Skip to content

Commit

Permalink
perf: 简化store文件中导出和导入用法
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxian521 committed Apr 16, 2024
1 parent 5d3a9df commit 4cbf905
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 35 deletions.
14 changes: 9 additions & 5 deletions src/store/modules/app.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { store } from "@/store";
import { defineStore } from "pinia";
import type { appType } from "./types";
import { getConfig, responsiveStorageNameSpace } from "@/config";
import { deviceDetection, storageLocal } from "@pureadmin/utils";
import {
type appType,
store,
getConfig,
defineStore,
storageLocal,
deviceDetection,
responsiveStorageNameSpace
} from "../utils";

export const useAppStore = defineStore({
id: "pure-app",
Expand Down
11 changes: 7 additions & 4 deletions src/store/modules/epTheme.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { store } from "@/store";
import { defineStore } from "pinia";
import { storageLocal } from "@pureadmin/utils";
import { getConfig, responsiveStorageNameSpace } from "@/config";
import {
store,
getConfig,
defineStore,
storageLocal,
responsiveStorageNameSpace
} from "../utils";

export const useEpThemeStore = defineStore({
id: "pure-epTheme",
Expand Down
18 changes: 12 additions & 6 deletions src/store/modules/multiTags.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { defineStore } from "pinia";
import { store } from "@/store";
import { routerArrays } from "@/layout/types";
import {
type multiType,
type positionType,
store,
isUrl,
isEqual,
isBoolean,
defineStore,
routerArrays,
storageLocal,
responsiveStorageNameSpace
} from "../utils";
import { usePermissionStoreHook } from "./permission";
import { responsiveStorageNameSpace } from "@/config";
import type { multiType, positionType } from "./types";
import { isEqual, isBoolean, isUrl, storageLocal } from "@pureadmin/utils";

export const useMultiTagsStore = defineStore({
id: "pure-multiTags",
Expand Down
15 changes: 8 additions & 7 deletions src/store/modules/permission.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { defineStore } from "pinia";
import { store } from "@/store";
import type { cacheType } from "./types";
import { constantMenus } from "@/router";
import { useMultiTagsStoreHook } from "./multiTags";
import { debounce, getKeyList } from "@pureadmin/utils";
import {
type cacheType,
store,
debounce,
ascending,
getKeyList,
filterTree,
defineStore,
constantMenus,
filterNoPermissionTree,
formatFlatteningRoutes
} from "@/router/utils";
} from "../utils";
import { useMultiTagsStoreHook } from "./multiTags";

export const usePermissionStore = defineStore({
id: "pure-permission",
Expand Down
5 changes: 1 addition & 4 deletions src/store/modules/settings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { defineStore } from "pinia";
import { store } from "@/store";
import { getConfig } from "@/config";
import type { setType } from "./types";
import { type setType, store, defineStore, getConfig } from "../utils";

export const useSettingStore = defineStore({
id: "pure-setting",
Expand Down
25 changes: 16 additions & 9 deletions src/store/modules/user.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { defineStore } from "pinia";
import { store } from "@/store";
import type { userType } from "./types";
import { routerArrays } from "@/layout/types";
import { router, resetRouter } from "@/router";
import { storageLocal } from "@pureadmin/utils";
import { getLogin, refreshTokenApi } from "@/api/user";
import type { UserResult, RefreshTokenResult } from "@/api/user";
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
import {
type userType,
store,
router,
defineStore,
resetRouter,
routerArrays,
storageLocal
} from "../utils";
import {
type UserResult,
type RefreshTokenResult,
getLogin,
refreshTokenApi
} from "@/api/user";
import { useMultiTagsStoreHook } from "./multiTags";
import { type DataInfo, setToken, removeToken, userKey } from "@/utils/auth";

export const useUserStore = defineStore({
Expand Down
File renamed without changes.
28 changes: 28 additions & 0 deletions src/store/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export { store } from "@/store";
export { defineStore } from "pinia";
export { routerArrays } from "@/layout/types";
export { router, resetRouter, constantMenus } from "@/router";
export { getConfig, responsiveStorageNameSpace } from "@/config";
export {
ascending,
filterTree,
filterNoPermissionTree,
formatFlatteningRoutes
} from "@/router/utils";
export {
isUrl,
isEqual,
debounce,
isBoolean,
getKeyList,
storageLocal,
deviceDetection
} from "@pureadmin/utils";
export type {
setType,
appType,
userType,
multiType,
cacheType,
positionType
} from "./types";

2 comments on commit 4cbf905

@jack20211101
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error during build: RollupError: src/store/modules/permission.ts (8:2): "defineStore" is not exported by "src/store/utils.ts", imported by "src/store/modules/permission.ts".

请问这是什么原因

@xiaoxian521
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没法复现 删除你的node-modules

Please sign in to comment.