更新
This commit is contained in:
@@ -116,12 +116,47 @@ function apiUrl(promise, Loading = true) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析页面参数(支持普通参数和扫码 scene 参数)
|
||||
* @param {Object} options - 页面 options,如 getCurrentPages()[].options
|
||||
* @returns {Object} 解析后的参数对象
|
||||
*/
|
||||
function parsePageParams(options) {
|
||||
const params = {}
|
||||
if (!options) return params
|
||||
|
||||
// 如果有 scene 参数(扫码进入),解析 scene
|
||||
if (options.scene) {
|
||||
try {
|
||||
const decodedScene = decodeURIComponent(options.scene)
|
||||
decodedScene.split('&').forEach(item => {
|
||||
const [key, value] = item.split('=')
|
||||
if (key && value) {
|
||||
params[key] = value
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('解析scene参数失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 合并普通参数(普通跳转进入)
|
||||
Object.keys(options).forEach(key => {
|
||||
if (key !== 'scene' && options[key]) {
|
||||
params[key] = options[key]
|
||||
}
|
||||
})
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
export function createApp() {
|
||||
const app = createSSRApp(App)
|
||||
|
||||
// Vue3挂载全局属性的方式
|
||||
app.config.globalProperties.$url = baseUrl
|
||||
app.config.globalProperties.apiUrl = apiUrl
|
||||
app.config.globalProperties.$parsePageParams = parsePageParams
|
||||
|
||||
return {
|
||||
app
|
||||
|
||||
Reference in New Issue
Block a user