scanner: Add redirect option to index page

This commit is contained in:
Fam Zheng 2025-03-01 21:10:22 +00:00
parent 361be2ac19
commit 0b8e93c94b
3 changed files with 18 additions and 0 deletions

View File

@ -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)

View File

@ -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);
},

View File

@ -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",