perf: add tagsViewIcon setting

This commit is contained in:
陈凯龙 2022-04-14 10:37:13 +08:00
parent 9b614fe892
commit d395f03a57
8 changed files with 47 additions and 6 deletions

View File

@ -128,6 +128,8 @@ const copyConfig = async () => {
locale: ${appStore.getLocale}, locale: ${appStore.getLocale},
// //
tagsView: ${appStore.getTagsView}, tagsView: ${appStore.getTagsView},
//
getTagsViewIcon: ${appStore.getTagsViewIcon},
// logo // logo
logo: ${appStore.getLogo}, logo: ${appStore.getLogo},
// //

View File

@ -65,6 +65,13 @@ const tagsViewChange = (show: boolean) => {
appStore.setTagsView(show) appStore.setTagsView(show)
} }
//
const tagsViewIcon = ref(appStore.getTagsViewIcon)
const tagsViewIconChange = (show: boolean) => {
appStore.setTagsViewIcon(show)
}
// logo // logo
const logo = ref(appStore.getLogo) const logo = ref(appStore.getLogo)
@ -149,6 +156,11 @@ watch(
<ElSwitch v-model="tagsView" @change="tagsViewChange" /> <ElSwitch v-model="tagsView" @change="tagsViewChange" />
</div> </div>
<div class="flex justify-between items-center">
<span class="text-14px">{{ t('setting.tagsViewIcon') }}</span>
<ElSwitch v-model="tagsViewIcon" @change="tagsViewIconChange" />
</div>
<div class="flex justify-between items-center"> <div class="flex justify-between items-center">
<span class="text-14px">{{ t('setting.logo') }}</span> <span class="text-14px">{{ t('setting.logo') }}</span>
<ElSwitch v-model="logo" @change="logoChange" /> <ElSwitch v-model="logo" @change="logoChange" />

View File

@ -4,6 +4,7 @@ import { useRouter } from 'vue-router'
import type { RouteLocationNormalizedLoaded, RouterLinkProps } from 'vue-router' import type { RouteLocationNormalizedLoaded, RouterLinkProps } from 'vue-router'
import { usePermissionStore } from '@/store/modules/permission' import { usePermissionStore } from '@/store/modules/permission'
import { useTagsViewStore } from '@/store/modules/tagsView' import { useTagsViewStore } from '@/store/modules/tagsView'
import { useAppStore } from '@/store/modules/app'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import { filterAffixTags } from './helper' import { filterAffixTags } from './helper'
import { ContextMenu, ContextMenuExpose } from '@/components/ContextMenu' import { ContextMenu, ContextMenuExpose } from '@/components/ContextMenu'
@ -30,6 +31,10 @@ const visitedViews = computed(() => tagsViewStore.getVisitedViews)
const affixTagArr = ref<RouteLocationNormalizedLoaded[]>([]) const affixTagArr = ref<RouteLocationNormalizedLoaded[]>([])
const appStore = useAppStore()
const tagsViewIcon = computed(() => appStore.getTagsViewIcon)
// tag // tag
const initTags = () => { const initTags = () => {
affixTagArr.value = filterAffixTags(unref(routers)) affixTagArr.value = filterAffixTags(unref(routers))
@ -341,6 +346,17 @@ watch(
@click="navigate" @click="navigate"
class="h-full flex justify-center items-center whitespace-nowrap pl-15px" class="h-full flex justify-center items-center whitespace-nowrap pl-15px"
> >
<Icon
v-if="
item?.matched &&
item?.matched[1] &&
item?.matched[1]?.meta?.icon &&
tagsViewIcon
"
:icon="item?.matched[1]?.meta?.icon"
:size="12"
class="mr-5px"
/>
{{ t(item?.meta?.title as string) }} {{ t(item?.meta?.title as string) }}
<Icon <Icon
:class="`${prefixCls}__item--close`" :class="`${prefixCls}__item--close`"
@ -434,6 +450,7 @@ watch(
@prefix-cls: ~'@{namespace}-tags-view'; @prefix-cls: ~'@{namespace}-tags-view';
.@{prefix-cls} { .@{prefix-cls} {
background-color: #fff;
:deep(.@{elNamespace}-scrollbar__view) { :deep(.@{elNamespace}-scrollbar__view) {
height: 100%; height: 100%;
} }

View File

@ -30,6 +30,7 @@ export interface AppState {
size: boolean size: boolean
locale: boolean locale: boolean
tagsView: boolean tagsView: boolean
tagsViewIcon: boolean
logo: boolean logo: boolean
fixedHeader: boolean fixedHeader: boolean
greyMode: boolean greyMode: boolean
@ -61,6 +62,7 @@ export const appModules: AppState = {
size: true, // 尺寸图标 size: true, // 尺寸图标
locale: true, // 多语言图标 locale: true, // 多语言图标
tagsView: true, // 标签页 tagsView: true, // 标签页
tagsViewIcon: true, // 是否显示标签图标
logo: true, // logo logo: true, // logo
fixedHeader: true, // 固定toolheader fixedHeader: true, // 固定toolheader
footer: true, // 显示页脚 footer: true, // 显示页脚

View File

@ -92,7 +92,7 @@ export const useRenderLayout = () => {
<ToolHeader class="border-bottom-1 border-solid border-[var(--top-tool-border-color)] bg-[var(--top-header-bg-color)]"></ToolHeader> <ToolHeader class="border-bottom-1 border-solid border-[var(--top-tool-border-color)] bg-[var(--top-header-bg-color)]"></ToolHeader>
{tagsView.value ? ( {tagsView.value ? (
<TagsView class="border-bottom-1 border-solid border-[var(--tags-view-border-color)]"></TagsView> <TagsView class="border-bottom-1 border-top-1 border-solid border-[var(--tags-view-border-color)]"></TagsView>
) : undefined} ) : undefined}
</div> </div>
@ -139,7 +139,7 @@ export const useRenderLayout = () => {
{tagsView.value ? ( {tagsView.value ? (
<TagsView <TagsView
class={[ class={[
'border-bottom-1 border-solid border-[var(--tags-view-border-color)]', 'border-bottom-1 border-top-1 border-solid border-[var(--tags-view-border-color)]',
{ {
'!fixed top-0 left-0 z-10': fixedHeader.value, '!fixed top-0 left-0 z-10': fixedHeader.value,
'w-[calc(100%-var(--left-menu-min-width))] left-[var(--left-menu-min-width)] mt-[var(--logo-height)]': 'w-[calc(100%-var(--left-menu-min-width))] left-[var(--left-menu-min-width)] mt-[var(--logo-height)]':
@ -181,7 +181,7 @@ export const useRenderLayout = () => {
{tagsView.value ? ( {tagsView.value ? (
<TagsView <TagsView
class={[ class={[
'border-bottom-1 border-solid border-[var(--tags-view-border-color)]', 'border-bottom-1 border-top-1 border-solid border-[var(--tags-view-border-color)]',
{ {
'!fixed w-full top-[var(--top-tool-height)] left-0': fixedHeader.value '!fixed w-full top-[var(--top-tool-height)] left-0': fixedHeader.value
} }
@ -233,7 +233,7 @@ export const useRenderLayout = () => {
{tagsView.value ? ( {tagsView.value ? (
<TagsView <TagsView
class={[ class={[
'border-bottom-1 border-solid border-[var(--tags-view-border-color)]', 'border-bottom-1 border-top-1 border-solid border-[var(--tags-view-border-color)]',
{ {
'!fixed top-0 left-0 z-10': fixedHeader.value, '!fixed top-0 left-0 z-10': fixedHeader.value,
'w-[calc(100%-var(--tab-menu-min-width))] left-[var(--tab-menu-min-width)] mt-[var(--logo-height)]': 'w-[calc(100%-var(--tab-menu-min-width))] left-[var(--tab-menu-min-width)] mt-[var(--logo-height)]':

View File

@ -73,7 +73,8 @@ export default {
copySuccess: 'Copy success', copySuccess: 'Copy success',
copyFailed: 'Copy failed', copyFailed: 'Copy failed',
footer: 'Footer', footer: 'Footer',
uniqueOpened: 'Unique opened' uniqueOpened: 'Unique opened',
tagsViewIcon: 'Tags view icon'
}, },
size: { size: {
default: 'Default', default: 'Default',

View File

@ -73,7 +73,8 @@ export default {
copySuccess: '拷贝成功', copySuccess: '拷贝成功',
copyFailed: '拷贝失败', copyFailed: '拷贝失败',
footer: '页脚', footer: '页脚',
uniqueOpened: '菜单手风琴' uniqueOpened: '菜单手风琴',
tagsViewIcon: '标签页图标'
}, },
size: { size: {
default: '默认', default: '默认',

View File

@ -42,6 +42,9 @@ export const useAppStore = defineStore({
getTagsView(): boolean { getTagsView(): boolean {
return this.tagsView return this.tagsView
}, },
getTagsViewIcon(): boolean {
return this.tagsViewIcon
},
getLogo(): boolean { getLogo(): boolean {
return this.logo return this.logo
}, },
@ -110,6 +113,9 @@ export const useAppStore = defineStore({
setTagsView(tagsView: boolean) { setTagsView(tagsView: boolean) {
this.tagsView = tagsView this.tagsView = tagsView
}, },
setTagsViewIcon(tagsViewIcon: boolean) {
this.tagsViewIcon = tagsViewIcon
},
setLogo(logo: boolean) { setLogo(logo: boolean) {
this.logo = logo this.logo = logo
}, },