收口宿主上下文查询契约

共享 HostBridge 契约新增宿主上下文 query 字段和值

移动壳和 H5 运行态改用共享 query 契约

桌面壳和微信壳门禁反查共享 query 契约

微信请求头和 H5 路由保留字段跟随共享契约

同步宿主上下文契约文档和共享记忆
This commit is contained in:
2026-06-19 07:39:51 +08:00
parent db153b0dde
commit de2798d415
14 changed files with 408 additions and 72 deletions
+8 -6
View File
@@ -18,8 +18,6 @@ const {
resolveWebViewUrlFromRuntimeConfig,
} = require('../host-bridge/webView');
const MINI_PROGRAM_CLIENT_TYPE = 'mini_program';
const MINI_PROGRAM_CLIENT_RUNTIME = 'wechat_mini_program';
const CLIENT_INSTANCE_STORAGE_KEY = 'genarrative:mini-program-client-instance-id';
const PAY_RESULT_STORAGE_KEY = 'genarrative:wechat-pay-result';
const AUTH_RESULT_STORAGE_KEY = 'genarrative:mini-program-auth-result';
@@ -69,6 +67,10 @@ function trimTrailingSlash(value) {
return String(value || '').trim().replace(/\/+$/u, '');
}
function readWebViewSourceQueryValue(key) {
return String((WEB_VIEW_SOURCE_QUERY && WEB_VIEW_SOURCE_QUERY[key]) || '').trim();
}
function isConfiguredApiBaseUrl(value) {
return /^https:\/\/[^/]+/i.test(String(value || '').trim());
}
@@ -306,8 +308,8 @@ function requestMiniProgramLogin(code, displayName) {
},
header: {
'content-type': 'application/json',
'x-client-type': MINI_PROGRAM_CLIENT_TYPE,
'x-client-runtime': MINI_PROGRAM_CLIENT_RUNTIME,
'x-client-type': readWebViewSourceQueryValue('clientType'),
'x-client-runtime': readWebViewSourceQueryValue('clientRuntime'),
'x-client-platform': resolveClientPlatform(),
'x-client-instance-id': getClientInstanceId(),
'x-mini-program-app-id': MINI_PROGRAM_APP_ID,
@@ -352,8 +354,8 @@ function requestMiniProgramBindPhone(authToken, wechatPhoneCode, displayName) {
header: {
authorization: `Bearer ${authToken}`,
'content-type': 'application/json',
'x-client-type': MINI_PROGRAM_CLIENT_TYPE,
'x-client-runtime': MINI_PROGRAM_CLIENT_RUNTIME,
'x-client-type': readWebViewSourceQueryValue('clientType'),
'x-client-runtime': readWebViewSourceQueryValue('clientRuntime'),
'x-client-platform': resolveClientPlatform(),
'x-client-instance-id': getClientInstanceId(),
'x-mini-program-app-id': MINI_PROGRAM_APP_ID,