diff --git a/src/api/api.ts b/src/api/api.ts index 4c9e6b6..6b51824 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -25,7 +25,7 @@ let lastestRefreshTokenAt = 0 export async function fetcher(method: FetcherMethod, path: string, data?: any): Promise { let response - if (method === FetcherMethod.GET || method === FetcherMethod.DELETE) { + if (method === FetcherMethod.GET || method === FetcherMethod.DELETE) { response = await fetch(buildUrl(path, data), { method: "GET", }) diff --git a/src/api/oauth2.ts b/src/api/oauth2.ts index 6289b39..89dedc8 100644 --- a/src/api/oauth2.ts +++ b/src/api/oauth2.ts @@ -7,27 +7,45 @@ export enum Oauth2RequestType { BIND = 2, } -export const getOauth2RedirectURL = async (provider: string, rType: Oauth2RequestType): Promise => { +export const getOauth2RedirectURL = async ( + provider: string, + rType: Oauth2RequestType, +): Promise => { + const sType = "type" return fetcher(FetcherMethod.GET, `/api/v1/oauth2/${provider}`, { - "type": rType, + sType: rType, }) } - -export const bindOauth2 = async (provider: string, state: string, code: string): Promise => { - return fetcher(FetcherMethod.POST, `/api/v1/oauth2/${provider}/bind`, { - "state": state, - "code": code, - }) +export const bindOauth2 = async ( + provider: string, + state: string, + code: string, +): Promise => { + return fetcher( + FetcherMethod.POST, + `/api/v1/oauth2/${provider}/bind`, + { + state: state, + code: code, + }, + ) } export const unbindOauth2 = async (provider: string): Promise => { - return fetcher(FetcherMethod.POST, `/api/v1/oauth2/${provider}/unbind`) + return fetcher( + FetcherMethod.POST, + `/api/v1/oauth2/${provider}/unbind`, + ) } - -export const oauth2callback = async (provider: string, state: string, code: string): Promise => { +export const oauth2callback = async ( + provider: string, + state: string, + code: string, +): Promise => { return fetcher(FetcherMethod.POST, `/api/v1/oauth2/${provider}/callback`, { - state, code + state, + code, }) } diff --git a/src/components/fm.tsx b/src/components/fm.tsx index 4b3e7a8..bdb02c0 100644 --- a/src/components/fm.tsx +++ b/src/components/fm.tsx @@ -41,6 +41,7 @@ import { HTMLAttributes, useEffect, useRef, useState } from "react" import { useTranslation } from "react-i18next" import { toast } from "sonner" +import { Button } from "./ui/button" import { TableCell, TableRow } from "./ui/table" import { Filepath } from "./xui/filepath" import { IconButton } from "./xui/icon-button" @@ -102,7 +103,7 @@ const FMComponent: React.FC = ({ wsUrl, header: () => {t("Actions")}, id: "download", cell: ({ row }) => { - return ( + return row.original.type == 0 ? ( = ({ wsUrl, downloadFile(row.original.name) }} /> + ) : ( + - )} + ))} ) diff --git a/src/routes/profile.tsx b/src/routes/profile.tsx index f8936e3..6d62616 100644 --- a/src/routes/profile.tsx +++ b/src/routes/profile.tsx @@ -1,4 +1,4 @@ -import { bindOauth2, getOauth2RedirectURL, Oauth2RequestType, unbindOauth2 } from "@/api/oauth2" +import { Oauth2RequestType, bindOauth2, getOauth2RedirectURL, unbindOauth2 } from "@/api/oauth2" import { getProfile } from "@/api/user" import { ProfileCard } from "@/components/profile" import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" @@ -31,7 +31,8 @@ export default function ProfilePage() { getProfile().then((profile) => { setProfile(profile) }) - }).finally(() => { + }) + .finally(() => { window.history.replaceState({}, document.title, window.location.pathname) }) } @@ -116,12 +117,20 @@ export default function ProfilePage() { - {settingData?.config?.oauth2_providers?.map((provider) =>
- {provider}: {profile.oauth2_bind?.[provider.toLowerCase()]} {profile.oauth2_bind?.[provider.toLowerCase()] ? - - : - } -
)} + {settingData?.config?.oauth2_providers?.map((provider) => ( +
+ {provider}: {profile.oauth2_bind?.[provider.toLowerCase()]}{" "} + {profile.oauth2_bind?.[provider.toLowerCase()] ? ( + + ) : ( + + )} +
+ ))}
diff --git a/src/routes/settings.tsx b/src/routes/settings.tsx index 8d27ca3..50e3a34 100644 --- a/src/routes/settings.tsx +++ b/src/routes/settings.tsx @@ -67,21 +67,21 @@ export default function SettingsPage() { resolver: zodResolver(settingFormSchema), defaultValues: config ? { - ...config, - language: config?.config?.language, - site_name: config.config?.site_name || "", - user_template: - config.config?.user_template || - Object.keys(config.frontend_templates?.filter((t) => !t.is_admin) || {})[0] || - "user-dist", - } + ...config, + language: config?.config?.language, + site_name: config.config?.site_name || "", + user_template: + config.config?.user_template || + Object.keys(config.frontend_templates?.filter((t) => !t.is_admin) || {})[0] || + "user-dist", + } : { - ip_change_notification_group_id: 0, - cover: 1, - site_name: "", - language: "", - user_template: "user-dist", - }, + ip_change_notification_group_id: 0, + cover: 1, + site_name: "", + language: "", + user_template: "user-dist", + }, resetOptions: { keepDefaultValues: false, }, @@ -229,15 +229,15 @@ export default function SettingsPage() { {!config?.frontend_templates?.find( (t) => t.path === field.value, )?.is_official && ( -
-
- {t("CommunityThemeWarning")} -
-
- {t("CommunityThemeDescription")} -
+
+
+ {t("CommunityThemeWarning")}
- )} +
+ {t("CommunityThemeDescription")} +
+
+ )} )} /> diff --git a/src/types/api.ts b/src/types/api.ts index 2899ec1..16359d5 100644 --- a/src/types/api.ts +++ b/src/types/api.ts @@ -1,14 +1,14 @@ -/* eslint-disable */ -/* tslint:disable */ -/* - * --------------------------------------------------------------- - * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## - * ## ## - * ## AUTHOR: acacode ## - * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## - * --------------------------------------------------------------- - */ - +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + export interface GithubComNezhahqNezhaModelCommonResponseAny { data?: any error?: string