chore: version 2.7.3 (#120)
* fix: 用户输入也被渲染的问题 (#117) * fix: 用户输入不转换 * feat: 基础深色模式适配 * feat: 主题模式跟随系统 * feat: 深色适配补漏 * chore: version 2.7.3
This commit is contained in:
@@ -2,19 +2,22 @@ import { ss } from '@/utils/storage'
|
||||
|
||||
const LOCAL_NAME = 'appSetting'
|
||||
|
||||
export type Theme = 'light' | 'dark' | 'auto'
|
||||
|
||||
export interface AppState {
|
||||
siderCollapsed: boolean
|
||||
theme: Theme
|
||||
}
|
||||
|
||||
export function defaultSetting() {
|
||||
return { siderCollapsed: false }
|
||||
export function defaultSetting(): AppState {
|
||||
return { siderCollapsed: false, theme: 'light' }
|
||||
}
|
||||
|
||||
export function getLocalSetting() {
|
||||
export function getLocalSetting(): AppState {
|
||||
const localSetting: AppState | undefined = ss.get(LOCAL_NAME)
|
||||
return localSetting ?? defaultSetting()
|
||||
return { ...defaultSetting(), ...localSetting }
|
||||
}
|
||||
|
||||
export function setLocalSetting(setting: AppState) {
|
||||
export function setLocalSetting(setting: AppState): void {
|
||||
ss.set(LOCAL_NAME, setting)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import type { AppState } from './helper'
|
||||
import type { AppState, Theme } from './helper'
|
||||
import { getLocalSetting, setLocalSetting } from './helper'
|
||||
|
||||
export const useAppStore = defineStore('app-store', {
|
||||
@@ -7,6 +7,15 @@ export const useAppStore = defineStore('app-store', {
|
||||
actions: {
|
||||
setSiderCollapsed(collapsed: boolean) {
|
||||
this.siderCollapsed = collapsed
|
||||
this.recordState()
|
||||
},
|
||||
|
||||
setTheme(theme: Theme) {
|
||||
this.theme = theme
|
||||
this.recordState()
|
||||
},
|
||||
|
||||
recordState() {
|
||||
setLocalSetting(this.$state)
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user