From 28f11e148b66bb421fb88d3e4f8538ec46dfe9fa Mon Sep 17 00:00:00 2001 From: Xwite <1797350009@qq.com> Date: Sat, 5 Oct 2024 06:38:31 +0800 Subject: [PATCH] chore(web): sync readconfig only when readSetting unvisible --- modules/web/src/components/ReadSettings.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/web/src/components/ReadSettings.vue b/modules/web/src/components/ReadSettings.vue index f8fdcb80a..7e0c05b55 100644 --- a/modules/web/src/components/ReadSettings.vue +++ b/modules/web/src/components/ReadSettings.vue @@ -192,16 +192,25 @@ import API from "@api"; const store = useBookStore(); //阅读界面设置改变时保存同步配置 +let configChanged = false; watch( () => store.config, (newValue) => { localStorage.setItem("config", JSON.stringify(newValue)); - API.saveReadConfig(newValue); + configChanged = true; }, { deep: 2, //深度为2 }, ); +// 设置页面关闭时同步设置到阅读APP +watch( + () => store.readSettingsVisible, + (visbile) => { + if (!visbile && configChanged) + API.saveReadConfig(store.config).then(() => (configChanged = false)); + }, +); //主题颜色 const theme = computed(() => store.theme);