refactor(web): align resource APIs and forms with the starter conventions
Centralize typed resource functions under common/apis and return complete JSON envelopes while preserving raw responses, bearer session isolation, and single-owner errors. Keep settings state and queues inside the setup store. Use Element Plus forms and dialogs for login, settings, imports, moves, and images; preserve editor interactions and themes. Update callers, tests, generated declarations, and request import constraints together.
This commit is contained in:
1 parent
cef0298c34
commit
6b537c03e0
114 files changed
+2876
-2217
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import type { Settings } from '@/pinia/stores/settings'
|
||||
import { toast } from '@@/utils/notifications'
|
||||
import { isCancel } from 'axios'
|
||||
import { SettingsAppearanceError, useSettingsStore } from '@/pinia/stores/settings'
|
||||
|
||||
export function useSettingsChange() {
|
||||
const store = useSettingsStore()
|
||||
return async (patch: Partial<Settings>): Promise<boolean> => {
|
||||
try {
|
||||
await store.updateSettings(patch)
|
||||
return true
|
||||
} catch (cause) {
|
||||
if (isCancel(cause)) return false
|
||||
toast(cause instanceof Error ? cause.message : '保存设置失败')
|
||||
if (cause instanceof SettingsAppearanceError) return true
|
||||
try {
|
||||
await store.loadSettings()
|
||||
} catch (reload) {
|
||||
if (!isCancel(reload)) toast(`重新读取设置失败:${String(reload)}`)
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user