consumer模块完成度95%,实现数据库多端注册登录,优化安卓端小程序bug

This commit is contained in:
cyh666666
2026-03-10 17:08:20 +08:00
parent 2262d1bfd9
commit 5517c93666
1010 changed files with 1688 additions and 4919 deletions

View File

@@ -1,5 +1,5 @@
import { AkReqUploadOptions, AkReqOptions, AkReqResponse, AkReqError } from './interface.uts';
import { SUPA_URL, IS_TEST_MODE } from '@/ak/config.uts';
import { SUPA_URL, SUPA_KEY, IS_TEST_MODE } from '@/ak/config.uts';
// token 持久化 key
const ACCESS_TOKEN_KEY = 'akreq_access_token';
@@ -71,14 +71,17 @@ export class AkReq {
return false;
}
// 构造 header必须带 apikey
let headers = {} as UTSJSONObject;
let headers = new UTSJSONObject();
if (apikey !== null && apikey !== "") {
headers = Object.assign({}, headers, { 'apikey': apikey }) as UTSJSONObject;
} try {
headers.set('apikey', apikey)
}
const reqData = new UTSJSONObject()
reqData.set('refresh_token', refreshToken)
try {
const res = await this.request({
url: SUPA_URL + '/auth/v1/token?grant_type=refresh_token',
method: 'POST',
data: ({ refresh_token: refreshToken } as UTSJSONObject),
data: reqData,
headers: headers,
contentType: 'application/json'
}, true); // skipRefresh=true避免递归
@@ -123,9 +126,9 @@ export class AkReq {
const originalHeaders = options.headers
if (typeof originalHeaders.getString === 'function') {
// 复制 apikey
const apikey = originalHeaders.getString('apikey')
if (apikey != null) {
newHeaders.set('apikey', apikey)
const apikeyStr = originalHeaders.getString('apikey')
if (apikeyStr != null) {
newHeaders.set('apikey', apikeyStr)
}
// 复制 Content-Type
const contentType = originalHeaders.getString('Content-Type')
@@ -144,6 +147,13 @@ export class AkReq {
}
}
}
// 补齐 apikey (如果 headers 中没有,则直接使用 SUPA_KEY 补全)
if (newHeaders.getString('apikey') == null) {
if (SUPA_KEY != null && SUPA_KEY != "") {
newHeaders.set('apikey', SUPA_KEY)
}
}
// 添加/更新 Authorization
const token = this.getToken();