feat: split DA and API layers by domain, add parallel route docs

This commit is contained in:
2026-08-10 01:56:09 +08:00
parent 68c5e8ee04
commit 0394da6771
38 changed files with 1156 additions and 437 deletions
+35
View File
@@ -0,0 +1,35 @@
import Taro from '@tarojs/taro'
/** 当前登录用户信息在 Storage 中的 key */
export const USER_KEY = 'smart_user_info'
/** 当前激活 openid 在 Storage 中的 key */
export const ACTIVE_USER_KEY = 'smart_active_openid'
/** 判断 openid 是否为历史版 mock 残留(形如 mock_xxx */
export function isMockOpenid(openid?: string | null): boolean {
return !!openid && (openid.startsWith('mock_') || openid.startsWith('mock-'))
}
/** 取当前用户 openid;没有登录态时回退 _guest_ 并缓存 */
function getActiveOpenid(): string {
let user: any = null
try {
user = Taro.getStorageSync(USER_KEY)
} catch {
user = null
}
const openid = user?.openid || Taro.getStorageSync(ACTIVE_USER_KEY) || '_guest_'
Taro.setStorageSync(ACTIVE_USER_KEY, openid)
return openid
}
/** 按当前用户生成作用域 storage key */
export function key(scope: string): string {
const prefix = getActiveOpenid()
return `${scope}_${prefix}`
}
/** 按指定 openid 生成作用域 storage key */
export function keyFor(scope: string, openid: string): string {
return `${scope}_${openid}`
}