Support remote script

This commit is contained in:
Peng-YM 2020-08-21 18:06:27 +08:00
parent a610346c5d
commit 343692db86
14 changed files with 158 additions and 29 deletions

View File

@ -20,7 +20,20 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="8b97a098-48b2-4e64-a9ef-522fe2d30b52" name="Default Changelist" comment=""> <list default="true" id="8b97a098-48b2-4e64-a9ef-522fe2d30b52" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/../web/src/router/index.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../web/src/views/Dashboard.vue" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../web/src/views/Subscription.vue" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../web/src/views/User.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/sub-store.js" beforeDir="false" afterPath="$PROJECT_DIR$/sub-store.js" afterDir="false" /> <change beforePath="$PROJECT_DIR$/sub-store.js" beforeDir="false" afterPath="$PROJECT_DIR$/sub-store.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/../web/package-lock.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/../web/package.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/App.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/App.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/assets/logo.svg" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/assets/logo.svg" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/components/BottomNav.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/components/BottomNav.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/components/TopToolbar.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/components/TopToolbar.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/main.js" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/main.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/plugins/vuetify.js" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/plugins/vuetify.js" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -52,6 +65,8 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1597827738046</updated> <updated>1597827738046</updated>
<workItem from="1597827739128" duration="775000" /> <workItem from="1597827739128" duration="775000" />
<workItem from="1597902241253" duration="776000" />
<workItem from="1598004165212" duration="170000" />
</task> </task>
<servers /> <servers />
</component> </component>
@ -68,5 +83,6 @@
</entry> </entry>
</map> </map>
</option> </option>
<option name="oldMeFiltersMigrated" value="true" />
</component> </component>
</project> </project>

View File

