From 22cdf71a29635c394458733230b42c99b52d7ae6 Mon Sep 17 00:00:00 2001 From: Zyronon Date: Mon, 13 Oct 2025 02:37:40 +0800 Subject: [PATCH] save --- src/App.vue | 6 +++- src/apis/index.ts | 24 ++++++++++---- src/hooks/event.ts | 1 + src/pages/article/BookDetail.vue | 3 +- src/pages/article/components/EditBook.vue | 38 ++++++++++++++++------- src/stores/setting.ts | 17 +++++++--- src/types/func.ts | 9 +++++- src/types/types.ts | 6 +++- 8 files changed, 77 insertions(+), 27 deletions(-) diff --git a/src/App.vue b/src/App.vue index 3cfb144c..14ef6389 100644 --- a/src/App.vue +++ b/src/App.vue @@ -10,7 +10,8 @@ import { get, set } from 'idb-keyval' import { useRoute } from "vue-router"; import { DictId } from "@/types/types.ts"; -import { APP_VERSION, LOCAL_FILE_KEY, SAVE_DICT_KEY, SAVE_SETTING_KEY } from "@/config/env.ts"; +import { APP_VERSION, CAN_REQUEST, LOCAL_FILE_KEY, SAVE_DICT_KEY, SAVE_SETTING_KEY } from "@/config/env.ts"; +import { syncSetting } from "@/apis"; const store = useBaseStore() const runtimeStore = useRuntimeStore() @@ -50,6 +51,9 @@ watch(store.$state, (n: BaseState) => { watch(settingStore.$state, (n) => { set(SAVE_SETTING_KEY.key, JSON.stringify({val: n, version: SAVE_SETTING_KEY.version})) + if (CAN_REQUEST) { + syncSetting(null, settingStore.$state) + } }) async function init() { diff --git a/src/apis/index.ts b/src/apis/index.ts index d41055cc..eccb34be 100644 --- a/src/apis/index.ts +++ b/src/apis/index.ts @@ -13,25 +13,37 @@ function remove(data?: any) { } export function dictListVersion() { - return http('dicts/dictListVersion', null, null, 'get') + return http('dict/dictListVersion', null, null, 'get') } export function myDictList(params?) { - return http('dicts/myDictList', null, params, 'get') + return http('dict/myDictList', null, params, 'get') } export function add2MyDict(data) { - return http('dicts/add2MyDict', remove(data), null, 'post') + return http('dict/add2MyDict', remove(data), null, 'post') } export function addStat(data) { - return http('dicts/addStat', data, null, 'post') + return http('dict/addStat', data, null, 'post') } export function detail(params?, data?) { - return http('dicts/detail', data, params, 'get') + return http('dict/detail', data, params, 'get') } export function setDictProp(params?, data?) { - return http('dicts/setDictProp', remove(data), remove(params), 'post') + return http('dict/setDictProp', remove(data), remove(params), 'post') +} + +export function syncSetting(params?, data?) { + return http('dict/syncSetting', remove(data), remove(params), 'post') +} + +export function getSetting(params?, data?) { + return http('dict/getSetting', remove(data), remove(params), 'get') +} + +export function addDict(params?, data?) { + return http('dict/addDict', remove(data), remove(params), 'post') } diff --git a/src/hooks/event.ts b/src/hooks/event.ts index 67670a95..d2040cec 100644 --- a/src/hooks/event.ts +++ b/src/hooks/event.ts @@ -37,6 +37,7 @@ export function useEventListener(type: string, listener: EventListenerOrEventLis e.ctrlKey = false e.altKey = false e.shiftKey = false + //@ts-ignore listener(e) e.target.value = '1' }) diff --git a/src/pages/article/BookDetail.vue b/src/pages/article/BookDetail.vue index 1c7215c4..92e646d2 100644 --- a/src/pages/article/BookDetail.vue +++ b/src/pages/article/BookDetail.vue @@ -85,6 +85,7 @@ async function init() { if (!runtimeStore.editDict?.articles?.length && !runtimeStore.editDict?.custom && ![DictId.articleCollect].includes(runtimeStore.editDict.en_name || runtimeStore.editDict.id) + && !runtimeStore.editDict?.is_default ) { loading = true let r = await _getDictDataByUrl(runtimeStore.editDict, DictType.article) @@ -96,7 +97,7 @@ async function init() { let res = await detail({id: runtimeStore.editDict.id}) if (res.success) { runtimeStore.editDict.statistics = res.data.statistics - if (res.data.articles.length){ + if (res.data.articles.length) { runtimeStore.editDict.articles = res.data.articles } } diff --git a/src/pages/article/components/EditBook.vue b/src/pages/article/components/EditBook.vue index fad45c0c..fbfe96be 100644 --- a/src/pages/article/components/EditBook.vue +++ b/src/pages/article/components/EditBook.vue @@ -1,17 +1,19 @@