高考版优化

审核模式优化
This commit is contained in:
Ghost
2026-04-29 18:01:26 +08:00
parent 59419c4ce9
commit a411bf7b21
134 changed files with 19898 additions and 3371 deletions

View File

@@ -11,66 +11,6 @@ const DEFAULT_ITEMS = [
{ pagePath: 'pages/profile/index', text: '我', iconKey: 'profile', iconUrl: '', highlight: false }
]
const AI_PATH = 'pages/ai-chat/index'
/** 与 iconKey 为 ai 时的图标 URL 归一(与 refreshFromConfig 内一致) */
function mapTabIconUrls(rawItems) {
return rawItems.map((it) => {
if (it.iconKey === 'ai') {
const u = (it.iconUrl && String(it.iconUrl).trim()) || ''
const raster = /\.(png|jpg|jpeg|webp)$/i.test(u)
if (raster) {
return {
...it,
iconUrl: u,
iconUrlActive: (it.iconUrlActive && String(it.iconUrlActive).trim()) || '/images/tab-ai-active.png'
}
}
return { ...it, iconUrl: '', iconUrlActive: '' }
}
return { ...it, iconUrl: it.iconUrl || '' }
})
}
/**
* 提审/面相审核:去掉神仙 AI非审核且列表无神仙 AI 时补回(与 app.json 仅 3 Tab 时 navigateTo 兜底配合)
*/
function applyAuditFilterAndMaybeInjectAi(items, gd) {
const hideAiTab = isAuditHideAiMode(gd)
const hideMiddleFab = shouldHideTabBarHighlightFab(gd)
let effectiveItems = items.filter((it) => {
const path = (it.pagePath || '').replace(/^\//, '')
if (hideAiTab && (it.iconKey === 'ai' || /ai-chat/.test(path))) return false
if (hideMiddleFab && it.highlight) return false
return true
})
const hasAiItem = effectiveItems.some((it) => {
const p = (it.pagePath || '').replace(/^\//, '')
return p === AI_PATH || it.iconKey === 'ai' || /ai-chat/.test(p)
})
if (!hideAiTab && !hasAiItem) {
const next = effectiveItems.slice()
const insertAt = Math.max(0, next.length - 1)
next.splice(insertAt, 0, {
pagePath: AI_PATH,
text: '神仙AI',
iconKey: 'ai',
iconUrl: '',
iconUrlActive: '',
highlight: false,
})
effectiveItems = next
}
return {
effectiveItems,
reviewMode: !!(gd.reviewMode || gd.maintenanceMode),
hideMiddleFab,
}
}
Component({
data: {
selected: 0,
@@ -93,14 +33,38 @@ Component({
methods: {
refreshFromConfig() {
const app = getApp() || {}
const gd = app.globalData || {}
try {
const app = getApp() || {}
const gd = app.globalData || {}
const cfg = gd.tabBar && Array.isArray(gd.tabBar.items) ? gd.tabBar.items : null
const rawItems = (cfg && cfg.length >= 2) ? cfg.slice() : DEFAULT_ITEMS.slice()
const items = mapTabIconUrls(rawItems)
const { effectiveItems, reviewMode, hideMiddleFab } = applyAuditFilterAndMaybeInjectAi(items, gd)
const items = rawItems.map((it) => {
if (it.iconKey === 'ai') {
const u = (it.iconUrl && String(it.iconUrl).trim()) || ''
const raster = /\.(png|jpg|jpeg|webp)$/i.test(u)
if (raster) {
return {
...it,
iconUrl: u,
iconUrlActive: (it.iconUrlActive && String(it.iconUrlActive).trim()) || '/images/tab-ai-active.png'
}
}
return { ...it, iconUrl: '', iconUrlActive: '' }
}
return { ...it, iconUrl: it.iconUrl || '' }
})
const reviewMode = !!(gd.reviewMode || gd.maintenanceMode)
const hideAiTab = isAuditHideAiMode(gd)
const hideMiddleFab = shouldHideTabBarHighlightFab(gd)
// 审核模式:隐藏神仙 AI审核模式 / face 关闭时:隐藏所有 highlight=true 的 Tab
const effectiveItems = items.filter((it) => {
const path = (it.pagePath || '').replace(/^\//, '')
if (hideAiTab && (it.iconKey === 'ai' || /ai-chat/.test(path))) return false
if (hideMiddleFab && it.highlight) return false
return true
})
this.setData({
items: effectiveItems,
@@ -108,17 +72,7 @@ Component({
hideMiddleFab,
}, () => this.updateSelected())
} catch (e) {
try {
const items = mapTabIconUrls(DEFAULT_ITEMS.slice())
const { effectiveItems, reviewMode, hideMiddleFab } = applyAuditFilterAndMaybeInjectAi(items, gd)
this.setData({
items: effectiveItems,
reviewMode,
hideMiddleFab,
}, () => this.updateSelected())
} catch (e2) {
this.setData({ items: [], reviewMode: false, hideMiddleFab: false }, () => this.updateSelected())
}
this.setData({ items: DEFAULT_ITEMS, reviewMode: false, hideMiddleFab: false }, () => this.updateSelected())
}
},
@@ -166,12 +120,18 @@ Component({
if (it.pagePath === 'pages/index/index' || it.iconKey === 'home') {
try {
const app = getApp()
const scope = (app && app.globalData && app.globalData.appScope) || 'personal'
const gd = (app && app.globalData) || {}
const scope = gd.selectedHomeVersion || gd.appScope || 'personal'
if (scope === 'enterprise') {
wx.navigateTo({ url: '/pages/enterprise/index' })
this.setData({ selected: index })
return
}
if (scope === 'gaokao') {
wx.navigateTo({ url: '/pages/gaokao/index' })
this.setData({ selected: index })
return
}
} catch (e) {}
}