mirror of
https://github.com/imsyy/DailyHotApi.git
synced 2026-01-12 05:04:56 +08:00
🐞 fix: Fixed type errors
This commit is contained in:
@@ -4,15 +4,12 @@ import md5 from "md5";
|
|||||||
|
|
||||||
export const getToken = async () => {
|
export const getToken = async () => {
|
||||||
const cachedData = await getCache("51cto-token");
|
const cachedData = await getCache("51cto-token");
|
||||||
if (cachedData && typeof cachedData === "object" && "token" in cachedData) {
|
if (cachedData?.data) return cachedData.data;
|
||||||
const { token } = cachedData as { token: string };
|
|
||||||
return token;
|
|
||||||
}
|
|
||||||
const result = await get({
|
const result = await get({
|
||||||
url: "https://api-media.51cto.com/api/token-get",
|
url: "https://api-media.51cto.com/api/token-get",
|
||||||
});
|
});
|
||||||
const token = result.data.data.data.token;
|
const token = result.data.data.data.token;
|
||||||
await setCache("51cto-token", { token });
|
await setCache("51cto-token", { data: token, updateTime: new Date().toISOString() });
|
||||||
return token;
|
return token;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -68,17 +68,16 @@ const getWbiKeys = async (): Promise<EncodedKeys> => {
|
|||||||
|
|
||||||
const getBiliWbi = async (): Promise<string> => {
|
const getBiliWbi = async (): Promise<string> => {
|
||||||
const cachedData = await getCache("bilibili-wbi");
|
const cachedData = await getCache("bilibili-wbi");
|
||||||
console.log(cachedData);
|
if (cachedData?.data) return cachedData.data as string;
|
||||||
if (cachedData && typeof cachedData === "object" && "wbi" in cachedData) {
|
|
||||||
const { wbi } = cachedData as { wbi: string };
|
|
||||||
return wbi;
|
|
||||||
}
|
|
||||||
const web_keys = await getWbiKeys();
|
const web_keys = await getWbiKeys();
|
||||||
const params = { foo: "114", bar: "514", baz: 1919810 };
|
const params = { foo: "114", bar: "514", baz: 1919810 };
|
||||||
const img_key = web_keys.img_key;
|
const img_key = web_keys.img_key;
|
||||||
const sub_key = web_keys.sub_key;
|
const sub_key = web_keys.sub_key;
|
||||||
const query = encWbi(params, img_key, sub_key);
|
const query = encWbi(params, img_key, sub_key);
|
||||||
await setCache("bilibili-wbi", { wbi: query });
|
await setCache("bilibili-wbi", {
|
||||||
|
data: query,
|
||||||
|
updateTime: new Date().toISOString(),
|
||||||
|
});
|
||||||
return query;
|
return query;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user