refactor: state类型声明移动至types目录下
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import {AppState} from "@/store/interface";
|
||||
import {localStorage} from "@/utils/storage";
|
||||
import {defineStore} from "pinia";
|
||||
import { AppState } from "@/types";
|
||||
import { localStorage } from "@/utils/storage";
|
||||
import { defineStore } from "pinia";
|
||||
import { getLanguage } from '@/lang/index'
|
||||
|
||||
const useAppStore = defineStore({
|
||||
const useAppStore = defineStore({
|
||||
id: "app",
|
||||
state: (): AppState => ({
|
||||
device: 'desktop',
|
||||
@@ -12,7 +12,7 @@ import { getLanguage } from '@/lang/index'
|
||||
withoutAnimation: false
|
||||
},
|
||||
language: getLanguage(),
|
||||
size: localStorage.get('size')||'default'
|
||||
size: localStorage.get('size') || 'default'
|
||||
}),
|
||||
actions: {
|
||||
toggleSidebar() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {PermissionState} from "@/store/interface";
|
||||
import {PermissionState} from "@/types";
|
||||
import {RouteRecordRaw} from 'vue-router'
|
||||
import {constantRoutes} from '@/router'
|
||||
import {listRoutes} from "@/api/system/menu";
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import {defineStore} from "pinia";
|
||||
import {SettingState} from "@/store/interface";
|
||||
import { defineStore } from "pinia";
|
||||
import { SettingState } from "@/types";
|
||||
import defaultSettings from '../../settings'
|
||||
import {localStorage} from "@/utils/storage";
|
||||
import { localStorage } from "@/utils/storage";
|
||||
|
||||
const {showSettings, tagsView, fixedHeader, sidebarLogo} = defaultSettings
|
||||
const { showSettings, tagsView, fixedHeader, sidebarLogo } = defaultSettings
|
||||
import variables from '@/styles/element-variables.module.scss'
|
||||
|
||||
export const useSettingStore = defineStore({
|
||||
id: "setting",
|
||||
state: (): SettingState => ({
|
||||
theme: localStorage.get("theme") || variables.theme ,
|
||||
theme: localStorage.get("theme") || variables.theme,
|
||||
showSettings: showSettings,
|
||||
tagsView: localStorage.get("tagsView") != null ? localStorage.get("tagsView") : tagsView,
|
||||
fixedHeader: fixedHeader,
|
||||
@@ -17,7 +17,7 @@ export const useSettingStore = defineStore({
|
||||
}),
|
||||
actions: {
|
||||
async changeSetting(payload: { key: string, value: any }) {
|
||||
const {key, value} = payload
|
||||
const { key, value } = payload
|
||||
switch (key) {
|
||||
case 'theme':
|
||||
this.theme = value
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { TagsViewState } from "@/store/interface";
|
||||
import { TagsViewState } from "@/types";
|
||||
|
||||
const useTagsViewStore = defineStore({
|
||||
id: "tagsView",
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { UserState } from "@/store/interface";
|
||||
import { LoginFormData, UserState } from "@/types";
|
||||
import { localStorage } from "@/utils/storage";
|
||||
import { login, logout } from "@/api/login";
|
||||
import { resetRouter } from "@/router";
|
||||
import { login, logout } from "@/api/login";
|
||||
import { getUserInfo } from "@/api/system/user";
|
||||
|
||||
const useUserStore = defineStore({
|
||||
@@ -26,7 +26,7 @@ const useUserStore = defineStore({
|
||||
* code: 验证码
|
||||
* uuid: 匹配正确验证码的 key
|
||||
*/
|
||||
login(userInfo: { username: string, password: string, code: string, uuid: string }) {
|
||||
login(userInfo: LoginFormData) {
|
||||
const { username, password, code, uuid } = userInfo
|
||||
return new Promise((resolve, reject) => {
|
||||
login(
|
||||
|
||||
Reference in New Issue
Block a user