import { defineStore } from 'pinia'
|
|
import { ref, computed, reactive } from 'vue'
|
|
import api from '@/api'
|
|
|
|
// 定义案例数据存储
|
|
export const useConfigStore = defineStore('config', () => {
|
|
|
|
const configParams = reactive({})
|
|
|
|
const map = {
|
|
0 : 'text',
|
|
1 : 'content',
|
|
2 : 'imageUrl',
|
|
}
|
|
|
|
const getConfigParams = async () => {
|
|
const res = await api.fetchConfigParams()
|
|
res.forEach(item => {
|
|
configParams[item.code] = item[map[item.type]]
|
|
})
|
|
}
|
|
return {
|
|
configParams,
|
|
getConfigParams
|
|
}
|
|
})
|