1
0
mirror of https://github.com/ialley-workshop-open/uni-halo.git synced 2026-09-12 16:40:40 +08:00

fix: 优化文章卡片样式与布局设置联动

1. 修复双列布局下卡片样式仅允许image_top的逻辑
2. 增加卡片样式选项禁用状态与点击拦截
3. 调整设置项样式类与交互逻辑
This commit is contained in:
小莫唐尼
2026-09-09 16:58:27 +08:00
parent d49a918ba4
commit b41e01106a
4 changed files with 42 additions and 18 deletions
@@ -111,7 +111,7 @@
: 'image_top' : 'image_top'
} }
const narrow = isGrid.value || (props.from === 'home' && _layout.home.listLayout === 'double') 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 'image_top'
} }
return raw return raw
@@ -3,10 +3,6 @@
import { useSettingStore } from '@/store/setting' import { useSettingStore } from '@/store/setting'
import { usePreferenceRows } from '@/hooks/usePreferenceRows' import { usePreferenceRows } from '@/hooks/usePreferenceRows'
import { useSettingsPopup } from '@/hooks/useSettingsPopup' import { useSettingsPopup } from '@/hooks/useSettingsPopup'
import { useDialog } from '@wot-ui/ui'
const dialog = useDialog()
const settingStore = useSettingStore() const settingStore = useSettingStore()
const { const {
@@ -18,6 +14,7 @@
handleRevert, handleRevert,
handleBoolChange, handleBoolChange,
handleChoose, handleChoose,
isCardTypeOptionDisabled,
} = usePreferenceRows() } = usePreferenceRows()
const { settingsPopupVisible } = useSettingsPopup() const { settingsPopupVisible } = useSettingsPopup()
@@ -26,7 +23,7 @@
const activeTab = ref<'layout' | 'feature'>('layout') const activeTab = ref<'layout' | 'feature'>('layout')
// 进行过滤,只保留当前页面的布局和功能 // 进行过滤,只保留当前页面的布局和功能
const pages = getCurrentPages() const pages = getCurrentPages()
const currentPage = pages[pages.length - 1] const currentPage = pages[pages.length - 1]
const filterLayoutGroups = computed(() => { const filterLayoutGroups = computed(() => {
@@ -117,14 +114,17 @@
<view class="mt-3 flex flex-wrap gap-2"> <view class="mt-3 flex flex-wrap gap-2">
<view <view
class="rounded-full px-3 py-1 text-xs uh-global-card-glass shadow-none border" class="rounded-full px-3 py-1 text-xs uh-global-card-glass shadow-none border"
:class="currentValueOf(row.path) === null ? 'bg-secondary font-bold' : 'text-gray-500'" :class="currentValueOf(row.path) === null ? 'bg-secondary font-bold' : 'border-gray-100 text-gray-500'"
@click="handleInlineChoose(row.path, null)"> @click="handleInlineChoose(row.path, null)">
默认 默认
</view> </view>
<view v-for="opt in row.options" :key="opt.value" <view v-for="opt in row.options" :key="opt.value"
class="rounded-full px-3 py-1 text-xs uh-global-card-glass shadow-none border" class="rounded-full px-3 py-1 text-xs uh-global-card-glass shadow-none border"
:class="currentValueOf(row.path) === opt.value ? 'bg-secondary font-bold' : ' border-gray-100 text-gray-500'" :class="[
@click="handleInlineChoose(row.path, opt.value)"> 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 }} {{ opt.label }}
</view> </view>
</view> </view>
@@ -160,19 +160,19 @@
<view class="mt-3 flex flex-wrap gap-2"> <view class="mt-3 flex flex-wrap gap-2">
<view <view
class="rounded-full px-3 py-1 text-xs uh-global-card-glass shadow-none border" class="rounded-full px-3 py-1 text-xs uh-global-card-glass shadow-none border"
:class="row.following ? 'bg-secondary font-bold' : 'text-gray-500'" :class="row.following ? 'bg-secondary font-bold' : 'border-gray-100 text-gray-500'"
@click="handleRevert(row.path)"> @click="handleRevert(row.path)">
默认 默认
</view> </view>
<view <view
class="rounded-full px-3 py-1 text-xs uh-global-card-glass shadow-none border" class="rounded-full px-3 py-1 text-xs uh-global-card-glass shadow-none border"
:class="!row.following && row.boolValue ? 'bg-secondary font-bold' : 'text-gray-500'" :class="!row.following && row.boolValue ? 'bg-secondary font-bold' : 'border-gray-100 text-gray-500'"
@click="handleBoolChange(row.path, true)"> @click="handleBoolChange(row.path, true)">
</view> </view>
<view <view
class="rounded-full px-3 py-1 text-xs uh-global-card-glass shadow-none border" class="rounded-full px-3 py-1 text-xs uh-global-card-glass shadow-none border"
:class="!row.following && !row.boolValue ? 'bg-secondary font-bold' : 'text-gray-500'" :class="!row.following && !row.boolValue ? 'bg-secondary font-bold' : 'border-gray-100 text-gray-500'"
@click="handleBoolChange(row.path, false)"> @click="handleBoolChange(row.path, false)">
</view> </view>
+23 -1
View File
@@ -150,11 +150,31 @@ export function usePreferenceRows() {
settingStore.savePreference(buildPatch(path, next)); 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 { function handleChoose(path: string[], value: string | null): void {
if (value === null) { if (value === null) {
handleRevert(path); handleRevert(path);
} else { } else {
settingStore.savePreference(buildPatch(path, value)); 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, isFollowing,
handleRevert, handleRevert,
handleBoolChange, handleBoolChange,
handleChoose handleChoose,
isDoubleColumn,
isCardTypeOptionDisabled
}; };
} }
+4 -2
View File
@@ -27,6 +27,7 @@
handleRevert, handleRevert,
handleBoolChange, handleBoolChange,
handleChoose, handleChoose,
isCardTypeOptionDisabled,
} = usePreferenceRows() } = usePreferenceRows()
/** 确保启动合并已执行(入口页未跑或 H5 直达时兜底) */ /** 确保启动合并已执行(入口页未跑或 H5 直达时兜底) */
@@ -65,13 +66,14 @@
} }
/* ---------------- wd-picker-view 弹层数据 ---------------- */ /* ---------------- wd-picker-view 弹层数据 ---------------- */
/** 枚举弹层列(首项「跟随站点默认」,空串哨兵映射 null) */ /** 枚举弹层列(首项「跟随站点默认」,空串哨兵映射 null;双列约束下卡片样式仅保留 image_top) */
const enumColumns = computed(() => { const enumColumns = computed(() => {
const def = enumSheet.value.def const def = enumSheet.value.def
if (!def) { return [] } if (!def) { return [] }
const options = (def.options || []).filter(opt => !isCardTypeOptionDisabled(def.path, opt.value))
return [ return [
{ label: '跟随站点默认', value: '' }, { label: '跟随站点默认', value: '' },
...(def.options || []).map(opt => ({ label: opt.label, value: opt.value })), ...options.map(opt => ({ label: opt.label, value: opt.value })),
] ]
}) })