2023-11-24 11:02:52 +00:00
|
|
|
import { defineStore } from 'pinia'
|
2024-05-22 06:54:37 +00:00
|
|
|
import { DeviceType } from '@/enums/common'
|
2023-11-24 11:02:52 +00:00
|
|
|
|
2024-04-10 06:16:56 +00:00
|
|
|
export interface commonTypes {
|
|
|
|
|
breadcrumb: any
|
|
|
|
|
paginationConfig: any | null
|
|
|
|
|
search: any
|
2024-05-22 06:54:37 +00:00
|
|
|
device: string
|
2024-04-10 06:16:56 +00:00
|
|
|
}
|
|
|
|
|
|
2023-11-24 11:02:52 +00:00
|
|
|
const useCommonStore = defineStore({
|
|
|
|
|
id: 'common',
|
2024-04-10 06:16:56 +00:00
|
|
|
state: (): commonTypes => ({
|
|
|
|
|
breadcrumb: null,
|
|
|
|
|
// 搜索和分页缓存
|
|
|
|
|
paginationConfig: {},
|
2024-05-22 06:54:37 +00:00
|
|
|
search: {},
|
|
|
|
|
device: DeviceType.Desktop
|
2023-11-24 11:02:52 +00:00
|
|
|
}),
|
|
|
|
|
actions: {
|
2023-12-04 03:18:12 +00:00
|
|
|
saveBreadcrumb(data: any) {
|
2023-11-24 11:02:52 +00:00
|
|
|
this.breadcrumb = data
|
2024-04-10 06:16:56 +00:00
|
|
|
},
|
|
|
|
|
savePage(val: string, data: any) {
|
|
|
|
|
this.paginationConfig[val] = data
|
|
|
|
|
},
|
|
|
|
|
saveCondition(val: string, data: any) {
|
|
|
|
|
this.search[val] = data
|
2024-05-22 06:54:37 +00:00
|
|
|
},
|
|
|
|
|
toggleDevice(value: DeviceType) {
|
|
|
|
|
this.device = value
|
|
|
|
|
},
|
|
|
|
|
isMobile() {
|
|
|
|
|
return this.device === DeviceType.Mobile
|
2023-11-24 11:02:52 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
export default useCommonStore
|