From 80fc62e60231eb13f6792616963674042fcda385 Mon Sep 17 00:00:00 2001 From: Luk Date: Fri, 16 Feb 2024 09:58:37 +0800 Subject: [PATCH] add `make_bgurl(image)` --- unitool.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/unitool.js b/unitool.js index 3384f86..77ae7c3 100644 --- a/unitool.js +++ b/unitool.js @@ -154,6 +154,10 @@ export default { return `${protocol}://${hostname}${port ? ':' : ''}${port}/${route}` }, + make_bgurl (image) { + return image ? `url(${this.make_server_url(image)})` : '' + }, + /** 统一 uni.request 和 uniCloud.callFunction 的调用方法,提供统一、透明的后台调用 * 返回值:{ _state, 成功结果或错误结果 },其中 _state 除了后台返回的,还可以是 * - CLIENT_WOBASE_BROKEN: 前端发现后台断线 @@ -172,10 +176,13 @@ export default { const thisRoute = getCurrentPages()?.pop?.()?.route || 'VueApp' // 立刻保存 route,因为在调用后台后,可能已切换到了其他页面。 const startTime = new Date().toJSON() let apiurl = undefined - apiWhat._clientInfo = globalThis.wo?.envar?.clientInfo - // #ifdef WEB - Object.assign(apiWhat._clientInfo, { requrl: globalThis.location?.href, lang: globalThis.wo?.ss?.i18n?.mylang }) - // #endif + apiWhat._clientInfo = { + ...globalThis.wo?.envar?.clientInfo, + lang: globalThis.wo?.ss?.i18n?.mylang, + // #ifdef WEB + requrl: globalThis.location?.href + // #endif + } apiWhat._passtoken = uni.getStorageSync('_passtoken') let result = {} if (baseType === 'UNICLOUD_OBJECT') { @@ -513,7 +520,11 @@ export default { } }, - showModal (option) { + showModal (option = {}) { + option.title = this.localizeText(option.title) + option.content = this.localizeText(option.content) + option.cancelText = this.localizeText(option.cancelText || { zhCN: '取消', enUS: 'Cancel' }) + option.confirmText = this.localizeText(option.confirmText || { zhCN: '好的', enUS: 'OK' }) // #ifdef APP if (option.content) option.content = '\n' + option.content // #endif