mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 04:46:26 +00:00
1. 删除大量旧版静态图标、图片资源,替换为新的svg图标 2. 移除废弃的API模块、页面组件与配置文件 3. 新增全局消息store与通用列表分页hook 4. 优化代码逻辑:简化错误处理、调整样式类顺序、更新路由鉴权 5. 替换旧的按钮样式属性,统一代码规范
33 lines
829 B
TypeScript
33 lines
829 B
TypeScript
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
|
||
}
|
||
|
||
/**
|
||
* 全局消息 store:GlobalMessage 组件监听 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
|
||
},
|
||
},
|
||
})
|