refactor: state类型声明移动至types目录下
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
import { Directive, DirectiveBinding } from "vue";
|
import { Directive, DirectiveBinding } from "vue";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按钮权限校验
|
* 按钮权限校验
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import {
|
|||||||
onBeforeUnmount,
|
onBeforeUnmount,
|
||||||
getCurrentInstance,
|
getCurrentInstance,
|
||||||
} from "vue";
|
} from "vue";
|
||||||
import { TagView } from "@/store/interface";
|
import { TagView } from "@/types";
|
||||||
import useStore from "@/store";
|
import useStore from "@/store";
|
||||||
|
|
||||||
const emits = defineEmits();
|
const emits = defineEmits();
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ ComponentInternalInstance,
|
|||||||
import path from "path-browserify";
|
import path from "path-browserify";
|
||||||
|
|
||||||
import { RouteRecordRaw, useRoute, useRouter } from "vue-router";
|
import { RouteRecordRaw, useRoute, useRouter } from "vue-router";
|
||||||
import { TagView } from "@/store/interface";
|
import { TagView } from "@/types";
|
||||||
|
|
||||||
import ScrollPane from "./ScrollPane.vue";
|
import ScrollPane from "./ScrollPane.vue";
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// 导入首页模块
|
|
||||||
import useUserStore from './modules/user'
|
import useUserStore from './modules/user'
|
||||||
import useAppStore from './modules/app'
|
import useAppStore from './modules/app'
|
||||||
import usePermissionStore from './modules/permission'
|
import usePermissionStore from './modules/permission'
|
||||||
@@ -11,7 +10,6 @@ const useStore = () => ({
|
|||||||
permission: usePermissionStore(),
|
permission: usePermissionStore(),
|
||||||
setting: useSettingStore(),
|
setting: useSettingStore(),
|
||||||
tagsView: useTagsViewStore()
|
tagsView: useTagsViewStore()
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export default useStore
|
export default useStore
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
import {RouteRecordRaw,RouteLocationNormalized} from "vue-router";
|
|
||||||
|
|
||||||
// 接口类型声明
|
|
||||||
export interface UserState {
|
|
||||||
token: string,
|
|
||||||
nickname: string,
|
|
||||||
avatar: string,
|
|
||||||
roles: string[],
|
|
||||||
perms: string[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AppState {
|
|
||||||
device: string,
|
|
||||||
sidebar: {
|
|
||||||
opened: boolean,
|
|
||||||
withoutAnimation: boolean
|
|
||||||
},
|
|
||||||
language:string,
|
|
||||||
size:string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SettingState {
|
|
||||||
theme: string,
|
|
||||||
tagsView: boolean,
|
|
||||||
fixedHeader: boolean,
|
|
||||||
showSettings: boolean,
|
|
||||||
sidebarLogo: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface PermissionState{
|
|
||||||
routes:RouteRecordRaw[]
|
|
||||||
addRoutes: RouteRecordRaw[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TagView extends Partial<RouteLocationNormalized> {
|
|
||||||
title?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TagsViewState{
|
|
||||||
visitedViews: TagView[],
|
|
||||||
cachedViews: (string)[]
|
|
||||||
}
|
|
||||||
|
|
||||||
// 顶级类型声明
|
|
||||||
export interface RootStateTypes {
|
|
||||||
user: UserState,
|
|
||||||
app: AppState,
|
|
||||||
settings: SettingState,
|
|
||||||
permission:PermissionState,
|
|
||||||
tagsView:TagsViewState
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import {AppState} from "@/store/interface";
|
import { AppState } from "@/types";
|
||||||
import { localStorage } from "@/utils/storage";
|
import { localStorage } from "@/utils/storage";
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { getLanguage } from '@/lang/index'
|
import { getLanguage } from '@/lang/index'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {PermissionState} from "@/store/interface";
|
import {PermissionState} from "@/types";
|
||||||
import {RouteRecordRaw} from 'vue-router'
|
import {RouteRecordRaw} from 'vue-router'
|
||||||
import {constantRoutes} from '@/router'
|
import {constantRoutes} from '@/router'
|
||||||
import {listRoutes} from "@/api/system/menu";
|
import {listRoutes} from "@/api/system/menu";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import {SettingState} from "@/store/interface";
|
import { SettingState } from "@/types";
|
||||||
import defaultSettings from '../../settings'
|
import defaultSettings from '../../settings'
|
||||||
import { localStorage } from "@/utils/storage";
|
import { localStorage } from "@/utils/storage";
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { TagsViewState } from "@/store/interface";
|
import { TagsViewState } from "@/types";
|
||||||
|
|
||||||
const useTagsViewStore = defineStore({
|
const useTagsViewStore = defineStore({
|
||||||
id: "tagsView",
|
id: "tagsView",
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { UserState } from "@/store/interface";
|
import { LoginFormData, UserState } from "@/types";
|
||||||
import { localStorage } from "@/utils/storage";
|
import { localStorage } from "@/utils/storage";
|
||||||
import { login, logout } from "@/api/login";
|
|
||||||
import { resetRouter } from "@/router";
|
import { resetRouter } from "@/router";
|
||||||
|
import { login, logout } from "@/api/login";
|
||||||
import { getUserInfo } from "@/api/system/user";
|
import { getUserInfo } from "@/api/system/user";
|
||||||
|
|
||||||
const useUserStore = defineStore({
|
const useUserStore = defineStore({
|
||||||
@@ -26,7 +26,7 @@ const useUserStore = defineStore({
|
|||||||
* code: 验证码
|
* code: 验证码
|
||||||
* uuid: 匹配正确验证码的 key
|
* uuid: 匹配正确验证码的 key
|
||||||
*/
|
*/
|
||||||
login(userInfo: { username: string, password: string, code: string, uuid: string }) {
|
login(userInfo: LoginFormData) {
|
||||||
const { username, password, code, uuid } = userInfo
|
const { username, password, code, uuid } = userInfo
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
login(
|
login(
|
||||||
|
|||||||
2
src/types/api/system/login.d.ts
vendored
2
src/types/api/system/login.d.ts
vendored
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* 登录请求参数类型声明
|
* 登录表单类型声明
|
||||||
*/
|
*/
|
||||||
export interface LoginFormData {
|
export interface LoginFormData {
|
||||||
username: string,
|
username: string,
|
||||||
|
|||||||
1
src/types/api/system/user.d.ts
vendored
1
src/types/api/system/user.d.ts
vendored
@@ -19,7 +19,6 @@ export interface UserQueryParam extends PageQueryParam {
|
|||||||
deptId: number | undefined
|
deptId: number | undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户分页列表项声明
|
* 用户分页列表项声明
|
||||||
*/
|
*/
|
||||||
|
|||||||
1
src/types/api/ums/index.d.ts
vendored
1
src/types/api/ums/index.d.ts
vendored
@@ -1 +0,0 @@
|
|||||||
export * from './member'
|
|
||||||
9
src/types/index.d.ts
vendored
9
src/types/index.d.ts
vendored
@@ -11,12 +11,15 @@ export * from './api/system/client'
|
|||||||
|
|
||||||
export * from './api/pms/goods'
|
export * from './api/pms/goods'
|
||||||
export * from './api/pms/brand'
|
export * from './api/pms/brand'
|
||||||
|
|
||||||
export * from './api/sms/advert'
|
export * from './api/sms/advert'
|
||||||
|
|
||||||
export * from './api/oms/order'
|
export * from './api/oms/order'
|
||||||
|
|
||||||
export * from './api/ums/member'
|
export * from './api/ums/member'
|
||||||
|
|
||||||
|
export * from './store/user'
|
||||||
|
export * from './store/app'
|
||||||
|
export * from './store/permission'
|
||||||
|
export * from './store/setting'
|
||||||
|
export * from './store/tagsView'
|
||||||
|
|
||||||
export * from './common'
|
export * from './common'
|
||||||
|
|
||||||
|
|||||||
12
src/types/store/app.d.ts
vendored
Normal file
12
src/types/store/app.d.ts
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* 用户状态类型声明
|
||||||
|
*/
|
||||||
|
export interface AppState {
|
||||||
|
device: string,
|
||||||
|
sidebar: {
|
||||||
|
opened: boolean,
|
||||||
|
withoutAnimation: boolean
|
||||||
|
},
|
||||||
|
language:string,
|
||||||
|
size:string
|
||||||
|
}
|
||||||
9
src/types/store/permission.d.ts
vendored
Normal file
9
src/types/store/permission.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import {RouteRecordRaw} from "vue-router";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限类型声明
|
||||||
|
*/
|
||||||
|
export interface PermissionState{
|
||||||
|
routes:RouteRecordRaw[]
|
||||||
|
addRoutes: RouteRecordRaw[]
|
||||||
|
}
|
||||||
10
src/types/store/setting.d.ts
vendored
Normal file
10
src/types/store/setting.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* 设置状态类型声明
|
||||||
|
*/
|
||||||
|
export interface SettingState {
|
||||||
|
theme: string,
|
||||||
|
tagsView: boolean,
|
||||||
|
fixedHeader: boolean,
|
||||||
|
showSettings: boolean,
|
||||||
|
sidebarLogo: boolean
|
||||||
|
}
|
||||||
12
src/types/store/tagsView.d.ts
vendored
Normal file
12
src/types/store/tagsView.d.ts
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import {RouteLocationNormalized} from "vue-router";
|
||||||
|
/**
|
||||||
|
* 用户状态类型声明
|
||||||
|
*/
|
||||||
|
export interface TagView extends Partial<RouteLocationNormalized> {
|
||||||
|
title?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TagsViewState{
|
||||||
|
visitedViews: TagView[],
|
||||||
|
cachedViews: (string)[]
|
||||||
|
}
|
||||||
10
src/types/store/user.d.ts
vendored
Normal file
10
src/types/store/user.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* 用户状态类型声明
|
||||||
|
*/
|
||||||
|
export interface UserState {
|
||||||
|
token: string,
|
||||||
|
nickname: string,
|
||||||
|
avatar: string,
|
||||||
|
roles: string[],
|
||||||
|
perms: string[]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user