Prechádzať zdrojové kódy

feat: app 新增 isMaxM 值 判断是否为 手机 屏幕

lanceJiang 10 mesiacov pred
rodič
commit
27a0cf7a95
2 zmenil súbory, kde vykonal 8 pridanie a 1 odobranie
  1. 5 0
      src/store/modules/app.ts
  2. 3 1
      src/types/store.d.ts

+ 5 - 0
src/store/modules/app.ts

@@ -2,11 +2,13 @@ import { AppState } from '@/types'
 // import { ls } from '@/utils'
 import { defineStore } from 'pinia'
 import { getLanguage } from '@/lang'
+import { isMaxM } from '@/utils'
 
 const useAppStore = defineStore({
 	id: 'app',
 	state: (): AppState => ({
 		device: 'desktop',
+		isMaxM: false,
 		// sidebar: {
 		// 	opened: true,
 		// 	withoutAnimation: false
@@ -16,6 +18,9 @@ const useAppStore = defineStore({
 		// size: 'small'
 	}),
 	actions: {
+		updateDevice() {
+			this.isMaxM = isMaxM()
+		},
 		// toggleSidebar() {
 		// 	this.sidebar.opened = !this.sidebar.opened
 		// 	this.sidebar.withoutAnimation = false

+ 3 - 1
src/types/store.d.ts

@@ -1,4 +1,5 @@
 import { /*RouteRecordRaw,*/ RouteLocationNormalized } from 'vue-router'
+import { isMaxM } from '@/utils'
 // import { AppRouteRecordRaw } from '@/router/types'
 
 /**
@@ -6,7 +7,8 @@ import { /*RouteRecordRaw,*/ RouteLocationNormalized } from 'vue-router'
  */
 export interface AppState {
 	device: string
-	sidebar: {
+	isMaxM: boolean
+	sidebar?: {
 		opened: boolean
 		withoutAnimation: boolean
 	}