From 8cec47281258897c4a282a17255bbf3e05db39e8 Mon Sep 17 00:00:00 2001
From: Peng-YM <1048217874pengym@gmail.com>
Date: Sun, 23 Aug 2020 12:25:02 +0800
Subject: [PATCH] Add some components
---
backend/.idea/workspace.xml | 108 +++++++++++++--------------
web/package-lock.json | 5 ++
web/package.json | 1 +
web/src/App.vue | 37 ++++++++++
web/src/components/BottomNav.vue | 1 -
web/src/main.js | 3 +-
web/src/router/index.js | 14 ++++
web/src/store/index.js | 49 ++++++++++---
web/src/views/Subscription.vue | 121 ++++++++++++++++++++++++++-----
9 files changed, 252 insertions(+), 87 deletions(-)
diff --git a/backend/.idea/workspace.xml b/backend/.idea/workspace.xml
index c41746a..e2a8f18 100644
--- a/backend/.idea/workspace.xml
+++ b/backend/.idea/workspace.xml
@@ -20,23 +20,15 @@
-
-
-
-
-
-
-
-
+
-
@@ -87,6 +79,8 @@
+
+
@@ -106,85 +100,85 @@
-
-
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
\ No newline at end of file
diff --git a/web/package-lock.json b/web/package-lock.json
index a6f678c..332f532 100644
--- a/web/package-lock.json
+++ b/web/package-lock.json
@@ -10888,6 +10888,11 @@
"integrity": "sha1-sj5DWK+oogL+ehAK8fX4g/AgB+4=",
"dev": true
},
+ "v-clipboard": {
+ "version": "2.2.3",
+ "resolved": "https://registry.npmjs.org/v-clipboard/-/v-clipboard-2.2.3.tgz",
+ "integrity": "sha512-Wg+ObZoYK6McHb5OOCFWvm0R7xHp0/p0G1ocx/8bO22jvA/yVY05rADbfiztwCokXBNfQuGv/XSd1ozcTFgekw=="
+ },
"v8-compile-cache": {
"version": "2.1.1",
"resolved": "https://registry.npm.taobao.org/v8-compile-cache/download/v8-compile-cache-2.1.1.tgz",
diff --git a/web/package.json b/web/package.json
index a3ff5bf..c7b9a29 100644
--- a/web/package.json
+++ b/web/package.json
@@ -12,6 +12,7 @@
"core-js": "^3.6.5",
"lodash": "^4.17.20",
"material-design-icons-iconfont": "^5.0.1",
+ "v-clipboard": "^2.2.3",
"vue": "^2.6.11",
"vue-router": "^3.4.3",
"vuetify": "^2.2.11",
diff --git a/web/src/App.vue b/web/src/App.vue
index 62321b8..4317d12 100644
--- a/web/src/App.vue
+++ b/web/src/App.vue
@@ -5,6 +5,25 @@
+
+ {{ successMessage }}
+
+
+
+ {{ errorMessage }}
+
@@ -32,7 +51,25 @@ export default {
},
computed: {
+ successMessage: function () {
+ return this.$store.state.successMessage;
+ },
+ errorMessage: function () {
+ return this.$store.state.errorMessage;
+ }
+ },
+ watch: {
+ successMessage: function () {
+ setTimeout(() => {
+ this.$store.commit("SET_SUCCESS_MESSAGE", "");
+ }, 1000);
+ },
+ errorMessage: function () {
+ setTimeout(() => {
+ this.$store.commit("SET_ERROR_MESSAGE", "");
+ }, 1000);
+ }
}
}
\ No newline at end of file
diff --git a/web/src/components/BottomNav.vue b/web/src/components/BottomNav.vue
index 12a8333..7400d15 100644
--- a/web/src/components/BottomNav.vue
+++ b/web/src/components/BottomNav.vue
@@ -1,5 +1,4 @@
-
{
const {data} = resp.data;
- commit("SET_SUBSCRIPTIONS", data);
+ state.subscriptions = data;
});
},
// fetch collections
- async FETCH_COLLECTIONS({commit}) {
+ async FETCH_COLLECTIONS({state}) {
axios.get("/collection").then(resp => {
const {data} = resp.data;
- commit("SET_COLLECTIONS", data);
+ state.collections = data;
});
+ },
+ // update subscriptions
+ async UPDATE_SUBSCRIPTION({commit}, {name, sub}) {
+ axios.patch(`/sub/${name}`, sub).then(() => {
+ commit("FETCH_SUBSCRIPTIONS");
+ });
+ },
+ // new subscription
+ async NEW_SUBSCRIPTION() {
+
+ },
+ // delete subscription
+ async DELETE_SUBSCRIPTION() {
+
+ },
+ // update collection
+ async UPDATE_COLLECTION() {
+
+ },
+ // new collection
+ async NEW_COLLECTION() {
+
+ },
+ // delete collection
+ async DELETE_COLLECTION() {
+
}
},
diff --git a/web/src/views/Subscription.vue b/web/src/views/Subscription.vue
index 03950c8..5b436db 100644
--- a/web/src/views/Subscription.vue
+++ b/web/src/views/Subscription.vue
@@ -1,33 +1,53 @@
-
+
单个订阅
-
-
+
+
-
- mdi-dots-vertical
-
+
+
+
+ mdi-dots-vertical
+
+
+
+
+
+ {{ menuItem.title }}
+
+
+
-
+
组合订阅
@@ -35,15 +55,15 @@
src="https://avatars2.githubusercontent.com/u/21050064?s=460&u=40a74913dd0a3d00670d05148c3a08c787470021&v=4">
-
+
{{ subs }}
@@ -51,9 +71,27 @@
-
- mdi-dots-vertical
-
+
+
+
+ mdi-dots-vertical
+
+
+
+
+
+ {{ menuItem.title }}
+
+
+
@@ -91,7 +129,21 @@
export default {
data: () => {
return {
- opened: false
+ opened: false,
+ editMenu: [
+ {
+ title: "复制",
+ action: "COPY"
+ },
+ {
+ title: "编辑",
+ action: "EDIT"
+ },
+ {
+ title: "删除",
+ action: "DELETE"
+ },
+ ]
}
},
@@ -104,6 +156,39 @@ export default {
const cols = this.$store.state.collections;
return Object.keys(cols).map(k => cols[k]);
}
+ },
+
+ methods: {
+ subscriptionMenu(action, sub) {
+ console.log(`${action} --> ${sub.name}`);
+ switch (action) {
+ case 'COPY':
+ this.$clipboard(`http://127.0.0.1:3000/download/${sub.name}`);
+ this.$store.commit("SET_SUCCESS_MESSAGE", "成功复制订阅链接");
+ break
+ case 'EDIT':
+ this.$router.push(`/sub-edit/${sub.name}`);
+ break
+ case 'DELETE':
+ break
+ }
+ },
+ collectionMenu(action, collection) {
+ console.log(`${action} --> ${collection.name}`);
+ switch (action) {
+ case 'COPY':
+ this.$clipboard(`http://127.0.0.1:3000/download/collection/${collection.name}`);
+ this.$store.commit("SET_SUCCESS_MESSAGE", "成功复制订阅链接");
+ break
+ case 'EDIT':
+ break
+ case 'DELETE':
+ break
+ }
+ },
+ preview(item) {
+ console.log(`PREVIEW: ${item.name}`);
+ },
}
}