From 05f746571acf54e672d15b397cd49e0a77e11738 Mon Sep 17 00:00:00 2001
From: Peng-YM <1048217874pengym@gmail.com>
Date: Fri, 18 Sep 2020 12:56:37 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=BC=E5=85=A5=E5=AF=BC?=
=?UTF-8?q?=E5=87=BA=E9=85=8D=E7=BD=AE=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
web/src/App.vue | 4 +-
web/src/main.js | 1 +
web/src/store/index.js | 7 +++-
web/src/views/SubEditor.vue | 75 +++++++++++++++++++++++++++++++++----
4 files changed, 77 insertions(+), 10 deletions(-)
diff --git a/web/src/App.vue b/web/src/App.vue
index 27e0b05..641e695 100644
--- a/web/src/App.vue
+++ b/web/src/App.vue
@@ -62,7 +62,7 @@ export default {
},
errorMessage() {
return this.$store.state.errorMessage;
- }
+ },
},
watch: {
@@ -75,7 +75,7 @@ export default {
setTimeout(() => {
this.$store.commit("SET_ERROR_MESSAGE", "");
}, 1000);
- }
+ },
}
}
diff --git a/web/src/main.js b/web/src/main.js
index 4a2ed45..365809e 100644
--- a/web/src/main.js
+++ b/web/src/main.js
@@ -11,5 +11,6 @@ new Vue({
vuetify,
router,
store,
+ Clipboard,
render: h => h(App)
}).$mount('#app')
diff --git a/web/src/store/index.js b/web/src/store/index.js
index 4f52c84..e08ff9b 100644
--- a/web/src/store/index.js
+++ b/web/src/store/index.js
@@ -8,6 +8,7 @@ const store = new Vuex.Store({
state: {
title: "Sub-Store",
isDarkMode: false,
+ clipboard: "",
successMessage: "",
errorMessage: "",
@@ -19,6 +20,9 @@ const store = new Vuex.Store({
},
mutations: {
+ COPY(state, text) {
+ state.clipboard = text;
+ },
// UI
SET_NAV_TITLE(state, title) {
state.title = title;
@@ -33,7 +37,8 @@ const store = new Vuex.Store({
SET_ERROR_MESSAGE(state, msg) {
state.errorMessage = msg;
- }
+ },
+
},
actions: {
diff --git a/web/src/views/SubEditor.vue b/web/src/views/SubEditor.vue
index 7213ef7..d9b0974 100644
--- a/web/src/views/SubEditor.vue
+++ b/web/src/views/SubEditor.vue
@@ -10,6 +10,8 @@
required
label="订阅名称"
placeholder="填入订阅名称,名称需唯一"
+ clearable
+ clear-icon="clear"
/>
@@ -26,9 +30,38 @@
save_alt
-
- settings_backup_restore
-
+
+
+
+ cloud_circle
+
+
+
+
+ cloud_circle
+ 配置同步
+
+
+ share
+
+
+
+
+
+ 确认
+ 取消
+
+
+
+
@@ -238,11 +271,13 @@ export default {
KeywordDeleteOperator,
RegexDeleteOperator,
ScriptFilter,
- ScriptOperator
+ ScriptOperator,
},
data: function () {
return {
selectedProcess: null,
+ showShareDialog: false,
+ importedSub: "",
dialog: false,
validations: {
nameRules: [
@@ -252,6 +287,9 @@ export default {
urlRules: [
v => !!v || "订阅链接不能为空!",
v => /^https?:\/\//.test(v) || "订阅链接不合法!"
+ ],
+ importRules: [
+ v => !!v || "不能导入空配置!"
]
},
formState: {
@@ -314,8 +352,31 @@ export default {
}
},
- discard() {
- this.$router.back();
+ share() {
+ let sub = buildSubscription(this.options, this.process);
+ sub.name = "「订阅名称」";
+ sub.url = "「订阅链接」";
+ sub = JSON.stringify(sub);
+ this.$clipboard(sub);
+ this.$store.commit("SET_SUCCESS_MESSAGE", "导出成功,订阅已复制到剪贴板!");
+ this.showShareDialog = false;
+ },
+
+ importSub() {
+ if (this.importedSub) {
+ const sub = JSON.parse(this.importedSub);
+ const {options, process} = loadSubscription(this.options, sub);
+ delete options.name;
+ delete options.url;
+
+ Object.assign(this.options, options);
+ this.process = process;
+
+ this.$store.commit("SET_SUCCESS_MESSAGE", "成功导入订阅!");
+ this.showShareDialog = false;
+ } else {
+ this.$store.commit("SET_ERROR_MESSAGE", "不能导入空配置!");
+ }
},
dataChanged(content) {
@@ -368,7 +429,7 @@ export default {
const cur = this.process[index];
const next = this.process[index + 1]
this.process.splice(index, 2, next, cur);
- }
+ },
}
}