From 6144dc72b8f8a52cc33a716716b87e1e11533777 Mon Sep 17 00:00:00 2001 From: jinhhanhan <1683105490@qq.com> Date: Fri, 16 Jan 2026 18:00:03 +0800 Subject: [PATCH 01/13] =?UTF-8?q?chore:=E9=9D=9E=20h5=20=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=20:key=20=E4=B8=8D=E6=94=AF=E6=8C=81=E8=A1=A8=E8=BE=BE?= =?UTF-8?q?=E5=BC=8F=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages_tool/ai-chat/ai-chat-message.vue | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pages_tool/ai-chat/ai-chat-message.vue b/pages_tool/ai-chat/ai-chat-message.vue index edcf3a8..4978f1b 100644 --- a/pages_tool/ai-chat/ai-chat-message.vue +++ b/pages_tool/ai-chat/ai-chat-message.vue @@ -10,8 +10,7 @@ - + @@ -392,6 +391,19 @@ export default { isFetchingHistory: false } }, + computed: { + // 为每条消息生成兼容小程序的唯一 key + messagesWithKey() { + return this.messages.map((msg, idx) => { + const uniqueId = msg.id || msg.timestamp || idx; + return { + ...msg, + __renderKey: `msg_${uniqueId}_${idx}`, + __index: idx // 保留原始索引,用于判断 first-message 等 + }; + }); + } + }, onShow() { // 优先读取本地缓存的会话 ID const localConvId = this.getConversationIdFromLocal(); From 1ebb94e9e2d9f80a05b64dc244e5ee506df72ee3 Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Sat, 17 Jan 2026 13:52:19 +0800 Subject: [PATCH 02/13] =?UTF-8?q?chore:=20=E8=B0=83=E6=95=B4=E9=9A=90?= =?UTF-8?q?=E7=A7=81=E5=8D=8F=E8=AE=AE=E5=8F=8A=E6=B3=A8=E5=86=8C=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=B1=95=E7=A4=BA=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages_tool/agreement/contenr.vue | 199 ++++++++++++++++++++++++++----- 1 file changed, 167 insertions(+), 32 deletions(-) diff --git a/pages_tool/agreement/contenr.vue b/pages_tool/agreement/contenr.vue index 0477a08..4d0f37f 100644 --- a/pages_tool/agreement/contenr.vue +++ b/pages_tool/agreement/contenr.vue @@ -1,52 +1,187 @@ - \ No newline at end of file From 7ae7a1d3bdf4cb9692b269dd15c5fc5ff392b763 Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Sat, 17 Jan 2026 15:30:02 +0800 Subject: [PATCH 03/13] =?UTF-8?q?chore(uniapp):=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=8B=B7=E8=B4=9D=E6=96=87=E6=9C=AC=E8=B6=85=E6=97=B6=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E6=8F=90=E7=A4=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .local.config.js | 4 ++ common/js/uniapp.utils.js | 135 +++++++++++++++++++++++++++----------- 2 files changed, 101 insertions(+), 38 deletions(-) diff --git a/.local.config.js b/.local.config.js index 28cf028..6386cb0 100644 --- a/.local.config.js +++ b/.local.config.js @@ -38,6 +38,10 @@ const localDevConfig = ({ uniacid: 1, domain: 'https://test.aigc-quickapp.com', }, + 'local-2': { // 测试平台 + uniacid: 2, + domain: 'http://localhost:8050/', + }, })['2811']; // 选择要使用的环境配置 export default localDevConfig; \ No newline at end of file diff --git a/common/js/uniapp.utils.js b/common/js/uniapp.utils.js index e450d28..2034bd9 100644 --- a/common/js/uniapp.utils.js +++ b/common/js/uniapp.utils.js @@ -6,13 +6,23 @@ /** * 显示错误信息 * @param {Exception} err + * @param {Boolean} useModal */ -const showError = (err) => { - uni.showToast({ - title: err?.message || err?.errMsg || err?.toString(), - icon: 'none', - duration: 2000 - }); +const showError = (err, useModal = false) => { + const content = err?.message || err?.errMsg || err?.toString(); + if (!useModal) { + uni.showToast({ + title: content, + icon: 'none', + duration: 3000 + }); + } else { + uni.showModal({ + title: '错误提示', + content, + showCancel: false, + }) + } } /** @@ -33,43 +43,92 @@ export const makePhoneCall = (mobile) => { } /** - * 拷贝文本 + * 拷贝文本(返回 Promise) * @param {*} text * @param {*} options + * @returns {Promise} 返回 Promise,成功时 resolve,失败时 reject */ -export const copyText = (text, { copySuccess = '', copyFailed = '' } = {}) => { - try { - console.log('copyText'); - uni.setClipboardData({ - data: `${text}`, - success: () => { - console.error('复制成功'); - try { - uni.showToast({ - title: copySuccess, - icon: 'success', - duration: 2000 - }); - } catch (e) { - showError(e); +export const copyTextAsync = (text, { copySuccess = '', copyFailed = '' } = {}) => { + return new Promise((resolve, reject) => { + // 输入验证 + if (!text && text !== '') { + const error = new Error('复制文本不能为空'); + showError(error); + reject(error); + return; + } + + // 超时监测 + const timeoutId = setTimeout(() => { + let error = new Error('复制操作长时间无响应,请检查相关权限及配置是否正确'); + // #ifdef MP-WEIXIN + error = new Error([ + '复制操作长时间无响应!', + '原因:', + '1.微信平台->用户隐私保护指引->"剪贴板"功能未添加或审核未通过;', + '2.微信平台对剪贴板API调用频率有限制' + ].join('\r\n')); + // #endif + showError(error, true); + reject(error); + }, 5000); + + try { + uni.setClipboardData({ + data: `${text}`, + success: (res) => { + clearTimeout(timeoutId); + + try { + if (copySuccess) { + uni.showToast({ + title: copySuccess, + icon: 'success', + duration: 2000 + }); + } + } catch (e) { + showError(e); + } + + resolve(res); + }, + fail: (err) => { + clearTimeout(timeoutId); + try { + uni.showToast({ + title: err.message || err.errMsg || copyFailed || '复制失败', + icon: 'none', + duration: 2000 + }); + } catch (e) { + showError(e); + } + reject(err); } - }, - fail: (err) => { - console.error('复制失败:', err); - try { - uni.showToast({ - title: err.message || err.errMsg || copyFailed, - icon: 'none', - duration: 2000 - }); - } catch (e) { - showError(e); - } - } + }); + } catch (err) { + clearTimeout(timeoutId); + showError(err); + reject(err); + } + }); +} + +/** + * 拷贝文本(回调形式,兼容旧代码) + * @param {*} text + * @param {*} options + * @param {Function} callback 回调函数,接收 (success, error) 参数 + */ +export const copyText = (text, options = {}, callback) => { + copyTextAsync(text, options) + .then(res => { + if (callback) callback(true, null); + }) + .catch(err => { + if (callback) callback(false, err); }); - } catch (err) { - showError(err); - } } /** From 153c84266a3f27a7c72b5c4cb94aa0c7c17114a0 Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Fri, 23 Jan 2026 09:25:58 +0800 Subject: [PATCH 04/13] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E5=92=8C=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将项目名称从'lucky_shop'改为'mp-weixin' - 在project.config.json中添加include数组和多个新配置项 - 启用enhance功能并添加编译相关设置 --- project.config.json | 15 ++++++++++++--- project.private.config.json | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/project.config.json b/project.config.json index 7126295..776d6c4 100644 --- a/project.config.json +++ b/project.config.json @@ -1,12 +1,13 @@ { "description": "项目配置文件", "packOptions": { - "ignore": [] + "ignore": [], + "include": [] }, "setting": { "urlCheck": true, "es6": true, - "enhance": false, + "enhance": true, "postcss": true, "preloadBackgroundData": false, "minified": true, @@ -37,7 +38,15 @@ "userConfirmedBundleSwitch": false, "packNpmManually": false, "packNpmRelationList": [], - "minifyWXSS": true + "minifyWXSS": true, + "condition": true, + "swc": false, + "disableSWC": true, + "minifyWXML": true, + "compileWorklet": true, + "localPlugins": false, + "disableUseStrict": false, + "useCompilerPlugins": false }, "compileType": "miniprogram", "libVersion": "2.16.1", diff --git a/project.private.config.json b/project.private.config.json index cd9faf2..ba3edb6 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -1,6 +1,6 @@ { "libVersion": "3.12.0", - "projectname": "lucky_shop", + "projectname": "mp-weixin", "condition": {}, "setting": { "urlCheck": true, From e8ccb87266ff575c6baff59ceb6da2cf0bad948d Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Fri, 23 Jan 2026 10:12:30 +0800 Subject: [PATCH 05/13] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20=E5=A2=9E?= =?UTF-8?q?=E5=BC=BA=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=A1=A5?= =?UTF-8?q?=E4=B8=81=E8=84=9A=E6=9C=AC=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加新的 npm scripts 支持不同模式运行补丁脚本 - 支持命令行参数 --no-zip 和 --mode 控制 ZIP 文件生成和运行模式 - 自动复制项目配置文件到目标目录 - 更新使用说明文档 --- package.json | 5 +++- scripts/mp-weixin.patch.js | 60 +++++++++++++++++++++++++++++--------- 2 files changed, 50 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 3c45a8f..c82e734 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,9 @@ { "scripts": { - "mp-weixin": "node scripts/mp-weixin.patch.js" + "mp-weixin": "node scripts/mp-weixin.patch.js", + "mp-weixin:patch": "node scripts/mp-weixin.patch.js --no-zip", + "mp-weixin:dev": "node scripts/mp-weixin.patch.js --mode development", + "mp-weixin:dev:patch": "node scripts/mp-weixin.patch.js --mode development --no-zip" }, "devDependencies": { "dart-sass": "^1.25.0", diff --git a/scripts/mp-weixin.patch.js b/scripts/mp-weixin.patch.js index c3c0de9..43f5032 100644 --- a/scripts/mp-weixin.patch.js +++ b/scripts/mp-weixin.patch.js @@ -9,7 +9,10 @@ * 如果这个文件开头已经有了这行代码,则不追加 * * 使用: - * node fix-wechat-miniapp.js + * node fix-wechat-miniapp.js # 打补丁并创建 ZIP 文件(默认 mode=production) + * node fix-wechat-miniapp.js --no-zip # 只打补丁,不创建 ZIP 文件 + * node fix-wechat-miniapp.js --mode development # 使用 development 模式打补丁 + * node fix-wechat-miniapp.js --mode production # 使用 production 模式打补丁(默认) * * 注意: * - 在 Windows 上路径使用反斜杠也是可以的;脚本使用 path.join 来兼容不同平台。 @@ -29,8 +32,6 @@ async function commonPatch(mode = 'production') { // 根据当前脚本所在目录(scripts),定位到项目根目录 const cwd = path.join(__dirname, '..'); - - const srcSitePath = path.join(cwd, 'site.js'); const destDir = path.join(cwd, 'unpackage', 'dist', mode === 'production' ? 'build' : 'dev', 'mp-weixin'); const destSitePath = path.join(destDir, 'site.js'); @@ -47,6 +48,22 @@ async function commonPatch(mode = 'production') { // 确保目标目录存在 await ensureDir(destDir); + // 复制 project.config.json 及 project.private.config.json 文件到 destDir 下面 + const configFiles = ['project.config.json', 'project.private.config.json']; + for (const fileName of configFiles) { + const srcPath = path.join(cwd, fileName); + const destPath = path.join(destDir, fileName); + + // 检查源文件是否存在 + const fileExists = await exists(srcPath); + if (fileExists) { + await fsp.copyFile(srcPath, destPath); + console.log(`已拷贝: ${srcPath} -> ${destPath}`); + } else { + console.warn(`源文件不存在,跳过复制: ${srcPath}`); + } + } + // 复制 site.js 到目标目录(覆盖) await fsp.copyFile(srcSitePath, destSitePath); console.log(`已拷贝: ${srcSitePath} -> ${destSitePath}`); @@ -96,22 +113,37 @@ async function commonPatch(mode = 'production') { } } - - async function main() { + // 解析命令行参数 + const argv = process.argv.slice(2); + const options = { + noZip: argv.includes('--no-zip'), + mode: 'production' // 默认值 + }; + + // 解析 --mode 参数 + const modeIndex = argv.indexOf('--mode'); + if (modeIndex !== -1 && modeIndex + 1 < argv.length) { + options.mode = argv[modeIndex + 1]; + } + // 1) 打补丁 - await commonPatch('production'); + await commonPatch(options.mode); // await commonPatch('development'); - // 2) 创建 ZIP 文件 - const cwd = path.join(__dirname, '..'); - const sourceDir = path.join(cwd, 'unpackage', 'dist', 'build', 'mp-weixin'); - const destDir = path.join(cwd, 'unpackage', 'dist', 'build'); - const zipFilePath = await createZipWithSystemCommand(sourceDir, destDir); - console.log(`ZIP 文件路径: ${zipFilePath}`); + // 2) 创建 ZIP 文件(如果未指定 --no-zip) + if (!options.noZip) { + const cwd = path.join(__dirname, '..'); + const sourceDir = path.join(cwd, 'unpackage', 'dist', 'build', 'mp-weixin'); + const destDir = path.join(cwd, 'unpackage', 'dist', 'build'); + const zipFilePath = await createZipWithSystemCommand(sourceDir, destDir); + console.log(`ZIP 文件路径: ${zipFilePath}`); - // 3) 自动打开zip所在的目录 - await openFileDirectory(zipFilePath); + // 3) 自动打开zip所在的目录 + await openFileDirectory(zipFilePath); + } else { + console.log('跳过创建 ZIP 文件和打开目录'); + } } async function exists(p) { From aa9d2e64d237c218539a24318bea8a49e689ccaa Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Fri, 23 Jan 2026 11:18:55 +0800 Subject: [PATCH 06/13] =?UTF-8?q?feat(util):=20=E6=B7=BB=E5=8A=A0=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E6=8C=89=E9=92=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加 hideHomeButton 方法用于在微信小程序环境中隐藏首页按钮,提升用户体验 --- common/js/util.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/js/util.js b/common/js/util.js index 21b3588..59114f2 100644 --- a/common/js/util.js +++ b/common/js/util.js @@ -843,6 +843,15 @@ export default { uni.navigateBack(); } }, + /** + * 隐藏“返回首页/小房子”按钮 + * 这个函数,用到页面show, onshow 的生命周期时 + */ + hideHomeButton() { + // #ifdef MP-WEIXIN + wx.hideHomeButton(); + // #endif + }, /** * * @param val 转化时间字符串 (转化时分秒) From ceca4e5956b954ee5dd39eb90a58341b0e6138e1 Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Fri, 23 Jan 2026 11:36:15 +0800 Subject: [PATCH 07/13] =?UTF-8?q?fix:=20=E5=9C=A8=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=B7=BB=E5=8A=A0=E9=9A=90=E8=97=8F=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E6=8C=89=E9=92=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为统一处理首页按钮显示逻辑,在会员页、联系页和商品分类页的onShow生命周期中添加了hideHomeButton调用 --- pages_goods/category.vue | 1 + pages_tool/contact/contact.vue | 3 +++ pages_tool/member/index.vue | 3 +++ 3 files changed, 7 insertions(+) diff --git a/pages_goods/category.vue b/pages_goods/category.vue index 9edb1b9..a863f67 100644 --- a/pages_goods/category.vue +++ b/pages_goods/category.vue @@ -38,6 +38,7 @@ export default { }, onShow() { if (this.$refs.category) this.$refs.category[0].pageShow(); + this.$util.hideHomeButton(); }, onUnload() { if (!this.storeToken && this.$refs.login) this.$refs.login.cancelCompleteInfo(); diff --git a/pages_tool/contact/contact.vue b/pages_tool/contact/contact.vue index 08ece5a..bda2223 100644 --- a/pages_tool/contact/contact.vue +++ b/pages_tool/contact/contact.vue @@ -301,6 +301,9 @@ export default { fail: res => { } }); }, + onShow() { + this.$util.hideHomeButton(); + }, methods: { // 分享文件 shareFile(file) { diff --git a/pages_tool/member/index.vue b/pages_tool/member/index.vue index 499ee06..2259642 100644 --- a/pages_tool/member/index.vue +++ b/pages_tool/member/index.vue @@ -86,6 +86,9 @@ export default { nsNewGift }, mixins: [diyJs, indexJs], + onShow() { + this.$util.hideHomeButton(); + }, methods: { tourl(url) { From 29b5cfda6fe8c95c821215a85a2cca8e6ff3f4d9 Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Fri, 23 Jan 2026 11:54:31 +0800 Subject: [PATCH 08/13] =?UTF-8?q?fix:=20=E5=9C=A8=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=97=B6=E7=BB=9F=E4=B8=80=E9=9A=90=E8=97=8F?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在多个页面的onLoad生命周期中添加this.$util.hideHomeButton()调用,确保页面加载时即隐藏首页按钮,避免显示不一致问题。同时调整category.vue中onShow的逻辑顺序。 --- pages_goods/category.vue | 5 ++--- pages_tool/contact/contact.vue | 1 + pages_tool/member/index.vue | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pages_goods/category.vue b/pages_goods/category.vue index a863f67..be21c82 100644 --- a/pages_goods/category.vue +++ b/pages_goods/category.vue @@ -30,15 +30,14 @@ export default { }; }, onLoad() { + this.$util.hideHomeButton(); //刷新多语言 this.$langConfig.refresh(); - - uni.hideTabBar(); this.getDiyInfo(); }, onShow() { - if (this.$refs.category) this.$refs.category[0].pageShow(); this.$util.hideHomeButton(); + if (this.$refs.category) this.$refs.category[0].pageShow(); }, onUnload() { if (!this.storeToken && this.$refs.login) this.$refs.login.cancelCompleteInfo(); diff --git a/pages_tool/contact/contact.vue b/pages_tool/contact/contact.vue index bda2223..9b97a97 100644 --- a/pages_tool/contact/contact.vue +++ b/pages_tool/contact/contact.vue @@ -252,6 +252,7 @@ export default { }; }, onLoad(option) { + this.$util.hideHomeButton(); this.$langConfig.refresh(); this.$api.sendRequest({ url: '/api/member/personnel', diff --git a/pages_tool/member/index.vue b/pages_tool/member/index.vue index 2259642..27081c1 100644 --- a/pages_tool/member/index.vue +++ b/pages_tool/member/index.vue @@ -86,6 +86,9 @@ export default { nsNewGift }, mixins: [diyJs, indexJs], + onLoad() { + this.$util.hideHomeButton(); + }, onShow() { this.$util.hideHomeButton(); }, From 0939449aa79306695ecd7423a5192420297a0733 Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Fri, 23 Jan 2026 17:07:38 +0800 Subject: [PATCH 09/13] =?UTF-8?q?fix(ns-login):=20=E4=BF=AE=E5=A4=8Dcomple?= =?UTF-8?q?te-info-wrap=E5=BC=B9=E7=AA=97=E5=B1=82=E7=BA=A7=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/ns-login/ns-login.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/components/ns-login/ns-login.vue b/components/ns-login/ns-login.vue index f14421e..7b750d5 100644 --- a/components/ns-login/ns-login.vue +++ b/components/ns-login/ns-login.vue @@ -760,6 +760,7 @@ export default {