Added subscription page

This commit is contained in:
Peng-YM
2020-08-23 00:56:35 +08:00
parent 72bb2f4edb
commit 0a11261eee
17 changed files with 401 additions and 65 deletions

View File

@@ -20,20 +20,23 @@
</component>
<component name="ChangeListManager">
<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 afterPath="$PROJECT_DIR$/../web/src/store/index.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../web/src/utils/index.js" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../web/src/views/CollectionEditor.vue" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../web/src/views/PopUpProxyList.vue" afterDir="false" />
<change afterPath="$PROJECT_DIR$/../web/src/views/SubEditor.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$/../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" />
<change beforePath="$PROJECT_DIR$/../web/src/router/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/router/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/views/Dashboard.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/views/Dashboard.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/views/Subscription.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/views/Subscription.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../web/src/views/User.vue" beforeDir="false" afterPath="$PROJECT_DIR$/../web/src/views/User.vue" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -55,6 +58,22 @@
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.detected.package.tslint" value="true" />
<property name="node.js.path.for.package.eslint" value="project" />
<property name="node.js.path.for.package.tslint" value="project" />
<property name="node.js.selected.package.eslint" value="(autodetect)" />
<property name="node.js.selected.package.tslint" value="(autodetect)" />
</component>
<component name="RunManager">
<configuration name="sub-store.js" type="NodeJSConfigurationType" temporary="true" nameIsGenerated="true" path-to-js-file="$PROJECT_DIR$/sub-store.js" working-dir="$PROJECT_DIR$">
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Node.js.sub-store.js" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
@@ -66,7 +85,8 @@
<updated>1597827738046</updated>
<workItem from="1597827739128" duration="775000" />
<workItem from="1597902241253" duration="776000" />
<workItem from="1598004165212" duration="170000" />
<workItem from="1598004165212" duration="400000" />
<workItem from="1598099373952" duration="2155000" />
</task>
<servers />
</component>
@@ -85,4 +105,86 @@
</option>
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="WindowStateProjectService">
<state width="840" height="374" key="GridCell.Tab.0.bottom" timestamp="1598115358068">
<screen x="0" y="0" width="1792" height="1120" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358068" />
<state width="840" height="303" key="GridCell.Tab.0.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598100552976" />
<state width="840" height="374" key="GridCell.Tab.0.center" timestamp="1598115358067">
<screen x="0" y="0" width="1792" height="1120" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358067" />
<state width="840" height="303" key="GridCell.Tab.0.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598100552975" />
<state width="840" height="374" key="GridCell.Tab.0.left" timestamp="1598115358067">
<screen x="0" y="0" width="1792" height="1120" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358067" />
<state width="840" height="303" key="GridCell.Tab.0.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598100552974" />
<state width="840" height="374" key="GridCell.Tab.0.right" timestamp="1598115358068">
<screen x="0" y="0" width="1792" height="1120" />
</state>
<state width="840" height="374" key="GridCell.Tab.0.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358068" />
<state width="840" height="303" key="GridCell.Tab.0.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598100552975" />
<state width="840" height="374" key="GridCell.Tab.1.bottom" timestamp="1598115358069">
<screen x="0" y="0" width="1792" height="1120" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
<state width="840" height="374" key="GridCell.Tab.1.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598099904581" />
<state width="840" height="374" key="GridCell.Tab.1.center" timestamp="1598115358069">
<screen x="0" y="0" width="1792" height="1120" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
<state width="840" height="374" key="GridCell.Tab.1.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598099904581" />
<state width="840" height="374" key="GridCell.Tab.1.left" timestamp="1598115358069">
<screen x="0" y="0" width="1792" height="1120" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
<state width="840" height="374" key="GridCell.Tab.1.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598099904581" />
<state width="840" height="374" key="GridCell.Tab.1.right" timestamp="1598115358069">
<screen x="0" y="0" width="1792" height="1120" />
</state>
<state width="840" height="374" key="GridCell.Tab.1.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358069" />
<state width="840" height="374" key="GridCell.Tab.1.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598099904581" />
<state width="840" height="374" key="GridCell.Tab.2.bottom" timestamp="1598115358071">
<screen x="0" y="0" width="1792" height="1120" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358071" />
<state width="840" height="374" key="GridCell.Tab.2.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598099904582" />
<state width="840" height="374" key="GridCell.Tab.2.center" timestamp="1598115358070">
<screen x="0" y="0" width="1792" height="1120" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358070" />
<state width="840" height="374" key="GridCell.Tab.2.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598099904582" />
<state width="840" height="374" key="GridCell.Tab.2.left" timestamp="1598115358070">
<screen x="0" y="0" width="1792" height="1120" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358070" />
<state width="840" height="374" key="GridCell.Tab.2.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598099904581" />
<state width="840" height="374" key="GridCell.Tab.2.right" timestamp="1598115358070">
<screen x="0" y="0" width="1792" height="1120" />
</state>
<state width="840" height="374" key="GridCell.Tab.2.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358070" />
<state width="840" height="374" key="GridCell.Tab.2.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598099904582" />
<state width="840" height="374" key="GridCell.Tab.3.bottom" timestamp="1598115358072">
<screen x="0" y="0" width="1792" height="1120" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.bottom/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358072" />
<state width="840" height="374" key="GridCell.Tab.3.bottom/70.23.1722.1097@70.23.1722.1097" timestamp="1598099904582" />
<state width="840" height="374" key="GridCell.Tab.3.center" timestamp="1598115358071">
<screen x="0" y="0" width="1792" height="1120" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.center/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358071" />
<state width="840" height="374" key="GridCell.Tab.3.center/70.23.1722.1097@70.23.1722.1097" timestamp="1598099904582" />
<state width="840" height="374" key="GridCell.Tab.3.left" timestamp="1598115358071">
<screen x="0" y="0" width="1792" height="1120" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.left/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358071" />
<state width="840" height="374" key="GridCell.Tab.3.left/70.23.1722.1097@70.23.1722.1097" timestamp="1598099904582" />
<state width="840" height="374" key="GridCell.Tab.3.right" timestamp="1598115358072">
<screen x="0" y="0" width="1792" height="1120" />
</state>
<state width="840" height="374" key="GridCell.Tab.3.right/0.0.1792.1120@0.0.1792.1120" timestamp="1598115358072" />
<state width="840" height="374" key="GridCell.Tab.3.right/70.23.1722.1097@70.23.1722.1097" timestamp="1598099904582" />
</component>
</project>

