yn_img_tools_app/src/stores/modules/common.js

40 lines
1.0 KiB
JavaScript
Raw Normal View History

2025-04-07 11:27:47 +08:00
import { ref } from 'vue'
2025-04-07 17:51:31 +08:00
import { defineStore } from 'pinia'
import { getProjectApi, getMajorApi } from '@/services/common'
2025-04-07 11:27:47 +08:00
export const useCommonStore = defineStore('common', () => {
// 项目数据
const projectList = ref([])
// 专业数据
const majorList = ref([])
// 存储项目数据
2025-04-07 17:51:31 +08:00
const getProjectList = async () => {
if (projectList.value.length < 1) {
const { data: result } = await getProjectApi({})
projectList.value = result
return projectList.value
} else {
return projectList.value
}
2025-04-07 11:27:47 +08:00
}
// 存储专业数据
2025-04-07 17:51:31 +08:00
const getMajorList = async () => {
if (majorList.value.length < 1) {
const { data: result } = await getMajorApi()
majorList.value = result
return majorList.value
} else {
return majorList.value
}
2025-04-07 11:27:47 +08:00
}
// 把数据和方法 return 出去
return {
projectList,
majorList,
2025-04-07 17:51:31 +08:00
getProjectList,
getMajorList,
2025-04-07 11:27:47 +08:00
}
})