Skip to content

Commit

Permalink
🐞 fix: Fixed type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
imsyy committed Dec 7, 2024
1 parent 51f27af commit 4897239
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
7 changes: 2 additions & 5 deletions src/utils/getToken/51cto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ import md5 from "md5";

export const getToken = async () => {
const cachedData = await getCache("51cto-token");
if (cachedData && typeof cachedData === "object" && "token" in cachedData) {
const { token } = cachedData as { token: string };
return token;
}
if (cachedData?.data) return cachedData.data;
const result = await get({
url: "https://api-media.51cto.com/api/token-get",
});
const token = result.data.data.data.token;
await setCache("51cto-token", { token });
await setCache("51cto-token", { data: token, updateTime: new Date().toISOString() });
return token;
};

Expand Down
11 changes: 5 additions & 6 deletions src/utils/getToken/bilibili.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,16 @@ const getWbiKeys = async (): Promise<EncodedKeys> => {

const getBiliWbi = async (): Promise<string> => {
const cachedData = await getCache("bilibili-wbi");
console.log(cachedData);
if (cachedData && typeof cachedData === "object" && "wbi" in cachedData) {
const { wbi } = cachedData as { wbi: string };
return wbi;
}
if (cachedData?.data) return cachedData.data as string;
const web_keys = await getWbiKeys();
const params = { foo: "114", bar: "514", baz: 1919810 };
const img_key = web_keys.img_key;
const sub_key = web_keys.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;
};

Expand Down

0 comments on commit 4897239

Please sign in to comment.