From 0b8e93c94b7f174163f336550da3442bd9674eb7 Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Sat, 1 Mar 2025 21:10:22 +0000 Subject: [PATCH] scanner: Add redirect option to index page --- api/products/views.py | 4 ++++ scanner/pages/index/index.js | 7 +++++++ scanner/project.private.config.json | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/api/products/views.py b/api/products/views.py index 093c81c..fd2ecaa 100644 --- a/api/products/views.py +++ b/api/products/views.py @@ -1245,6 +1245,10 @@ def mini_prog_entry_redirect(code, tid): key = 'mini-prog-entry.' + query path = sc.batch.mini_prog_entry_path or 'pages/index/index' env_version = sc.batch.mini_prog_entry_env_version or 'release' + if path != "/pages/index/index": + # the mplink path setting may not work for some reason, so we use + # redirect param of the index page as a fallback + query += '&redirect=' + path url = cache.get_or_set(key, lambda: mplink(query, path, env_version), 300) return redirect(url) diff --git a/scanner/pages/index/index.js b/scanner/pages/index/index.js index ec30012..47a91cb 100644 --- a/scanner/pages/index/index.js +++ b/scanner/pages/index/index.js @@ -82,6 +82,13 @@ Page({ gd.debug = true; } gd.tenant = options.tenant; + if (options.redirect && options.redirect.length > 0) { + console.log("Redirecting to", options.redirect); + wx.redirectTo({ + url: options.redirect, + }); + return; + } this.load_content(options.tenant); }, diff --git a/scanner/project.private.config.json b/scanner/project.private.config.json index b14be75..c6decc1 100644 --- a/scanner/project.private.config.json +++ b/scanner/project.private.config.json @@ -2,6 +2,13 @@ "condition": { "miniprogram": { "list": [ + { + "name": "index-redirect-to-chat", + "pathName": "pages/index/index", + "query": "redirect=/pages/chat/chat", + "launchMode": "default", + "scene": null + }, { "name": "chat", "pathName": "pages/chat/chat",