feat(projects): add pinia setup syntax example: setup-store[添加setup syntax的pinia示例setup-store]

This commit is contained in:
Soybean
2022-09-21 18:14:57 +08:00
parent a539112a0f
commit 82c4b09b94
4 changed files with 51 additions and 0 deletions

View File

@ -3,3 +3,4 @@ export * from './theme';
export * from './auth';
export * from './tab';
export * from './route';
export * from './setup-store';

View File

@ -0,0 +1,26 @@
import { reactive } from 'vue';
import { defineStore } from 'pinia';
import { useBoolean } from '@/hooks';
export const useSetupStore = defineStore('setup-store', () => {
const { bool: visible, setTrue: show, setFalse: hide } = useBoolean();
interface Config {
name: string;
}
const config = reactive<Config>({ name: 'config' });
/** 设置配置 */
function setConfig(conf: Partial<Config>) {
Object.assign(config, conf);
}
return {
visible,
show,
hide,
config,
setConfig
};
});