refactor: 重构主题色配置,多标签配置化处理

This commit is contained in:
张传龙 2022-04-10 23:20:28 +08:00
parent 0d240f083a
commit b3aa8147b1
11 changed files with 44 additions and 40 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<n-config-provider :theme-overrides="appStore.themeOverrides"> <n-config-provider :theme-overrides="useTheme.naiveThemeOverrides">
<n-loading-bar-provider> <n-loading-bar-provider>
<LoadingBar /> <LoadingBar />
<n-dialog-provider> <n-dialog-provider>
@ -17,7 +17,7 @@
import MessageContent from './MessageContent.vue' import MessageContent from './MessageContent.vue'
import DialogContent from './DialogContent.vue' import DialogContent from './DialogContent.vue'
import LoadingBar from './LoadingBar.vue' import LoadingBar from './LoadingBar.vue'
import { useThemeStore } from '@/store/modules/theme'
import { useAppStore } from '@/store/modules/app' const useTheme = useThemeStore()
const appStore = useAppStore()
</script> </script>

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="tags-wrapper" :style="{ height: useTheme.tag.height + 'px' }"> <div class="tags-wrapper" :style="{ height: useTheme.tags.height + 'px' }">
<n-space> <n-space>
<n-tag <n-tag
v-for="tag in useTag.tags" v-for="tag in useTag.tags"
@ -59,7 +59,7 @@ const handleClose = (path) => {
.tags-wrapper { .tags-wrapper {
display: flex; display: flex;
align-items: center; align-items: center;
background-color: #f5f6fb; background-color: #fff;
padding: 0 10px; padding: 0 10px;
position: sticky; position: sticky;
top: 0; top: 0;

View File

@ -1,16 +1,21 @@
<template> <template>
<div class="layout"> <div class="layout">
<n-layout has-sider position="absolute"> <n-layout has-sider position="absolute">
<n-layout-sider :width="200" :collapsed-width="0" :native-scrollbar="false"> <n-layout-sider bordered :width="200" :collapsed-width="0" :native-scrollbar="false">
<SideBar /> <SideBar />
</n-layout-sider> </n-layout-sider>
<n-layout> <n-layout>
<n-layout-header> <n-layout-header :style="{ height: useTheme.header.height + 'px' }" style="border-left: none">
<AppHeader /> <AppHeader />
</n-layout-header> </n-layout-header>
<n-layout position="absolute" style="top: 60px; background-color: #f5f6fb" :native-scrollbar="false"> <n-layout
<AppTags v-if="useTheme.tag.visible" /> position="absolute"
style="background-color: #f5f6fb"
:style="{ top: useTheme.header.height + 'px' }"
:native-scrollbar="false"
>
<AppTags v-if="useTheme.tags.visible" />
<AppMain /> <AppMain />
</n-layout> </n-layout>
</n-layout> </n-layout>

1
src/settings/index.js Normal file
View File

@ -0,0 +1 @@
export { default as themeSettings } from './theme.json'

14
src/settings/theme.json Normal file
View File

@ -0,0 +1,14 @@
{
"tags": {
"visible": true,
"height": 50
},
"header": {
"height": 60
},
"naiveThemeOverrides": {
"common": {
"primaryColor": "#316c72"
}
}
}

View File

@ -1,17 +0,0 @@
import { defineStore } from 'pinia'
export const useAppStore = defineStore('app', {
state() {
return {
themeOverrides: {
common: {
primaryColor: '#316c72',
primaryColorSuppl: '#316c72',
primaryColorHover: '#316c72',
successColorHover: '#316c72',
successColorSuppl: '#316c72',
},
},
}
},
})

View File

@ -1,17 +1,13 @@
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { themeSettings } from '@/settings'
export const useThemeStore = defineStore('theme', { export const useThemeStore = defineStore('theme', {
state() { state() {
return { return themeSettings
tag: {
visible: true,
height: 50,
},
}
}, },
getters: {},
actions: { actions: {
setTabVisible(visible) { setTabVisible(visible) {
this.tag.visible = visible this.tags.visible = visible
}, },
}, },
}) })

View File

@ -2,7 +2,7 @@
<div class="page-404"> <div class="page-404">
<n-result status="404" description="抱歉,您访问的页面不存在。"> <n-result status="404" description="抱歉,您访问的页面不存在。">
<template #icon> <template #icon>
<img src="@/assets/images/404.png" width="500" /> <img src="@/assets/images/404.png" width="300" />
</template> </template>
<template #footer> <template #footer>
<n-button strong secondary type="primary" @click="replace('/')">返回首页</n-button> <n-button strong secondary type="primary" @click="replace('/')">返回首页</n-button>
@ -18,10 +18,14 @@ const { replace } = useRouter()
<style lang="scss" scoped> <style lang="scss" scoped>
.page-404 { .page-404 {
height: 100%;
min-height: calc(100vh - 60px);
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
position: absolute;
top: 50px;
bottom: 50px;
left: 0;
right: 0;
} }
</style> </style>

View File

@ -11,7 +11,6 @@
:columns="columns" :columns="columns"
:pagination="pagination" :pagination="pagination"
:row-key="(row) => row.id" :row-key="(row) => row.id"
max-height="calc(100vh - 250px)"
@update:checked-row-keys="handleCheck" @update:checked-row-keys="handleCheck"
/> />
</div> </div>

View File

@ -1,10 +1,10 @@
<template> <template>
<div> <div pb-20>
<div class="header"> <div class="header">
<input v-model="post.title" type="text" placeholder="输入文章标题..." class="title" /> <input v-model="post.title" type="text" placeholder="输入文章标题..." class="title" />
<n-button type="primary" style="width: 80px" :loading="btnLoading" @click="handleSavePost">保存</n-button> <n-button type="primary" style="width: 80px" :loading="btnLoading" @click="handleSavePost">保存</n-button>
</div> </div>
<MdEditor v-model="post.content" style="height: calc(100vh - 140px)" /> <MdEditor v-model="post.content" style="height: calc(100vh - 200px)" />
</div> </div>
</template> </template>

View File

@ -13,3 +13,5 @@
</div> </div>
</div> </div>
</template> </template>
<script setup></script>