You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ocr-web/src/store/modules/final.ts

48 lines
1.0 KiB

import { defineStore } from 'pinia'
import { store } from '@/store'
import { getFilter } from '@/api/home/filter'
export interface ConfigState {
customConfig: string[] | null
asideValue: any
listKey: number
}
export const useFinalStore = defineStore({
id: 'app-final',
state: (): ConfigState => ({
customConfig: null,
asideValue: null,
listKey: 0,
}),
getters: {
getCustomConfig(): string[] | null {
return this.customConfig
},
getAsideValue(): any {
return this.asideValue
},
},
actions: {
setAsideValue(value) {
this.asideValue = value
},
setListKey() {
this.listKey = new Date().getTime()
},
// 获取终审个性化配置
async fetchCustomConfig() {
const res = await getFilter(1)
const { data } = res
const list = data && data.searchcount ? data.searchcount.split(',') : []
this.customConfig = list
return list
},
},
})
// Need to be used outside the setup
export function useFinal() {
return useFinalStore(store)
}