kun-galgame-vue/src/store/modules/message.ts

41 lines
992 B
TypeScript
Raw Normal View History

2023-06-11 08:50:46 +00:00
import { defineStore } from 'pinia'
2023-09-28 13:07:12 +00:00
// message store 的类型
import { MessageStore } from '../types/message'
2023-06-11 08:50:46 +00:00
export const useKUNGalgameMessageStore = defineStore({
2023-10-07 08:51:14 +00:00
id: 'KUNGalgameMessage',
2023-09-24 07:30:42 +00:00
// 所有消息组件均不需要持久存储
2023-06-11 08:50:46 +00:00
persist: false,
2023-09-28 13:07:12 +00:00
state: (): MessageStore => ({
2023-06-11 08:50:46 +00:00
showInfo: false,
showAlert: false,
infoMsg: '',
alertMsg: '',
isShowCancel: false,
confirm: false,
2023-09-24 07:30:42 +00:00
isShowCapture: false,
isCaptureSuccessful: false,
2023-06-11 08:50:46 +00:00
}),
getters: {},
actions: {
info(infoMsg: string) {
this.showInfo = true
this.infoMsg = infoMsg
},
alert(alertMsg: string, isShowCancel: boolean): Promise<boolean> {
return new Promise<boolean>((resolve) => {
this.showAlert = true
this.alertMsg = alertMsg
this.isShowCancel = isShowCancel
this.handleClose = () => resolve(false)
this.handleConfirm = () => resolve(true)
})
},
handleClose() {},
handleConfirm() {},
},
})