This commit is contained in:
2026-05-28 13:16:24 +08:00
parent 6f07c8bc15
commit b539cdb42f
34 changed files with 1118 additions and 779 deletions
+30 -26
View File
@@ -1,44 +1,48 @@
import { defineStore } from "pinia";
import api from "@/api";
import type { IHelperInfo } from "@/api/info/type";
import { defineStore } from 'pinia'
import api from '@/api'
import type { IHelperInfo } from '@/api/info/type'
export const useDnfHelperStore = defineStore("dnfHelperStore", () => {
const helperInfo = useLocalStorage<IHelperInfo | null>("dnfHelperInfo", null, {
export const useDnfHelperStore = defineStore('dnfHelperStore', () => {
const helperInfo = useLocalStorage<IHelperInfo | null>('dnfHelperInfo', null, {
serializer: {
read: (v) => (v ? JSON.parse(v) : null),
write: (v) => JSON.stringify(v),
},
});
})
const loading = ref(false);
const errorMessage = ref("");
const loading = ref(false)
const errorMessage = ref('')
const refleshHelperInfo = async (uid?: string) => {
if (!uid) return;
loading.value = true;
errorMessage.value = "";
const refreshHelperInfoInner = async (uid?: string) => {
if (!uid) return
loading.value = true
errorMessage.value = ''
try {
const data = await api.getHelperList(uid);
const data = await api.getHelperList(uid)
if (data) {
helperInfo.value = data;
helperInfo.value = data
}
} catch (error) {
errorMessage.value = error instanceof Error ? error.message : "同步助手数据失败";
throw error;
errorMessage.value = error instanceof Error ? error.message : '同步助手数据失败'
throw error
} finally {
loading.value = false;
loading.value = false
}
};
}
const refreshHelperInfo = async (uid?: string) => {
await refleshHelperInfo(uid);
};
await refreshHelperInfoInner(uid)
}
// Keep compatibility with existing callers.
const refleshHelperInfo = async (uid?: string) => {
await refreshHelperInfoInner(uid)
}
const logout = () => {
helperInfo.value = null;
errorMessage.value = "";
};
helperInfo.value = null
errorMessage.value = ''
}
return {
helperInfo,
@@ -47,5 +51,5 @@ export const useDnfHelperStore = defineStore("dnfHelperStore", () => {
refleshHelperInfo,
refreshHelperInfo,
logout,
};
});
}
})