From 498af7a09cb32d69db455f98fd415daf55c99c9f Mon Sep 17 00:00:00 2001 From: Yukino_fox Date: Sat, 11 Apr 2026 13:35:46 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=A0=BC=E5=BC=8F=E5=92=8COAuth=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 统一组件参数格式和换行风格 - 将OAuth请求参数从数组改为JSON格式 - 更新OAuth相关API的域名 --- src-tauri/src/commands/auth.rs | 28 +++++++++---------- src/components/AutoScore/AutoScoreUtils.ts | 6 +++- .../AutoScore/IntervalValueWidget.tsx | 6 +--- src/components/AutoScoreManager.tsx | 13 +++++++-- src/components/ScoreManager.tsx | 4 ++- 5 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src-tauri/src/commands/auth.rs b/src-tauri/src/commands/auth.rs index 95741fd..f054240 100644 --- a/src-tauri/src/commands/auth.rs +++ b/src-tauri/src/commands/auth.rs @@ -369,19 +369,19 @@ pub async fn oauth_exchange_code( let state_guard = state.read(); let client = &state_guard.http_client; - let params = [ - ("grant_type", "authorization_code"), - ("code", &code), - ("client_id", &platform_id), - ("client_secret", &platform_secret), - ("redirect_uri", &callback_url), - ]; + let payload = serde_json::json!({ + "grant_type": "authorization_code", + "code": &code, + "client_id": &platform_id, + "client_secret": &platform_secret, + "redirect_uri": &callback_url, + }); - println!("[OAuth] 请求参数:{:?}", params); + println!("[OAuth] 请求参数:{:?}", payload); let response = client - .post("https://sectl.top/api/oauth/token") - .form(¶ms) + .post("https://appwrite.sectl.top/api/oauth/token") + .json(&payload) .send() .await .map_err(|e| format!("Request failed: {}", e))?; @@ -426,7 +426,7 @@ pub async fn oauth_revoke_token( } let response = client - .post("https://sectl.top/api/oauth/revoke") + .post("https://appwrite.sectl.top/api/oauth/revoke") .json(&payload) .send() .await @@ -454,7 +454,7 @@ pub async fn oauth_introspect_token( let client = &state_guard.http_client; let response = client - .post("https://sectl.top/api/oauth/introspect") + .post("https://appwrite.sectl.top/api/oauth/introspect") .json(&serde_json::json!({ "token": token, "client_id": platform_id, @@ -489,7 +489,7 @@ pub async fn oauth_get_user_info( let client = &state_guard.http_client; let response = client - .get("https://sectl.top/api/oauth/userinfo") + .get("https://appwrite.sectl.top/api/oauth/userinfo") .header("Authorization", format!("Bearer {}", access_token)) .send() .await @@ -522,7 +522,7 @@ pub async fn oauth_refresh_token( let client = &state_guard.http_client; let response = client - .post("https://sectl.top/api/oauth/token") + .post("https://appwrite.sectl.top/api/oauth/token") .json(&serde_json::json!({ "grant_type": "refresh_token", "refresh_token": refresh_token, diff --git a/src/components/AutoScore/AutoScoreUtils.ts b/src/components/AutoScore/AutoScoreUtils.ts index efc45be..44bc56d 100644 --- a/src/components/AutoScore/AutoScoreUtils.ts +++ b/src/components/AutoScore/AutoScoreUtils.ts @@ -549,7 +549,11 @@ export const normalizeActionDrafts = (drafts: ActionDraft[] | null | undefined): export const actionsToDrafts = (actions: AutoScoreAction[]): ActionDraft[] => { const mapped = actions .map((action) => { - if (action.event !== "add_score" && action.event !== "add_tag" && action.event !== "settle_score") { + if ( + action.event !== "add_score" && + action.event !== "add_tag" && + action.event !== "settle_score" + ) { return null } return { diff --git a/src/components/AutoScore/IntervalValueWidget.tsx b/src/components/AutoScore/IntervalValueWidget.tsx index 76d82f2..65c08c3 100644 --- a/src/components/AutoScore/IntervalValueWidget.tsx +++ b/src/components/AutoScore/IntervalValueWidget.tsx @@ -27,11 +27,7 @@ const buildNextIntervalValue = ( const getDisplayValue = (value: number | undefined, fallback = 0) => typeof value === "number" && Number.isFinite(value) ? value : fallback -export const IntervalValueWidget: React.FC = ({ - value, - setValue, - readonly, -}) => { +export const IntervalValueWidget: React.FC = ({ value, setValue, readonly }) => { const { t } = useTranslation() const parsedValue = parseIntervalTriggerValue(value) diff --git a/src/components/AutoScoreManager.tsx b/src/components/AutoScoreManager.tsx index 76b81d3..75ac4b0 100644 --- a/src/components/AutoScoreManager.tsx +++ b/src/components/AutoScoreManager.tsx @@ -441,7 +441,7 @@ function AutoScoreManager({ canEdit }: AutoScoreManagerProps): React.JSX.Element } finally { setRollingBackBatchId(null) } - } + }, }) } @@ -620,7 +620,11 @@ function AutoScoreManager({ canEdit }: AutoScoreManagerProps): React.JSX.Element name="name" rules={[{ required: true, message: t("autoScore.nameRequired") }]} > - +