优化首页逻辑以支持动态标题生成,提升用户体验。更新管理后台资源文件,替换旧的 JavaScript 和 CSS 文件,增强页面性能和样式一致性。同时,调整数据库结构以支持更细粒度的推送状态。
This commit is contained in:
68
miniprogram/utils/mpPagePopups.js
Normal file
68
miniprogram/utils/mpPagePopups.js
Normal file
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* 从 mpConfig.mpUi.pagePopupItems 按 pagePath + key 取文案(管理端 CRUD)。
|
||||
* 兼容旧版 mpUi.memberDetailPage / readPage 字段。
|
||||
*
|
||||
* 当前代码显式引用的键(与 soul-admin 默认种子 / db.defaultMpUi 一致,勿改 key 除非双端同步):
|
||||
* - MEMBER_PATH unlockIntroTitle, unlockIntroBody → member-detail.js _showUnlockIntroThenLogin
|
||||
* - READ_PATH beforeLoginHint, singlePageTitle, singlePagePaywallHint → read.js onLoad
|
||||
*/
|
||||
|
||||
const MEMBER_PATH = '/pages/member-detail/member-detail'
|
||||
const READ_PATH = '/pages/read/read'
|
||||
|
||||
function getList(app) {
|
||||
const mpUi = app.globalData.configCache && app.globalData.configCache.mpConfig
|
||||
? app.globalData.configCache.mpConfig.mpUi
|
||||
: null
|
||||
const list = mpUi && mpUi.pagePopupItems
|
||||
return Array.isArray(list) ? list : []
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} app getApp()
|
||||
* @param {string} pagePath 如 /pages/read/read
|
||||
* @param {string} key 英文键
|
||||
* @returns {string} 文案,未配置时返回空串
|
||||
*/
|
||||
function getPagePopupContent(app, pagePath, key) {
|
||||
const list = getList(app)
|
||||
const it = list.find(function (p) {
|
||||
return p && p.pagePath === pagePath && p.key === key
|
||||
})
|
||||
if (it && typeof it.content === 'string') return it.content.trim()
|
||||
return ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 带旧版 readPage / memberDetailPage 兜底
|
||||
*/
|
||||
function getReadPageContent(app, key) {
|
||||
const v = getPagePopupContent(app, READ_PATH, key)
|
||||
if (v) return v
|
||||
const rp = (app.globalData.configCache && app.globalData.configCache.mpConfig &&
|
||||
app.globalData.configCache.mpConfig.mpUi &&
|
||||
app.globalData.configCache.mpConfig.mpUi.readPage) || {}
|
||||
if (key === 'beforeLoginHint') return String(rp.beforeLoginHint || '').trim()
|
||||
if (key === 'singlePageTitle') return String(rp.singlePageTitle || '').trim()
|
||||
if (key === 'singlePagePaywallHint') return String(rp.singlePagePaywallHint || '').trim()
|
||||
return ''
|
||||
}
|
||||
|
||||
function getMemberDetailContent(app, key) {
|
||||
const v = getPagePopupContent(app, MEMBER_PATH, key)
|
||||
if (v) return v
|
||||
const md = (app.globalData.configCache && app.globalData.configCache.mpConfig &&
|
||||
app.globalData.configCache.mpConfig.mpUi &&
|
||||
app.globalData.configCache.mpConfig.mpUi.memberDetailPage) || {}
|
||||
if (key === 'unlockIntroTitle') return String(md.unlockIntroTitle || '').trim()
|
||||
if (key === 'unlockIntroBody') return String(md.unlockIntroBody || '').trim()
|
||||
return ''
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getPagePopupContent,
|
||||
getReadPageContent,
|
||||
getMemberDetailContent,
|
||||
MEMBER_PATH,
|
||||
READ_PATH,
|
||||
}
|
||||
Reference in New Issue
Block a user