mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-06-16 02:37:19 +08:00
Add some logs
This commit is contained in:
parent
4b25874dc6
commit
8b626ffad3
@ -129,20 +129,24 @@ async function gistBackup(req, res) {
|
|||||||
case "upload":
|
case "upload":
|
||||||
content = $.read("#sub-store");
|
content = $.read("#sub-store");
|
||||||
await gist.upload(JSON.stringify(content));
|
await gist.upload(JSON.stringify(content));
|
||||||
|
$.info(`上传备份中...`);
|
||||||
break;
|
break;
|
||||||
case "download":
|
case "download":
|
||||||
content = await gist.download();
|
content = await gist.download();
|
||||||
// restore settings
|
// restore settings
|
||||||
$.write(content,"#sub-store");
|
$.write(content,"#sub-store");
|
||||||
|
$.info(`还原备份中...`);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
res.json({
|
res.json({
|
||||||
status: "success",
|
status: "success",
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
const msg = `${action === "upload" ? "上传" : "下载"}备份失败!${err}`;
|
||||||
|
$.error(msg);
|
||||||
res.status(500).json({
|
res.status(500).json({
|
||||||
status: "failed",
|
status: "failed",
|
||||||
message: `${action === "upload" ? "上传" : "下载"}备份失败!${err}`
|
message: msg
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
backend/sub-store.min.js
vendored
2
backend/sub-store.min.js
vendored
File diff suppressed because one or more lines are too long
@ -26,7 +26,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {axios} from "@/utils";
|
import {axios, showError} from "@/utils";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@ -53,12 +53,23 @@ export default {
|
|||||||
}
|
}
|
||||||
this.save();
|
this.save();
|
||||||
axios.get(`/backup?action=${action}`).then(resp => {
|
axios.get(`/backup?action=${action}`).then(resp => {
|
||||||
if (resp.data.status === 'success')
|
if (resp.data.status === 'success') {
|
||||||
this.$store.commit("SET_SUCCESS_MESSAGE", `${action === 'upload' ? "备份" : "还原"}成功!`);
|
this.$store.commit("SET_SUCCESS_MESSAGE", `${action === 'upload' ? "备份" : "还原"}成功!`);
|
||||||
|
this.updateStore(this.$store);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
this.$store.commit("SET_ERROR_MESSAGE", `备份失败!${resp.data.message}`);
|
this.$store.commit("SET_ERROR_MESSAGE", `备份失败!${resp.data.message}`);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateStore(store) {
|
||||||
|
store.dispatch('FETCH_SUBSCRIPTIONS').catch(() => {
|
||||||
|
showError(`无法拉取订阅列表!`);
|
||||||
|
});
|
||||||
|
store.dispatch("FETCH_COLLECTIONS").catch(() => {
|
||||||
|
showError(`无法拉取组合订阅列表!`);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user