View File

@@ -21,12 +21,12 @@ if (!$.read(COLLECTIONS_KEY)) $.write({}, COLLECTIONS_KEY);
// BACKEND API
const $app = express();
$app.route("/sub/:name")
$app.route("/api/sub/:name")
.get(getSub)
.patch(updateSub)
.delete(deleteSub);
$app.route("/sub")
$app.route("/api/sub")
.get(getAllSubs)
.post(newSub)
.delete(deleteAllSubs);
@@ -36,11 +36,11 @@ $app.get("/download/:name", downloadSub);
// collections
$app.get("/download/collection/:name", downloadCollection);
$app.route("/collection/:name")
$app.route("/api/collection/:name")
.get(getCollection)
.patch(updateCollection)
.delete(deleteCollection);
$app.route("/collection")
$app.route("/api/collection")
.get(getAllCollections)
.post(newCollection)
.delete(deleteAllCollections);
@@ -203,8 +203,21 @@ async function updateSub(req, res) {
...sub
};
// allow users to update the subscription name
delete allSubs[name];
allSubs[sub.name || name] = newSub;
if (name !== sub.name) {
// we need to find out all collections refer to this name
const allCols = $.read(COLLECTIONS_KEY);
for (const k of Object.keys(allCols)) {
const idx = allCols[k].subscriptions.indexOf(name);
if (idx !== -1) {
allCols[k].subscriptions[idx] = sub.name;
}
}
// update subscriptions
delete allSubs[name];
allSubs[sub.name] = newSub;
} else {
allSubs[name] = newSub;
}
$.write(allSubs, SUBS_KEY);
res.json({
status: "success",
@@ -232,7 +245,7 @@ async function getAllSubs(req, res) {
const allSubs = $.read(SUBS_KEY);
res.json({
status: "success",
data: Object.keys(allSubs)
data: allSubs
});
}
@@ -349,7 +362,7 @@ async function getAllCollections(req, res) {
const allCols = $.read(COLLECTIONS_KEY);
res.json({
status: "success",
data: Object.keys(allCols)
data: allCols
});
}
@@ -2059,6 +2072,12 @@ function API(name = "untitled", debug = false) {
/*********************************** Mini Express *************************************/
function express(port = 3000) {
const {isNode} = ENV();
const DEFAULT_HEADERS = {
"Content-Type": "text/plain;charset=UTF-8",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept"
};
// node support
if (isNode) {
@@ -2068,6 +2087,10 @@ function express(port = 3000) {
app.use(bodyParser.json({verify: rawBodySaver}));
app.use(bodyParser.urlencoded({verify: rawBodySaver, extended: true}));
app.use(bodyParser.raw({verify: rawBodySaver, type: '*/*'}));
app.use((req, res, next) => {
res.set(DEFAULT_HEADERS);
next();
})
// adapter
app.start = () => {
@@ -2184,9 +2207,7 @@ function express(port = 3000) {
function Response() {
let statusCode = "200";
const {isQX, isLoon, isSurge} = ENV();
const headers = {
"Content-Type": "text/plain;charset=UTF-8",
};
const headers = DEFAULT_HEADERS;
return new (class {
status(code) {
statusCode = code;