feat: move pinia to new folder

This commit is contained in:
IchliebedichZhu 2024-03-18 23:19:29 +00:00
parent 9e2e9228a8
commit a7334b7749
6 changed files with 69 additions and 45 deletions

50
src/pinia/base/index.ts Normal file
View File

@ -0,0 +1,50 @@
/*
* @Author: Jeremy Yu
* @Date: 2024-03-17 15:00:00
* @Description: Base全局状态管理
* @LastEditors: Jeremy Yu <https://github.com/JeremyYu-cn>
* @LastEditTime: 2024-03-18 21:00:00
*/
import { defineStore } from 'pinia'
// import actions from './actions'
// import _config from '@/config'
type TStoreBaseState = {
loading: boolean | null
scroll: boolean
/** fonts */
fonts: string[]
/** 抠图服务 */
app: string | null
}
type TUserAction = {
hideLoading: () => void
setFonts: (list: string[]) => void
}
/** Base全局状态管理 */
const useBaseStore = defineStore<'base', TStoreBaseState, {}, TUserAction>('base', {
state: () => ({
loading: null,
scroll: true,
fonts: [], // 缓存字体列表
app: null, // 抠图服务
}),
actions: {
/** 隐藏loading */
hideLoading() {
setTimeout(() => {
this.loading = false
}, 600)
},
setFonts(list: string[]) {
this.fonts = list
},
}
})
export default useBaseStore

View File

@ -3,7 +3,7 @@
* @Date: 2024-03-17 15:00:00
* @Description: User全局状态管理
* @LastEditors: Jeremy Yu <https://github.com/JeremyYu-cn>
* @LastEditTime: 2024-03-17 15:00:00
* @LastEditTime: 2024-03-18 21:00:00
*/
import { defineStore } from "pinia"
@ -29,6 +29,7 @@ type TUserAction = {
managerEdit: (status: boolean) => void
}
/** User全局状态管理 */
const useUserStore = defineStore<'userStore', TUserStoreState, {}, TUserAction>('userStore', {
state: () => ({
online: true, // 登录状态,

15
src/pinia/index.ts Normal file
View File

@ -0,0 +1,15 @@
/*
* @Author: Jeremy Yu
* @Date: 2024-03-18 21:00:00
* @Description:
* @LastEditors: Jeremy Yu <https://github.com/JeremyYu-cn>
* @LastEditTime: 2024-03-18 21:00:00
*/
import useBaseStore from "./base";
import useUserStore from "./base/user";
export {
useBaseStore,
useUserStore,
}

View File

@ -6,47 +6,6 @@
* @LastEditTime: 2024-03-17 15:00:00
*/
import { defineStore } from 'pinia'
// import actions from './actions'
// import _config from '@/config'
type TStoreBaseState = {
loading: boolean | null
scroll: boolean
/** fonts */
fonts: string[]
/** 抠图服务 */
app: string | null
}
type TUserAction = {
hideLoading: () => void
setFonts: (list: string[]) => void
}
const useBaseStore = defineStore<'base', TStoreBaseState, {}, TUserAction>('base', {
state: () => ({
loading: null,
scroll: true,
fonts: [], // 缓存字体列表
app: null, // 抠图服务
}),
actions: {
/** 隐藏loading */
hideLoading() {
setTimeout(() => {
this.loading = false
}, 600)
},
setFonts(list: string[]) {
this.fonts = list
},
}
})
export default useBaseStore
// const all = {
// state: {
// loading: null,

View File

@ -8,8 +8,7 @@
import axios, { AxiosRequestConfig, AxiosResponse, AxiosStatic } from 'axios'
// import store from '@/store'
import app_config, { LocalStorageKey } from '@/config'
import useUserStore from '@/store/modules/base/user';
import useBaseStore from '@/store/modules/base';
import { useBaseStore, useUserStore } from '@/pinia/index';
axios.defaults.timeout = 30000
axios.defaults.headers.authorization = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MTAwMDEsImV4cCI6MTc4ODU3NDc1MDU4NX0.L_t6DFD48Dm6rUPfgIgOWJkz18En1m_-hhMHcpbxliY';

View File

@ -40,7 +40,7 @@ import _config from '@/config'
import useConfirm from '@/common/methods/confirm'
// import wGroup from '@/components/modules/widgets/wGroup/wGroup.vue'
import { useSetupMapGetters } from '@/common/hooks/mapGetters'
import useUserStore from '@/store/modules/base/user'
import { useUserStore } from '@/pinia/index'
type TProps = {
modelValue?: boolean