Skip to content

Commit

Permalink
chore(web): sync readconfig only when readSetting unvisible
Browse files Browse the repository at this point in the history
  • Loading branch information
Xwite committed Oct 5, 2024
1 parent b80e549 commit 28f11e1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion modules/web/src/components/ReadSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 28f11e1

Please sign in to comment.