Files
FastapiAdmin/frontend/app/src/composables/useGlobalMessage.ts
T
zhangtao 27ab0d802c refactor(frontend): 清理废弃资源与代码,优化项目结构
1.  删除大量旧版静态图标、图片资源,替换为新的svg图标
2.  移除废弃的API模块、页面组件与配置文件
3.  新增全局消息store与通用列表分页hook
4.  优化代码逻辑:简化错误处理、调整样式类顺序、更新路由鉴权
5.  替换旧的按钮样式属性,统一代码规范
2026-08-03 00:15:44 +08:00

33 lines
829 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { defineStore } from 'pinia'
export interface GlobalMessageOptions {
title?: string
content?: string
type?: 'alert' | 'confirm'
showCancel?: boolean
confirmText?: string
cancelText?: string
success?: (res: { confirm: boolean, cancel: boolean }) => void
fail?: (err: unknown) => void
}
/**
* 全局消息 storeGlobalMessage 组件监听 messageOptions
* 仅当触发页面与 currentPage 一致时展示,避免跨页误弹
*/
export const useGlobalMessage = defineStore('global-message', {
state: () => ({
messageOptions: null as GlobalMessageOptions | null,
currentPage: '',
}),
actions: {
show(options: GlobalMessageOptions) {
this.currentPage = getCurrentPath()
this.messageOptions = options
},
close() {
this.messageOptions = null
},
},
})