Files
MBTI_wang/miniprogram/utils/recoMiniProgram.js
卡若 ce55c48c64 feat: 同步今日小程序与后台迭代版本
集中提交今日 API、管理端、小程序与部署文档调整,确保 Gitea 主分支与本地最新开发版本一致。

Made-with: Cursor
2026-04-20 11:07:55 +08:00

28 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 精选推荐 → 跳转其他小程序 path与「一场 soul」阅读页 pages/read/read?id= 对齐)
* @param {string} basePath 后台配置的 path无 sourceId 时使用
* @param {{ id?: string|number, title?: string, sourceId?: string|number, fromTag?: string }} opts
*/
function buildRecoMiniProgramPath(basePath, opts) {
const id = opts && opts.id != null ? String(opts.id).trim() : ''
const title = opts && opts.title != null ? String(opts.title).trim() : ''
const sourceId = opts && opts.sourceId != null ? String(opts.sourceId).trim() : ''
const fromTag = (opts && opts.fromTag) || 'mbti_reco'
const parts = ['from=' + encodeURIComponent(fromTag)]
if (id) parts.push('mbtiArticleId=' + encodeURIComponent(id))
if (title) parts.push('title=' + encodeURIComponent(title.slice(0, 200)))
if (sourceId) {
let path = 'pages/read/read?id=' + encodeURIComponent(sourceId)
return path + '&' + parts.join('&')
}
let path = (basePath || 'pages/index/index').replace(/^\//, '')
if (!path) path = 'pages/index/index'
const sep = path.indexOf('?') >= 0 ? '&' : '?'
return path + sep + parts.join('&')
}
module.exports = {
buildRecoMiniProgramPath
}