mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-12-25 22:30:19 +08:00
feat(projects): add pinia setup syntax example: setup-store[添加setup syntax的pinia示例setup-store]
This commit is contained in:
@@ -3,3 +3,4 @@ export * from './theme';
|
||||
export * from './auth';
|
||||
export * from './tab';
|
||||
export * from './route';
|
||||
export * from './setup-store';
|
||||
|
||||
26
src/store/modules/setup-store/index.ts
Normal file
26
src/store/modules/setup-store/index.ts
Normal 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
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user