diff --git a/src/components/uh-article-card/uh-article-card.vue b/src/components/uh-article-card/uh-article-card.vue index 1e29ab1..64a913f 100644 --- a/src/components/uh-article-card/uh-article-card.vue +++ b/src/components/uh-article-card/uh-article-card.vue @@ -111,7 +111,7 @@ : 'image_top' } const narrow = isGrid.value || (props.from === 'home' && _layout.home.listLayout === 'double') - if (narrow && (raw === 'image_left' || raw === 'image_right')) { + if (narrow && raw !== 'image_top') { return 'image_top' } return raw diff --git a/src/components/uh-settings-popup/uh-settings-popup.vue b/src/components/uh-settings-popup/uh-settings-popup.vue index 40e9da8..d395705 100644 --- a/src/components/uh-settings-popup/uh-settings-popup.vue +++ b/src/components/uh-settings-popup/uh-settings-popup.vue @@ -2,11 +2,7 @@ import { ref } from 'vue' import { useSettingStore } from '@/store/setting' import { usePreferenceRows } from '@/hooks/usePreferenceRows' - import { useSettingsPopup } from '@/hooks/useSettingsPopup' - import { useDialog } from '@wot-ui/ui' - - const dialog = useDialog() - + import { useSettingsPopup } from '@/hooks/useSettingsPopup' const settingStore = useSettingStore() const { @@ -18,6 +14,7 @@ handleRevert, handleBoolChange, handleChoose, + isCardTypeOptionDisabled, } = usePreferenceRows() const { settingsPopupVisible } = useSettingsPopup() @@ -25,8 +22,8 @@ const emits = defineEmits(['close', 'open']) const activeTab = ref<'layout' | 'feature'>('layout') - - // 进行过滤,只保留当前页面的布局和功能 + +// 进行过滤,只保留当前页面的布局和功能 const pages = getCurrentPages() const currentPage = pages[pages.length - 1] const filterLayoutGroups = computed(() => { @@ -34,7 +31,7 @@ return currentPage.route.split('/').pop() === group.key }) }) - + /* ---------------- 交互 ---------------- */ function currentValueOf(path : string[]) : string | null { return isFollowing(path) ? null : String(prefValueOf(path) ?? '') @@ -117,14 +114,17 @@ 默认 + :class="[ + currentValueOf(row.path) === opt.value ? 'bg-secondary font-bold' : 'border-gray-100 text-gray-500', + isCardTypeOptionDisabled(row.path, opt.value) ? 'opacity-40' : '' + ]" + @click="isCardTypeOptionDisabled(row.path, opt.value) ? null : handleInlineChoose(row.path, opt.value)"> {{ opt.label }} @@ -160,19 +160,19 @@ 默认 diff --git a/src/hooks/usePreferenceRows.ts b/src/hooks/usePreferenceRows.ts index 11860bf..545b13f 100644 --- a/src/hooks/usePreferenceRows.ts +++ b/src/hooks/usePreferenceRows.ts @@ -150,11 +150,31 @@ export function usePreferenceRows() { settingStore.savePreference(buildPatch(path, next)); } + /** 给定页面分组下字段路径,判断该页面列表布局是否为双列 */ + function isDoubleColumn(path: string[]): boolean { + if (path.length >= 2 && path[0] === 'layout') { + return prefValueOf(['layout', path[1], 'listLayout']) === 'double'; + } + return false; + } + + /** 卡片样式选项是否因双列约束被禁用(双列仅允许 image_top) */ + function isCardTypeOptionDisabled(path: string[], value: string): boolean { + return path[2] === 'cardType' && isDoubleColumn(path) && value !== 'image_top'; + } + function handleChoose(path: string[], value: string | null): void { if (value === null) { handleRevert(path); } else { settingStore.savePreference(buildPatch(path, value)); + // 双列约束:列表布局改为双列时,卡片样式强制为 image_top + if (path[0] === 'layout' && path[2] === 'listLayout' && value === 'double') { + const cardTypePath = ['layout', path[1], 'cardType']; + if (prefValueOf(cardTypePath) !== 'image_top') { + settingStore.savePreference(buildPatch(cardTypePath, 'image_top')); + } + } } } @@ -175,6 +195,8 @@ export function usePreferenceRows() { isFollowing, handleRevert, handleBoolChange, - handleChoose + handleChoose, + isDoubleColumn, + isCardTypeOptionDisabled }; } diff --git a/src/pages-blog/setting/setting.vue b/src/pages-blog/setting/setting.vue index 12698a2..bb225dc 100644 --- a/src/pages-blog/setting/setting.vue +++ b/src/pages-blog/setting/setting.vue @@ -27,6 +27,7 @@ handleRevert, handleBoolChange, handleChoose, + isCardTypeOptionDisabled, } = usePreferenceRows() /** 确保启动合并已执行(入口页未跑或 H5 直达时兜底) */ @@ -65,13 +66,14 @@ } /* ---------------- wd-picker-view 弹层数据 ---------------- */ - /** 枚举弹层列(首项「跟随站点默认」,空串哨兵映射 null) */ + /** 枚举弹层列(首项「跟随站点默认」,空串哨兵映射 null;双列约束下卡片样式仅保留 image_top) */ const enumColumns = computed(() => { const def = enumSheet.value.def if (!def) { return [] } + const options = (def.options || []).filter(opt => !isCardTypeOptionDisabled(def.path, opt.value)) return [ { label: '跟随站点默认', value: '' }, - ...(def.options || []).map(opt => ({ label: opt.label, value: opt.value })), + ...options.map(opt => ({ label: opt.label, value: opt.value })), ] })