feat: light app center and iframe refactor
This commit is contained in:
1 parent
728a4b1170
commit
9d73f27146
35 files changed
+1878
-246
No files matched your search
@@ -27,6 +27,50 @@ export function getNetworkActorIframeUrl(): string {
|
||||
return `${base}${path.startsWith("/") ? path : `/${path}`}`;
|
||||
}
|
||||
|
||||
/** 读取并解析 localStorage 中的 userInfo(登录信息)。 */
|
||||
function readUserInfo(): Record<string, unknown> {
|
||||
try {
|
||||
const raw = localStorage.getItem("userInfo");
|
||||
if (!raw) return {};
|
||||
const parsed = JSON.parse(raw);
|
||||
return parsed && typeof parsed === "object" ? (parsed as Record<string, unknown>) : {};
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
/** 当前登录态 accessToken(无则空串)。 */
|
||||
export function getAccessToken(): string {
|
||||
const value = readUserInfo().accessToken;
|
||||
return value == null ? "" : String(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* XK 中任务 iframe 地址。
|
||||
*
|
||||
* 形如 `{base}{gopath}?accessToken={token}`,其中 gopath 含 hash 路由
|
||||
* (如 `#/pageIndie/pageHome/pageSwrw`)—— 每次都从 base 重建,切换 gopath 不累加。
|
||||
*/
|
||||
export function getXkIframeUrl(gopath: string): string {
|
||||
const base = readEnv("VITE_AIPI_XKLINKTO_URL");
|
||||
if (!base) return "";
|
||||
return `${base}${gopath}?accessToken=${getAccessToken()}`;
|
||||
}
|
||||
|
||||
/** PG 中任务 iframe 地址:`{base}?access_token={token}&goPath={gopath}`。 */
|
||||
export function getPgIframeUrl(gopath: string): string {
|
||||
const base = readEnv("VITE_AIPI_PGLINKTO_URL");
|
||||
if (!base) return "";
|
||||
return `${base}?access_token=${getAccessToken()}&goPath=${gopath}`;
|
||||
}
|
||||
|
||||
/** TY 中任务 iframe 地址:`{base}/fromB/toPage?defaultPage={defaultPage}`。 */
|
||||
export function getTyIframeUrl(defaultPage: string): string {
|
||||
const base = trimTrailingSlash(readEnv("VITE_AIPI_B2ACTOR_URL"));
|
||||
if (!base) return "";
|
||||
return `${base}/fromB/toPage?defaultPage=${defaultPage}`;
|
||||
}
|
||||
|
||||
/** 知识库 iframe 地址换取 API */
|
||||
export function getKnowledgeIframeApiUrl(): string {
|
||||
return readEnv("VITE_AIPI_KNOWLEDGE_IFRAME_API_URL");
|
||||
|
||||
Reference in new issue
Block a user