ci: 集成 pinia 提供主题持久化

This commit is contained in:
就眠儀式 2022-04-06 00:24:20 +08:00
parent 0f7d25bc09
commit ae75cffa9b
5 changed files with 28 additions and 29 deletions

View File

@ -136,7 +136,9 @@
></lay-color-picker
>&nbsp;
<lay-color-picker
v-model="appStore.themeVariable['--global-dark-background-color']"
v-model="
appStore.themeVariable['--global-dark-background-color']
"
></lay-color-picker>
<lay-button fluid="true"> </lay-button>
@ -272,7 +274,7 @@ export default {
deep: true,
}
);
menu.forEach((m) => {
m.children.forEach((c) => {
menus.push(c);

View File

@ -3,7 +3,7 @@ import { App, createApp as _createApp } from "vue";
import { createRouter } from "./router/index";
import { Router } from "vue-router";
import layui from "@layui/layui-vue";
import Store from './store';
import Store from "./store";
import "@layui/layui-vue/lib/index.css";
import LayCode from "./components/LayCode.vue";
import LaySearch from "./components/LaySearch.vue";

View File

@ -1,10 +1,10 @@
import { defineStore } from 'pinia'
import { defineStore } from "pinia";
export const useAppStore = defineStore({
id: 'app',
id: "app",
state: () => {
return {
theme: 'light',
theme: "light",
themeVariable: {
"--global-primary-color": "#009688",
"--global-normal-color": "#1e9fff",
@ -21,24 +21,21 @@ export const useAppStore = defineStore({
"--global-neutral-color-7": "#cccccc",
"--global-neutral-color-8": "#c2c2c2",
},
}
},
getters: {
},
actions: {
};
},
getters: {},
actions: {},
persist: {
enabled: true,
strategies: [
{
key: 'theme',
storage: localStorage
},{
key: 'themeVariable',
storage: localStorage
}
]
}
})
enabled: true,
strategies: [
{
key: "theme",
storage: localStorage,
},
{
key: "themeVariable",
storage: localStorage,
},
],
},
});

View File

@ -1,7 +1,7 @@
import { createPinia } from 'pinia'
import piniaPluginPersist from 'pinia-plugin-persist'
import { createPinia } from "pinia";
import piniaPluginPersist from "pinia-plugin-persist";
const store = createPinia();
store.use(piniaPluginPersist);
export default store;
export default store;

View File

@ -119,7 +119,7 @@ export default {
setup() {
const { t } = useI18n();
const appStore = useAppStore();
const changeTheme = () => {
if (appStore.theme === "dark") {
appStore.theme = "light";