Skip to content

Commit

Permalink
chore: move api request to apis folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatpandac committed Sep 16, 2024
1 parent 5fb35bd commit 6554b59
Show file tree
Hide file tree
Showing 26 changed files with 45 additions and 39 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/utils/getConclsion.ts → src/apis/getConclsion.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import got from "got";
import { Cache } from "@raycast/api";
import { encWbi } from "./tools";
import { encWbi } from "../utils";
import { API } from "./api";

export async function getConclsion(bvid: string, cid: number, up_mid: number) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions src/apis/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export * from "./api";
export * from "./logout";
export * from "./getCid";
export * from "./getRcmd";
export * from "./checkLogin";
export * from "./getPlayUrl";
export * from "./checkQRCode";
export * from "./getConclsion";
export * from "./getVideoInfo";
export * from "./postHeartbeat";
export * from "./getDynamicFeed";
export * from "./gennerateQRCode";
export * from "./getSearchVideos";
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/components/conslusionView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Detail, List, showToast, Toast } from "@raycast/api";
import { useState, useEffect } from "react";
import { getCid, getConclsion } from "../utils";
import { getCid, getConclsion } from "../apis";

type Props = { bvid: string; cid: number; up_mid: number };
export function ConclusionView(props: Props) {
Expand Down
31 changes: 16 additions & 15 deletions src/dynamicFeed.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useDynamicFeed } from "./hooks";
import { checkLogin, formatUrl, getVideoInfo, postHeartbeat } from "./utils";
import { formatUrl } from "./utils";
import { checkLogin, getVideoInfo, postHeartbeat } from "./apis";
import { NoLoginView, Post, Video } from "./components";
import { List, showToast, Toast } from "@raycast/api";
import { useState } from "react";
Expand Down Expand Up @@ -88,21 +89,21 @@ export default function Command() {
markAsWatchedCallback={
last_play_time === 0
? async () => {
try {
const videoInfo = await getVideoInfo(aid);

await postHeartbeat(videoInfo.aid, videoInfo.cid);
if (!watchedList.includes(bvid)) setWatchedList([bvid, ...watchedList].slice(0, 200));

refetch({});
await showToast({ style: Toast.Style.Success, title: "Make as watched successfully" });
} catch {
await showToast({
style: Toast.Style.Failure,
title: "Make as watched failed, please retry later",
});
}
try {
const videoInfo = await getVideoInfo(aid);

await postHeartbeat(videoInfo.aid, videoInfo.cid);
if (!watchedList.includes(bvid)) setWatchedList([bvid, ...watchedList].slice(0, 200));

refetch({});
await showToast({ style: Toast.Style.Success, title: "Make as watched successfully" });
} catch {
await showToast({
style: Toast.Style.Failure,
title: "Make as watched failed, please retry later",
});
}
}
: undefined
}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useDynamicFeed.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getDynamicFeed, getPlayUrl, getVideoInfo } from "../utils";
import { getDynamicFeed, getPlayUrl, getVideoInfo } from "../apis";

import { useEffect, useState } from "react";
import { showToast, Toast } from "@raycast/api";
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useLogin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { checkLogin, checkQRCode, gennerateQRCode } from "../utils";
import { checkLogin, checkQRCode, gennerateQRCode } from "../apis";

import { useState, useEffect } from "react";
import { Cache, showToast, Toast } from "@raycast/api";
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useRcmdVideos.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getRcmd } from "../utils";
import { getRcmd } from "../apis";

import { useState, useEffect } from "react";
import { showToast, Toast } from "@raycast/api";
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useSearchVideos.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getSearchVideos } from "../utils";
import { getSearchVideos } from "../apis";

import { useState, useEffect } from "react";
import { showToast, Toast } from "@raycast/api";
Expand Down
2 changes: 1 addition & 1 deletion src/login.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { logout } from "./utils";
import { logout } from "./apis";
import { useLogin } from "./hooks";

import {
Expand Down
6 changes: 4 additions & 2 deletions src/notifications.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { formatUrl } from "./utils";
import { checkLogin, getDynamicFeed } from "./apis";

import { spawnSync } from "child_process";
import { runAppleScript } from "run-applescript";
import { checkLogin, formatUrl, getDynamicFeed } from "./utils";
import { getPreferenceValues, LocalStorage } from "@raycast/api";
import { spawnSync } from "child_process";

interface Preferences {
justNotifyVideos: boolean;
Expand Down
3 changes: 2 additions & 1 deletion src/rcmdVideos.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useRcmdVideos } from "./hooks";
import { NoLoginView, Video } from "./components";
import { checkLogin, formatNumber, secondToDate } from "./utils";
import { checkLogin } from "./apis";
import { formatNumber, secondToDate } from "./utils";

import { useState } from "react";
import { List } from "@raycast/api";
Expand Down
3 changes: 2 additions & 1 deletion src/searchVideos.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { NoLoginView, Video } from "./components";
import { checkLogin, formatNumber, removeEmHTMLTag } from "./utils";
import { checkLogin } from "./apis";
import {formatNumber, removeEmHTMLTag} from "./utils";
import { useState } from "react";
import { useSearchVideos } from "./hooks";
import { List } from "@raycast/api";
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ declare global {
like_num: number;
model_result: ModelResult;
}

export interface VideoConclusionResponse extends Omit<BaseResponse, "data"> {
data: VideoConclusionResponseData;
}
Expand Down
13 changes: 0 additions & 13 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1 @@
export * from "./api";
export * from "./tools";
export * from "./logout";
export * from "./getCid";
export * from "./getRcmd";
export * from "./checkLogin";
export * from "./getPlayUrl";
export * from "./checkQRCode";
export * from "./getConclsion";
export * from "./getVideoInfo";
export * from "./postHeartbeat";
export * from "./getDynamicFeed";
export * from "./gennerateQRCode";
export * from "./getSearchVideos";

0 comments on commit 6554b59

Please sign in to comment.