11
This commit is contained in:
@@ -1,27 +1,35 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
|
||||
/**
|
||||
* 经 Rust 读取本地 oem 文件中的 ID,并请求公开品牌 API。
|
||||
* @returns {Promise<{
|
||||
* oemId: number,
|
||||
* softwareName: string,
|
||||
* logoUrl: string | null,
|
||||
* wechat: string | null,
|
||||
* wechatQrcode: string | null,
|
||||
* }>}
|
||||
*/
|
||||
export async function fetchSoftwareInfo() {
|
||||
const empty = {
|
||||
oemId: 1,
|
||||
softwareName: "",
|
||||
logoUrl: null,
|
||||
wechat: null,
|
||||
wechatQrcode: null,
|
||||
};
|
||||
try {
|
||||
const data = await invoke("get_software_info");
|
||||
if (!data || typeof data !== "object") {
|
||||
return { oemId: 1, softwareName: "", logoUrl: null, wechat: null };
|
||||
return empty;
|
||||
}
|
||||
return {
|
||||
oemId: data.oemId ?? 1,
|
||||
softwareName: data.softwareName ?? "",
|
||||
logoUrl: data.logoUrl || null,
|
||||
wechat: data.wechat || null,
|
||||
wechatQrcode: data.wechatQrcodeUrl || null,
|
||||
};
|
||||
} catch {
|
||||
return { oemId: 1, softwareName: "", logoUrl: null, wechat: null };
|
||||
return empty;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user