feat:项目界面补充

This commit is contained in:
JiaJun
2026-04-10 17:29:49 +08:00
parent af3ed15ba2
commit 8fcf0355b3
19 changed files with 292 additions and 407 deletions

View File

@@ -15,6 +15,7 @@ type ToastStore = {
}
let toastTimer: ReturnType<typeof setTimeout> | null = null
let toastRemoveTimer: ReturnType<typeof setTimeout> | null = null
export function resolveToastMessage(source: unknown, fallback = '') {
if (typeof source === 'string' && source.trim()) {
@@ -37,18 +38,44 @@ export const useToastStore = create<ToastStore>((set) => ({
if (toastTimer) {
clearTimeout(toastTimer)
}
if (toastRemoveTimer) {
clearTimeout(toastRemoveTimer)
}
set({
toast: {
message,
type,
visible: true,
visible: false,
},
})
requestAnimationFrame(() => {
set((state) => state.toast
? {
toast: {
...state.toast,
visible: true,
},
}
: state)
})
toastTimer = setTimeout(() => {
set({toast: null})
set((state) => state.toast
? {
toast: {
...state.toast,
visible: false,
},
}
: state)
toastTimer = null
toastRemoveTimer = setTimeout(() => {
set({toast: null})
toastRemoveTimer = null
}, 220)
}, 2000)
},
clearToast: () => {
@@ -56,6 +83,10 @@ export const useToastStore = create<ToastStore>((set) => ({
clearTimeout(toastTimer)
toastTimer = null
}
if (toastRemoveTimer) {
clearTimeout(toastRemoveTimer)
toastRemoveTimer = null
}
set({toast: null})
},
}))