mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-09 13:53:38 +08:00
perf: tags
This commit is contained in:
@@ -1,23 +1,13 @@
|
||||
import { storageLocal } from "/@/utils/storage";
|
||||
import { deviceDetection } from "/@/utils/deviceDetection";
|
||||
import { defineStore } from "pinia";
|
||||
import { store } from "/@/store";
|
||||
import { appType } from "./types";
|
||||
import { defineStore } from "pinia";
|
||||
import { getConfig } from "/@/config";
|
||||
|
||||
interface AppState {
|
||||
sidebar: {
|
||||
opened: boolean;
|
||||
withoutAnimation: boolean;
|
||||
// 判断是否手动点击Hamburger
|
||||
isClickHamburger: boolean;
|
||||
};
|
||||
layout: string;
|
||||
device: string;
|
||||
}
|
||||
|
||||
export const useAppStore = defineStore({
|
||||
id: "pure-app",
|
||||
state: (): AppState => ({
|
||||
state: (): appType => ({
|
||||
sidebar: {
|
||||
opened: storageLocal.getItem("sidebarStatus")
|
||||
? !!+storageLocal.getItem("sidebarStatus")
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { store } from "/@/store";
|
||||
import { getConfig } from "/@/config";
|
||||
import { positionType } from "./types";
|
||||
import { storageLocal } from "/@/utils/storage";
|
||||
|
||||
interface Itag {
|
||||
path: string;
|
||||
parentPath: string;
|
||||
name: string;
|
||||
meta: any;
|
||||
}
|
||||
import { multiType, positionType } from "./types";
|
||||
|
||||
export const useMultiTagsStore = defineStore({
|
||||
id: "pure-multiTags",
|
||||
@@ -43,16 +36,16 @@ export const useMultiTagsStore = defineStore({
|
||||
},
|
||||
handleTags<T>(
|
||||
mode: string,
|
||||
value?: T | Itag,
|
||||
value?: T | multiType,
|
||||
position?: positionType
|
||||
): any {
|
||||
): T {
|
||||
switch (mode) {
|
||||
case "equal":
|
||||
this.multiTags = value;
|
||||
break;
|
||||
case "push":
|
||||
{
|
||||
const tagVal = value as Itag;
|
||||
const tagVal = value as multiType;
|
||||
// 判断tag是否已存在:
|
||||
const tagHasExits = this.multiTags.some(tag => {
|
||||
return tag.path === tagVal?.path;
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { store } from "/@/store";
|
||||
import { setType } from "./types";
|
||||
import { getConfig } from "/@/config";
|
||||
|
||||
interface SettingState {
|
||||
title: string;
|
||||
fixedHeader: boolean;
|
||||
hiddenSideBar: boolean;
|
||||
}
|
||||
|
||||
export const useSettingStore = defineStore({
|
||||
id: "pure-setting",
|
||||
state: (): SettingState => ({
|
||||
state: (): setType => ({
|
||||
title: getConfig().Title,
|
||||
fixedHeader: getConfig().FixedHeader,
|
||||
hiddenSideBar: getConfig().HiddenSideBar
|
||||
|
||||
@@ -9,3 +9,27 @@ export type positionType = {
|
||||
startIndex?: number;
|
||||
length?: number;
|
||||
};
|
||||
|
||||
export type appType = {
|
||||
sidebar: {
|
||||
opened: boolean;
|
||||
withoutAnimation: boolean;
|
||||
// 判断是否手动点击Hamburger
|
||||
isClickHamburger: boolean;
|
||||
};
|
||||
layout: string;
|
||||
device: string;
|
||||
};
|
||||
|
||||
export type multiType = {
|
||||
path: string;
|
||||
parentPath: string;
|
||||
name: string;
|
||||
meta: any;
|
||||
};
|
||||
|
||||
export type setType = {
|
||||
title: string;
|
||||
fixedHeader: boolean;
|
||||
hiddenSideBar: boolean;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user