feat: add pure-admin-thin

This commit is contained in:
xiaoxian521
2021-10-16 16:16:58 +08:00
parent 7067396ade
commit f4b5150b03
127 changed files with 11709 additions and 2 deletions

72
src/store/modules/app.ts Normal file
View File

@@ -0,0 +1,72 @@
import { storageLocal } from "/@/utils/storage";
import { deviceDetection } from "/@/utils/deviceDetection";
import { defineStore } from "pinia";
import { store } from "/@/store";
interface AppState {
sidebar: {
opened: boolean;
withoutAnimation: boolean;
};
layout: string;
device: string;
}
export const useAppStore = defineStore({
id: "pure-app",
state: (): AppState => ({
sidebar: {
opened: storageLocal.getItem("sidebarStatus")
? !!+storageLocal.getItem("sidebarStatus")
: true,
withoutAnimation: false
},
layout:
storageLocal.getItem("responsive-layout")?.layout.match(/(.*)-/)[1] ??
"vertical",
device: deviceDetection() ? "mobile" : "desktop"
}),
getters: {
getSidebarStatus() {
return this.sidebar.opened;
},
getDevice() {
return this.device;
}
},
actions: {
TOGGLE_SIDEBAR() {
this.sidebar.opened = !this.sidebar.opened;
this.sidebar.withoutAnimation = false;
if (this.sidebar.opened) {
storageLocal.setItem("sidebarStatus", 1);
} else {
storageLocal.setItem("sidebarStatus", 0);
}
},
CLOSE_SIDEBAR(withoutAnimation: boolean) {
storageLocal.setItem("sidebarStatus", 0);
this.sidebar.opened = false;
this.sidebar.withoutAnimation = withoutAnimation;
},
TOGGLE_DEVICE(device: string) {
this.device = device;
},
async toggleSideBar() {
await this.TOGGLE_SIDEBAR();
},
closeSideBar(withoutAnimation) {
this.CLOSE_SIDEBAR(withoutAnimation);
},
toggleDevice(device) {
this.TOGGLE_DEVICE(device);
},
setLayout(layout) {
this.layout = layout;
}
}
});
export function useAppStoreHook() {
return useAppStore(store);
}