@ -123,6 +123,7 @@ async function parseSub(sub, platform) {
const $operator = ProxyOperator(); const $operator = ProxyOperator();
for (const item of sub.process || []) { for (const item of sub.process || []) {
// process script
if (item.type.indexOf("Script") !== -1) { if (item.type.indexOf("Script") !== -1) {
if (item.args && item.args[0].indexOf("http") !== -1) { if (item.args && item.args[0].indexOf("http") !== -1) {
// if this is remote script // if this is remote script
@ -201,7 +202,9 @@ async function updateSub(req, res) {
...allSubs[name], ...allSubs[name],
...sub ...sub
}; };
allSubs[name] = newSub; // allow users to update the subscription name
delete allSubs[name];
allSubs[sub.name || name] = newSub;
$.write(allSubs, SUBS_KEY); $.write(allSubs, SUBS_KEY);
res.json({ res.json({
status: "success", status: "success",
@ -316,7 +319,9 @@ async function updateCollection(req, res) {
...allCol[name], ...allCol[name],
...collection ...collection
}; };
allCol[name] = newCol; // allow users to update collection name
delete allCol[name];
allCol[collection.name || name] = newCol;
$.write(allCol, COLLECTIONS_KEY); $.write(allCol, COLLECTIONS_KEY);
res.json({ res.json({
status: "success", status: "success",
@ -1489,6 +1494,15 @@ function ScriptOperator(script) {
name: "Script Operator", name: "Script Operator",
func: (proxies) => { func: (proxies) => {
;(function () { ;(function () {
// interface to get internal operators
const $get = (name, args) => {
const operator = AVAILABLE_OPERATORS[name];
if (operator) {
return operator(args).func;
} else {
throw new Error(`No operator named ${name} is found!`);
}
};
eval(script); eval(script);
return func(proxies); return func(proxies);
})(); })();
@ -1588,15 +1602,24 @@ function TypeFilter(...types) {
} }
WARNING: WARNING:
1. This function name should be `func`! 1. This function name should be `func`!
2. Always declare variable before using it! 2. Always declare variables before using them!
*/ */
function ScriptFilter(script) { function ScriptFilter(script) {
return { return {
name: "Script Filter", name: "Script Filter",
func: (proxies) => { func: (proxies) => {
!(function () { !(function () {
// interface to get internal filters
const $get = (name, args) => {
const filter = AVAILABLE_FILTERS[name];
if (filter) {
return filter(args).func;
} else {
throw new Error(`No filter named ${name} is found!`);
}
};
eval(script); eval(script);
return filter(proxies); return func(proxies);
})(); })();
} }
} }

5
web/package-lock.json generated
View File

@ -11114,6 +11114,11 @@
} }
} }
}, },
"vue-router": {
"version": "3.4.3",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.4.3.tgz",
"integrity": "sha512-BADg1mjGWX18Dpmy6bOGzGNnk7B/ZA0RxuA6qedY/YJwirMfKXIDzcccmHbQI0A6k5PzMdMloc0ElHfyOoX35A=="
},
"vue-style-loader": { "vue-style-loader": {
"version": "4.1.2", "version": "4.1.2",
"resolved": "https://registry.npm.taobao.org/vue-style-loader/download/vue-style-loader-4.1.2.tgz", "resolved": "https://registry.npm.taobao.org/vue-style-loader/download/vue-style-loader-4.1.2.tgz",

View File

@ -13,6 +13,7 @@
"lodash": "^4.17.20", "lodash": "^4.17.20",
"material-design-icons-iconfont": "^5.0.1", "material-design-icons-iconfont": "^5.0.1",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-router": "^3.4.3",
"vuetify": "^2.2.11" "vuetify": "^2.2.11"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,6 +1,9 @@
<template> <template>
<v-app> <v-app>
<TopToolbar></TopToolbar> <TopToolbar></TopToolbar>
<v-content>
<router-view></router-view>
</v-content>
<BottomNav></BottomNav> <BottomNav></BottomNav>
</v-app> </v-app>
</template> </template>
@ -15,16 +18,15 @@ export default {
BottomNav BottomNav
}, },
props: {
source: String,
},
data: () => ({
drawer: null,
}),
created() { created() {
this.$vuetify.theme.dark = true this.$vuetify.theme.dark = true;
this.$vuetify.theme.themes.dark.primary = '#d02f2f';
}, },
computed: {
isDarkMode() {
return true;
}
}
} }
</script> </script>

View File

@ -1 +1,10 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 87.5 100"><defs><style>.cls-1{fill:#1697f6;}.cls-2{fill:#7bc6ff;}.cls-3{fill:#1867c0;}.cls-4{fill:#aeddff;}</style></defs><title>Artboard 46</title><polyline class="cls-1" points="43.75 0 23.31 0 43.75 48.32"/><polygon class="cls-2" points="43.75 62.5 43.75 100 0 14.58 22.92 14.58 43.75 62.5"/><polyline class="cls-3" points="43.75 0 64.19 0 43.75 48.32"/><polygon class="cls-4" points="64.58 14.58 87.5 14.58 43.75 100 43.75 62.5 64.58 14.58"/></svg> <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 87.5 100">
<defs>
<style>.cls-1{fill:#1697f6;}.cls-2{fill:#7bc6ff;}.cls-3{fill:#1867c0;}.cls-4{fill:#aeddff;}</style>
</defs>
<title>Artboard 46</title>
<polyline class="cls-1" points="43.75 0 23.31 0 43.75 48.32"/>
<polygon class="cls-2" points="43.75 62.5 43.75 100 0 14.58 22.92 14.58 43.75 62.5"/>
<polyline class="cls-3" points="43.75 0 64.19 0 43.75 48.32"/>
<polygon class="cls-4" points="64.58 14.58 87.5 14.58 43.75 100 43.75 62.5 64.58 14.58"/>
</svg>

Before

Width:  |  Height:  |  Size: 539 B

After

Width:  |  Height:  |  Size: 584 B

View File

@ -2,24 +2,24 @@
<v-bottom-navigation <v-bottom-navigation
app app
color="primary"
fixed fixed
grow grow
v-model="activeItem" v-model="activeItem"
color="primary"
> >
<v-btn value="dashboard"> <v-btn :to="{path:'/dashboard'}" value="dashboard">
<span>首页</span> <span>首页</span>
<v-icon>dashboard</v-icon> <v-icon>dashboard</v-icon>
</v-btn> </v-btn>
<v-btn value="collection"> <v-btn :to="{path: '/'}" value="subscription">
<span>订阅</span> <span>订阅</span>
<v-icon>favorite</v-icon> <v-icon>favorite</v-icon>
</v-btn> </v-btn>
<v-btn value="subscription"> <v-btn :to="{path: '/user'}" value="user">
<span>机场</span> <span>我的</span>
<v-icon>code</v-icon> <v-icon>settings</v-icon>
</v-btn> </v-btn>
@ -31,7 +31,7 @@
export default { export default {
data: () => { data: () => {
return { return {
activeItem: 'collection' activeItem: 'subscription'
} }
} }
} }

View File

@ -28,9 +28,9 @@
<v-app-bar <v-app-bar
app app
fixed
dark
color="primary" color="primary"
dark
fixed
> >
<v-app-bar-nav-icon @click.stop="toggleMenu"></v-app-bar-nav-icon> <v-app-bar-nav-icon @click.stop="toggleMenu"></v-app-bar-nav-icon>
@ -50,10 +50,10 @@ export default {
}, },
methods: { methods: {
toggleMenu: function() { toggleMenu: function () {
this.showMenu = !this.showMenu; this.showMenu = !this.showMenu;
}, },
doNothing: function() { doNothing: function () {
} }
} }

View File

@ -1,10 +1,12 @@
import Vue from 'vue' import Vue from 'vue'
import App from './App.vue' import App from './App.vue'
import vuetify from './plugins/vuetify'; import vuetify from './plugins/vuetify';
import router from './router';
Vue.config.productionTip = false Vue.config.productionTip = false
new Vue({ new Vue({
vuetify, vuetify,
render: h => h(App) router,
render: h => h(App)
}).$mount('#app') }).$mount('#app')

View File

@ -4,5 +4,4 @@ import 'material-design-icons-iconfont/dist/material-design-icons.css'
Vue.use(Vuetify); Vue.use(Vuetify);
export default new Vuetify({ export default new Vuetify({});
});

32
web/src/router/index.js Normal file
View File

@ -0,0 +1,32 @@
import Vue from 'vue';
import Router from 'vue-router';
import Subscription from "@/views/Subscription";
import Dashboard from "@/views/Dashboard";
import User from "@/views/User";
Vue.use(Router);
const router = new Router({
mode: "history",
base: process.env.BASE_URL,
routes: [
{
path: "/",
name: "subscriptions",
component: Subscription
},
{
path: "/dashboard",
name: "dashboard",
component: Dashboard
},
{
path: "/user",
name: "user",
component: User
}
]
});
export default router;

View File

@ -0,0 +1,15 @@
<template>
<v-container>
<h1 class="headline">首页</h1>
</v-container>
</template>
<script>
export default {
name: "Dashboard"
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,10 @@
<template>
<v-container>
<h1 class="headline">订阅</h1>
</v-container>
</template>
<style scoped>
</style>

15
web/src/views/User.vue Normal file
View File

@ -0,0 +1,15 @@
<template>
<v-container>
<h1 class="headline">用户</h1>
</v-container>
</template>
<script>
export default {
name: "User"
}
</script>
<style scoped>
</style>