Skip to content

Commit ec4150d

Browse files
authored
fix: 修复配置项在重启后丢失的问题 (#656)
1 parent 3aa24f5 commit ec4150d

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/stores/cat.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export const useCatStore = defineStore('cat', () => {
4141
/** @deprecated 请使用 `window.opacity` */
4242
const opacity = ref(100)
4343

44+
/** @deprecated 用于标识数据是否已迁移,后续版本将删除 */
45+
const migrated = ref(false)
46+
4447
const model = reactive<CatStore['model']>({
4548
mirror: false,
4649
single: false,
@@ -57,6 +60,8 @@ export const useCatStore = defineStore('cat', () => {
5760
})
5861

5962
const init = () => {
63+
if (migrated.value) return
64+
6065
model.mirror = mirrorMode.value
6166
model.single = singleMode.value
6267
model.mouseMirror = mouseMirror.value
@@ -66,9 +71,12 @@ export const useCatStore = defineStore('cat', () => {
6671
window.alwaysOnTop = alwaysOnTop.value
6772
window.scale = scale.value
6873
window.opacity = opacity.value
74+
75+
migrated.value = true
6976
}
7077

7178
return {
79+
migrated,
7280
model,
7381
window,
7482
init,

src/stores/general.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export const useGeneralStore = defineStore('general', () => {
4141
/** @deprecated 请使用 `appearance.isDark` */
4242
const isDark = ref(false)
4343

44+
/** @deprecated 用于标识数据是否已迁移,后续版本将删除 */
45+
const migrated = ref(false)
46+
4447
const app = reactive<GeneralStore['app']>({
4548
autostart: false,
4649
taskbarVisible: false,
@@ -66,6 +69,10 @@ export const useGeneralStore = defineStore('general', () => {
6669
}
6770

6871
const init = async () => {
72+
appearance.language ??= await getLanguage()
73+
74+
if (migrated.value) return
75+
6976
app.autostart = autostart.value
7077
app.taskbarVisible = taskbarVisibility.value
7178

@@ -74,10 +81,11 @@ export const useGeneralStore = defineStore('general', () => {
7481

7582
update.autoCheck = autoCheckUpdate.value
7683

77-
appearance.language ??= await getLanguage()
84+
migrated.value = true
7885
}
7986

8087
return {
88+
migrated,
8189
app,
8290
appearance,
8391
update,

0 commit comments

Comments
 (0)