refactor: 将全局配置文件 platform-config.json中的ShowModel重命名为TagsStyle,以更准确地反映其语义

This commit is contained in:
xiaoxian521
2025-12-08 19:42:41 +08:00
parent aeb4feb6f9
commit 966efb5088
9 changed files with 36 additions and 34 deletions

View File

@@ -18,7 +18,7 @@
"SidebarStatus": true, "SidebarStatus": true,
"EpThemeColor": "#409EFF", "EpThemeColor": "#409EFF",
"ShowLogo": true, "ShowLogo": true,
"ShowModel": "smart", "TagsStyle": "chrome",
"MenuArrowIconNoTransition": false, "MenuArrowIconNoTransition": false,
"CachingAsyncRoutes": false, "CachingAsyncRoutes": false,
"TooltipEffect": "light", "TooltipEffect": "light",

View File

@@ -13,7 +13,7 @@ const props = defineProps({
}); });
const { t } = useI18n(); const { t } = useI18n();
const { showModel } = useTags(); const { tagsStyle } = useTags();
const { $storage, $config } = useGlobal<GlobalPropertiesApi>(); const { $storage, $config } = useGlobal<GlobalPropertiesApi>();
const isKeepAlive = computed(() => { const isKeepAlive = computed(() => {
@@ -54,13 +54,13 @@ const getSectionStyle = computed(() => {
return [ return [
hideTabs.value && layout ? "padding-top: 48px;" : "", hideTabs.value && layout ? "padding-top: 48px;" : "",
!hideTabs.value && layout !hideTabs.value && layout
? showModel.value == "chrome" ? tagsStyle.value == "chrome"
? "padding-top: 85px;" ? "padding-top: 85px;"
: "padding-top: 81px;" : "padding-top: 81px;"
: "", : "",
hideTabs.value && !layout.value ? "padding-top: 48px;" : "", hideTabs.value && !layout.value ? "padding-top: 48px;" : "",
!hideTabs.value && !layout.value !hideTabs.value && !layout.value
? showModel.value == "chrome" ? tagsStyle.value == "chrome"
? "padding-top: 85px;" ? "padding-top: 85px;"
: "padding-top: 81px;" : "padding-top: 81px;"
: "", : "",

View File

@@ -53,8 +53,8 @@ if (unref(layoutTheme)) {
setMenuLayout(layout); setMenuLayout(layout);
} }
/** 默认灵动模式 */ /** 页签风格默认为谷歌风格 */
const markValue = ref($storage.configure?.showModel ?? "smart"); const tagsStyleValue = ref($storage.configure?.tagsStyle ?? "chrome");
const logoVal = ref($storage.configure?.showLogo ?? true); const logoVal = ref($storage.configure?.showLogo ?? true);
@@ -63,7 +63,7 @@ const settings = reactive({
weakVal: $storage.configure.weak, weakVal: $storage.configure.weak,
tabsVal: $storage.configure.hideTabs, tabsVal: $storage.configure.hideTabs,
showLogo: $storage.configure.showLogo, showLogo: $storage.configure.showLogo,
showModel: $storage.configure.showModel, tagsStyle: $storage.configure.tagsStyle,
hideFooter: $storage.configure.hideFooter, hideFooter: $storage.configure.hideFooter,
multiTagsCache: $storage.configure.multiTagsCache, multiTagsCache: $storage.configure.multiTagsCache,
stretch: $storage.configure.stretch stretch: $storage.configure.stretch
@@ -124,9 +124,9 @@ const multiTagsCacheChange = () => {
function onChange({ option }) { function onChange({ option }) {
const { value } = option; const { value } = option;
markValue.value = value; tagsStyleValue.value = value;
storageConfigureChange("showModel", value); storageConfigureChange("tagsStyle", value);
emitter.emit("tagViewsShowModel", value); emitter.emit("tagViewsTagsStyle", value);
} }
/** 侧边栏Logo */ /** 侧边栏Logo */
@@ -442,7 +442,9 @@ onUnmounted(() => removeMatchMedia);
<Segmented <Segmented
resize resize
class="select-none" class="select-none"
:modelValue="markValue === 'smart' ? 0 : markValue === 'card' ? 1 : 2" :modelValue="
tagsStyleValue === 'smart' ? 0 : tagsStyleValue === 'card' ? 1 : 2
"
:options="markOptions" :options="markOptions"
@change="onChange" @change="onChange"
/> />

View File

@@ -32,11 +32,11 @@ const {
visible, visible,
showTags, showTags,
instance, instance,
tagsStyle,
multiTags, multiTags,
tagsViews, tagsViews,
buttonTop, buttonTop,
buttonLeft, buttonLeft,
showModel,
translateX, translateX,
isFixedTag, isFixedTag,
pureSetting, pureSetting,
@@ -542,8 +542,8 @@ onMounted(() => {
}); });
// 改变标签风格 // 改变标签风格
emitter.on("tagViewsShowModel", key => { emitter.on("tagViewsTagsStyle", key => {
showModel.value = key; tagsStyle.value = key;
}); });
// 接收侧边栏切换传递过来的参数 // 接收侧边栏切换传递过来的参数
@@ -559,9 +559,9 @@ onMounted(() => {
}); });
onBeforeUnmount(() => { onBeforeUnmount(() => {
// 解绑`tagViewsChange`、`tagViewsShowModel`、`changLayoutRoute`公共事件,防止多次触发 // 解绑`tagViewsChange`、`tagViewsTagsStyle`、`changLayoutRoute`公共事件,防止多次触发
emitter.off("tagViewsChange"); emitter.off("tagViewsChange");
emitter.off("tagViewsShowModel"); emitter.off("tagViewsTagsStyle");
emitter.off("changLayoutRoute"); emitter.off("changLayoutRoute");
}); });
</script> </script>
@@ -574,7 +574,7 @@ onBeforeUnmount(() => {
<div <div
ref="scrollbarDom" ref="scrollbarDom"
class="scroll-container" class="scroll-container"
:class="showModel === 'chrome' && 'chrome-scroll-container'" :class="tagsStyle === 'chrome' && 'chrome-scroll-container'"
@wheel.prevent="handleWheel" @wheel.prevent="handleWheel"
> >
<div ref="tabDom" class="tab select-none" :style="getTabStyle"> <div ref="tabDom" class="tab select-none" :style="getTabStyle">
@@ -585,7 +585,7 @@ onBeforeUnmount(() => {
:class="[ :class="[
'scroll-item is-closable', 'scroll-item is-closable',
linkIsActive(item), linkIsActive(item),
showModel === 'chrome' && 'chrome-item', tagsStyle === 'chrome' && 'chrome-item',
isFixedTag(item) && 'fixed-tag' isFixedTag(item) && 'fixed-tag'
]" ]"
@contextmenu.prevent="openMenu(item, $event)" @contextmenu.prevent="openMenu(item, $event)"
@@ -593,7 +593,7 @@ onBeforeUnmount(() => {
@mouseleave.prevent="onMouseleave(index)" @mouseleave.prevent="onMouseleave(index)"
@click="tagOnClick(item)" @click="tagOnClick(item)"
> >
<template v-if="showModel !== 'chrome'"> <template v-if="tagsStyle !== 'chrome'">
<span <span
class="tag-title dark:text-text_color_primary! dark:hover:text-primary!" class="tag-title dark:text-text_color_primary! dark:hover:text-primary!"
> >
@@ -612,7 +612,7 @@ onBeforeUnmount(() => {
<IconifyIconOffline :icon="Close" /> <IconifyIconOffline :icon="Close" />
</span> </span>
<span <span
v-if="showModel !== 'card'" v-if="tagsStyle !== 'card'"
:ref="'schedule' + index" :ref="'schedule' + index"
:class="[scheduleIsActive(item)]" :class="[scheduleIsActive(item)]"
/> />

View File

@@ -40,7 +40,7 @@ export function useLayout() {
hideTabs: $config?.HideTabs ?? false, hideTabs: $config?.HideTabs ?? false,
hideFooter: $config.HideFooter ?? true, hideFooter: $config.HideFooter ?? true,
showLogo: $config?.ShowLogo ?? true, showLogo: $config?.ShowLogo ?? true,
showModel: $config?.ShowModel ?? "smart", tagsStyle: $config?.TagsStyle ?? "chrome",
multiTagsCache: $config?.MultiTagsCache ?? false, multiTagsCache: $config?.MultiTagsCache ?? false,
stretch: $config?.Stretch ?? false stretch: $config?.Stretch ?? false
}; };

View File

@@ -44,11 +44,11 @@ export function useTags() {
const currentSelect = ref({}); const currentSelect = ref({});
const isScrolling = ref(false); const isScrolling = ref(false);
/** 显示模式,默认灵动模式 */ /** 页签风格默认为谷歌风格 */
const showModel = ref( const tagsStyle = ref(
storageLocal().getItem<StorageConfigs>( storageLocal().getItem<StorageConfigs>(
`${responsiveStorageNameSpace()}configure` `${responsiveStorageNameSpace()}configure`
)?.showModel || "smart" )?.tagsStyle || "chrome"
); );
/** 是否隐藏标签页,默认显示 */ /** 是否隐藏标签页,默认显示 */
const showTags = const showTags =
@@ -175,7 +175,7 @@ export function useTags() {
/** 鼠标移入添加激活样式 */ /** 鼠标移入添加激活样式 */
function onMouseenter(index) { function onMouseenter(index) {
if (index) activeIndex.value = index; if (index) activeIndex.value = index;
if (unref(showModel) === "smart") { if (unref(tagsStyle) === "smart") {
if (hasClass(instance.refs["schedule" + index][0], "schedule-active")) if (hasClass(instance.refs["schedule" + index][0], "schedule-active"))
return; return;
toggleClass(true, "schedule-in", instance.refs["schedule" + index][0]); toggleClass(true, "schedule-in", instance.refs["schedule" + index][0]);
@@ -190,7 +190,7 @@ export function useTags() {
/** 鼠标移出恢复默认样式 */ /** 鼠标移出恢复默认样式 */
function onMouseleave(index) { function onMouseleave(index) {
activeIndex.value = -1; activeIndex.value = -1;
if (unref(showModel) === "smart") { if (unref(tagsStyle) === "smart") {
if (hasClass(instance.refs["schedule" + index][0], "schedule-active")) if (hasClass(instance.refs["schedule" + index][0], "schedule-active"))
return; return;
toggleClass(false, "schedule-in", instance.refs["schedule" + index][0]); toggleClass(false, "schedule-in", instance.refs["schedule" + index][0]);
@@ -209,11 +209,11 @@ export function useTags() {
} }
onMounted(() => { onMounted(() => {
if (!showModel.value) { if (!tagsStyle.value) {
const configure = storageLocal().getItem<StorageConfigs>( const configure = storageLocal().getItem<StorageConfigs>(
`${responsiveStorageNameSpace()}configure` `${responsiveStorageNameSpace()}configure`
); );
configure.showModel = "card"; configure.tagsStyle = "card";
storageLocal().setItem( storageLocal().setItem(
`${responsiveStorageNameSpace()}configure`, `${responsiveStorageNameSpace()}configure`,
configure configure
@@ -229,7 +229,7 @@ export function useTags() {
showTags, showTags,
instance, instance,
multiTags, multiTags,
showModel, tagsStyle,
tagsViews, tagsViews,
buttonTop, buttonTop,
buttonLeft, buttonLeft,

View File

@@ -8,7 +8,7 @@ type Events = {
logoChange: boolean; logoChange: boolean;
tagViewsChange: string; tagViewsChange: string;
changLayoutRoute: string; changLayoutRoute: string;
tagViewsShowModel: string; tagViewsTagsStyle: string;
imageInfo: { imageInfo: {
img: HTMLImageElement; img: HTMLImageElement;
height: number; height: number;

View File

@@ -29,7 +29,7 @@ export const injectResponsiveStorage = (app: App, config: PlatformConfigs) => {
hideTabs: config.HideTabs ?? false, hideTabs: config.HideTabs ?? false,
hideFooter: config.HideFooter ?? true, hideFooter: config.HideFooter ?? true,
showLogo: config.ShowLogo ?? true, showLogo: config.ShowLogo ?? true,
showModel: config.ShowModel ?? "smart", tagsStyle: config.TagsStyle ?? "chrome",
multiTagsCache: config.MultiTagsCache ?? false, multiTagsCache: config.MultiTagsCache ?? false,
stretch: config.Stretch ?? false stretch: config.Stretch ?? false
} }

6
types/global.d.ts vendored
View File

@@ -102,7 +102,7 @@ declare global {
SidebarStatus?: boolean; SidebarStatus?: boolean;
EpThemeColor?: string; EpThemeColor?: string;
ShowLogo?: boolean; ShowLogo?: boolean;
ShowModel?: string; TagsStyle?: string;
MenuArrowIconNoTransition?: boolean; MenuArrowIconNoTransition?: boolean;
CachingAsyncRoutes?: boolean; CachingAsyncRoutes?: boolean;
TooltipEffect?: Effect; TooltipEffect?: Effect;
@@ -142,7 +142,7 @@ declare global {
themeColor?: string; themeColor?: string;
themeMode?: string; themeMode?: string;
showLogo?: boolean; showLogo?: boolean;
showModel?: string; tagsStyle?: string;
menuSearchHistory?: number; menuSearchHistory?: number;
mapConfigure?: { mapConfigure?: {
amapKey?: string; amapKey?: string;
@@ -177,7 +177,7 @@ declare global {
hideTabs?: boolean; hideTabs?: boolean;
hideFooter?: boolean; hideFooter?: boolean;
showLogo?: boolean; showLogo?: boolean;
showModel?: string; tagsStyle?: string;
multiTagsCache?: boolean; multiTagsCache?: boolean;
stretch?: boolean | number; stretch?: boolean | number;
}; };