mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-11 00:29:03 +08:00
添加导入导出配置功能
This commit is contained in:
parent
af9f96d101
commit
05f746571a
@ -62,7 +62,7 @@ export default {
|
|||||||
},
|
},
|
||||||
errorMessage() {
|
errorMessage() {
|
||||||
return this.$store.state.errorMessage;
|
return this.$store.state.errorMessage;
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
@ -75,7 +75,7 @@ export default {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.$store.commit("SET_ERROR_MESSAGE", "");
|
this.$store.commit("SET_ERROR_MESSAGE", "");
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -11,5 +11,6 @@ new Vue({
|
|||||||
vuetify,
|
vuetify,
|
||||||
router,
|
router,
|
||||||
store,
|
store,
|
||||||
|
Clipboard,
|
||||||
render: h => h(App)
|
render: h => h(App)
|
||||||
}).$mount('#app')
|
}).$mount('#app')
|
||||||
|
@ -8,6 +8,7 @@ const store = new Vuex.Store({
|
|||||||
state: {
|
state: {
|
||||||
title: "Sub-Store",
|
title: "Sub-Store",
|
||||||
isDarkMode: false,
|
isDarkMode: false,
|
||||||
|
clipboard: "",
|
||||||
|
|
||||||
successMessage: "",
|
successMessage: "",
|
||||||
errorMessage: "",
|
errorMessage: "",
|
||||||
@ -19,6 +20,9 @@ const store = new Vuex.Store({
|
|||||||
},
|
},
|
||||||
|
|
||||||
mutations: {
|
mutations: {
|
||||||
|
COPY(state, text) {
|
||||||
|
state.clipboard = text;
|
||||||
|
},
|
||||||
// UI
|
// UI
|
||||||
SET_NAV_TITLE(state, title) {
|
SET_NAV_TITLE(state, title) {
|
||||||
state.title = title;
|
state.title = title;
|
||||||
@ -33,7 +37,8 @@ const store = new Vuex.Store({
|
|||||||
|
|
||||||
SET_ERROR_MESSAGE(state, msg) {
|
SET_ERROR_MESSAGE(state, msg) {
|
||||||
state.errorMessage = msg;
|
state.errorMessage = msg;
|
||||||
}
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
required
|
required
|
||||||
label="订阅名称"
|
label="订阅名称"
|
||||||
placeholder="填入订阅名称,名称需唯一"
|
placeholder="填入订阅名称,名称需唯一"
|
||||||
|
clearable
|
||||||
|
clear-icon="clear"
|
||||||
/>
|
/>
|
||||||
<v-textarea
|
<v-textarea
|
||||||
v-model="options.url"
|
v-model="options.url"
|
||||||
@ -19,6 +21,8 @@
|
|||||||
required
|
required
|
||||||
label="订阅链接"
|
label="订阅链接"
|
||||||
placeholder="填入机场原始订阅链接"
|
placeholder="填入机场原始订阅链接"
|
||||||
|
clearable
|
||||||
|
clear-icon="clear"
|
||||||
/>
|
/>
|
||||||
</v-form>
|
</v-form>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
@ -26,9 +30,38 @@
|
|||||||
<v-btn icon @click="save">
|
<v-btn icon @click="save">
|
||||||
<v-icon>save_alt</v-icon>
|
<v-icon>save_alt</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-btn icon @click="discard">
|
<v-dialog max-width="400px" v-model="showShareDialog">
|
||||||
<v-icon>settings_backup_restore</v-icon>
|
<template #activator="{on}">
|
||||||
|
<v-btn icon v-on="on">
|
||||||
|
<v-icon>cloud_circle</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
</template>
|
||||||
|
<v-card class="pl-4 pr-4 pb-4 pt-4">
|
||||||
|
<v-card-title>
|
||||||
|
<v-icon left>cloud_circle</v-icon>
|
||||||
|
配置同步
|
||||||
|
<v-spacer/>
|
||||||
|
<v-btn icon @click="share">
|
||||||
|
<v-icon small>share</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</v-card-title>
|
||||||
|
<v-textarea
|
||||||
|
v-model="importedSub"
|
||||||
|
solo
|
||||||
|
label="粘贴配置以导入"
|
||||||
|
rows="5"
|
||||||
|
clearable
|
||||||
|
clear-icon="clear"
|
||||||
|
:rules="validations.importRules"
|
||||||
|
/>
|
||||||
|
<v-card-actions>
|
||||||
|
<v-spacer></v-spacer>
|
||||||
|
<v-btn text color="primary" @click="importSub">确认</v-btn>
|
||||||
|
<v-btn text @click="showShareDialog = false">取消</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
</v-card>
|
||||||
|
</v-dialog>
|
||||||
|
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card class="mb-4">
|
<v-card class="mb-4">
|
||||||
@ -238,11 +271,13 @@ export default {
|
|||||||
KeywordDeleteOperator,
|
KeywordDeleteOperator,
|
||||||
RegexDeleteOperator,
|
RegexDeleteOperator,
|
||||||
ScriptFilter,
|
ScriptFilter,
|
||||||
ScriptOperator
|
ScriptOperator,
|
||||||
},
|
},
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
selectedProcess: null,
|
selectedProcess: null,
|
||||||
|
showShareDialog: false,
|
||||||
|
importedSub: "",
|
||||||
dialog: false,
|
dialog: false,
|
||||||
validations: {
|
validations: {
|
||||||
nameRules: [
|
nameRules: [
|
||||||
@ -252,6 +287,9 @@ export default {
|
|||||||
urlRules: [
|
urlRules: [
|
||||||
v => !!v || "订阅链接不能为空!",
|
v => !!v || "订阅链接不能为空!",
|
||||||
v => /^https?:\/\//.test(v) || "订阅链接不合法!"
|
v => /^https?:\/\//.test(v) || "订阅链接不合法!"
|
||||||
|
],
|
||||||
|
importRules: [
|
||||||
|
v => !!v || "不能导入空配置!"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
formState: {
|
formState: {
|
||||||
@ -314,8 +352,31 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
discard() {
|
share() {
|
||||||
this.$router.back();
|
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) {
|
dataChanged(content) {
|
||||||
@ -368,7 +429,7 @@ export default {
|
|||||||
const cur = this.process[index];
|
const cur = this.process[index];
|
||||||
const next = this.process[index + 1]
|
const next = this.process[index + 1]
|
||||||
this.process.splice(index, 2, next, cur);
|
this.process.splice(index, 2, next, cur);
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user