From a21700ee021a3c5c62186784776f3343aff109e2 Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Sun, 25 Apr 2021 13:55:01 +0800 Subject: [PATCH] style: fix some style --- src/layout/components/Navbar.vue | 24 +++++++- src/layout/components/panel/index.vue | 78 ++++++++++++++++--------- src/layout/components/setting/index.vue | 19 +++++- src/plugins/i18n/config.ts | 2 + src/style/sidebar.scss | 1 + src/utils/storage/index.ts | 30 +++++----- 6 files changed, 110 insertions(+), 44 deletions(-) diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 4811edc4c..68af60f2c 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -12,9 +12,10 @@ -
+
+ @@ -47,6 +48,8 @@ import { useI18n } from "vue-i18n"; import ch from "/@/assets/ch.png"; import en from "/@/assets/en.png"; import favicon from "/favicon.ico"; +import { emitter } from "/@/utils/mitt"; + export default defineComponent({ name: "Navbar", components: { @@ -76,6 +79,10 @@ export default defineComponent({ router.push("/login"); }; + function onPanel() { + emitter.emit("openPanel"); + } + onMounted(() => { document .querySelector(".el-dropdown__popper") @@ -97,7 +104,8 @@ export default defineComponent({ logout, ch, en, - favicon + favicon, + onPanel }; } }); @@ -147,6 +155,18 @@ export default defineComponent({ width: 25px; } } + .hsset { + width: 40px; + height: 48px; + display: flex; + align-items: center; + justify-content: space-around; + margin-right: 5px; + &:hover { + cursor: pointer; + background: #f0f0f0; + } + } .el-dropdown-link { width: 80px; height: 48px; diff --git a/src/layout/components/panel/index.vue b/src/layout/components/panel/index.vue index 9da42346e..78f763380 100644 --- a/src/layout/components/panel/index.vue +++ b/src/layout/components/panel/index.vue @@ -1,15 +1,13 @@ @@ -24,11 +32,14 @@ import { onMounted, reactive, toRefs } from "vue"; import { storageLocal } from "/@/utils/storage"; import { toggleClass } from "/@/utils/operate"; import { emitter } from "/@/utils/mitt"; +import { useRouter } from "vue-router"; export default { name: "setting", components: { panel }, setup() { + const router = useRouter(); + function toggleClass(flag: boolean, clsName: string, target?: HTMLElement) { const targetEl = target || document.body; let { className } = targetEl; @@ -88,12 +99,18 @@ export default { emitter.emit("tagViewsChange", showVal); }; + function onReset() { + storageLocal.clear(); + router.push("/login"); + } + return { ...toRefs(settings), localOperate, greyChange, weekChange, - tagsChange + tagsChange, + onReset }; } }; diff --git a/src/plugins/i18n/config.ts b/src/plugins/i18n/config.ts index 6796f341a..4103ebec1 100644 --- a/src/plugins/i18n/config.ts +++ b/src/plugins/i18n/config.ts @@ -68,6 +68,7 @@ export const buttonConfig = { hssearch: "搜索", hsexpendAll: "全部展开", hscollapseAll: "全部折叠", + hssystemSet: "系统设置", }, }, en: { @@ -84,6 +85,7 @@ export const buttonConfig = { hssearch: "Search", hsexpendAll: "Expand All", hscollapseAll: "Collapse All", + hssystemSet: "System Set", }, }, }; diff --git a/src/style/sidebar.scss b/src/style/sidebar.scss index 22ef3793f..94f06683d 100644 --- a/src/style/sidebar.scss +++ b/src/style/sidebar.scss @@ -70,6 +70,7 @@ .is-active > .el-submenu__title, .is-active > .el-submenu__title i { + transition: color 0.3s; color: $subMenuActiveText !important; } diff --git a/src/utils/storage/index.ts b/src/utils/storage/index.ts index f34f9af44..12a5df502 100644 --- a/src/utils/storage/index.ts +++ b/src/utils/storage/index.ts @@ -1,42 +1,46 @@ interface ProxyStorage { - getItem(key: string): any - setItem(Key: string, value: string): void - removeItem(key: string): void + getItem(key: string): any; + setItem(Key: string, value: string): void; + removeItem(key: string): void; + clear(): void; } //sessionStorage operate class sessionStorageProxy implements ProxyStorage { - - protected storage: ProxyStorage + protected storage: ProxyStorage; constructor(storageModel: ProxyStorage) { - this.storage = storageModel + this.storage = storageModel; } - // 存 + // 存 public setItem(key: string, value: any): void { - this.storage.setItem(key, JSON.stringify(value)) + this.storage.setItem(key, JSON.stringify(value)); } // 取 public getItem(key: string): any { - return JSON.parse(this.storage.getItem(key)) || null + return JSON.parse(this.storage.getItem(key)) || null; } // 删 public removeItem(key: string): void { - this.storage.removeItem(key) + this.storage.removeItem(key); } + // 清空 + public clear(): void { + this.storage.clear(); + } } //localStorage operate class localStorageProxy extends sessionStorageProxy implements ProxyStorage { constructor(localStorage: ProxyStorage) { - super(localStorage) + super(localStorage); } } -export const storageSession = new sessionStorageProxy(sessionStorage) +export const storageSession = new sessionStorageProxy(sessionStorage); -export const storageLocal = new localStorageProxy(localStorage) \ No newline at end of file +export const storageLocal = new localStorageProxy(localStorage);