mirror of
https://github.com/SECTL/SecScore.git
synced 2026-07-19 19:04:23 +08:00
refactor: 优化代码格式和OAuth请求处理
- 统一组件参数格式和换行风格 - 将OAuth请求参数从数组改为JSON格式 - 更新OAuth相关API的域名
This commit is contained in:
@@ -369,19 +369,19 @@ pub async fn oauth_exchange_code(
|
|||||||
|
|
||||||
let state_guard = state.read();
|
let state_guard = state.read();
|
||||||
let client = &state_guard.http_client;
|
let client = &state_guard.http_client;
|
||||||
let params = [
|
let payload = serde_json::json!({
|
||||||
("grant_type", "authorization_code"),
|
"grant_type": "authorization_code",
|
||||||
("code", &code),
|
"code": &code,
|
||||||
("client_id", &platform_id),
|
"client_id": &platform_id,
|
||||||
("client_secret", &platform_secret),
|
"client_secret": &platform_secret,
|
||||||
("redirect_uri", &callback_url),
|
"redirect_uri": &callback_url,
|
||||||
];
|
});
|
||||||
|
|
||||||
println!("[OAuth] 请求参数:{:?}", params);
|
println!("[OAuth] 请求参数:{:?}", payload);
|
||||||
|
|
||||||
let response = client
|
let response = client
|
||||||
.post("https://sectl.top/api/oauth/token")
|
.post("https://appwrite.sectl.top/api/oauth/token")
|
||||||
.form(¶ms)
|
.json(&payload)
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
.map_err(|e| format!("Request failed: {}", e))?;
|
.map_err(|e| format!("Request failed: {}", e))?;
|
||||||
@@ -426,7 +426,7 @@ pub async fn oauth_revoke_token(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let response = client
|
let response = client
|
||||||
.post("https://sectl.top/api/oauth/revoke")
|
.post("https://appwrite.sectl.top/api/oauth/revoke")
|
||||||
.json(&payload)
|
.json(&payload)
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
@@ -454,7 +454,7 @@ pub async fn oauth_introspect_token(
|
|||||||
let client = &state_guard.http_client;
|
let client = &state_guard.http_client;
|
||||||
|
|
||||||
let response = client
|
let response = client
|
||||||
.post("https://sectl.top/api/oauth/introspect")
|
.post("https://appwrite.sectl.top/api/oauth/introspect")
|
||||||
.json(&serde_json::json!({
|
.json(&serde_json::json!({
|
||||||
"token": token,
|
"token": token,
|
||||||
"client_id": platform_id,
|
"client_id": platform_id,
|
||||||
@@ -489,7 +489,7 @@ pub async fn oauth_get_user_info(
|
|||||||
let client = &state_guard.http_client;
|
let client = &state_guard.http_client;
|
||||||
|
|
||||||
let response = 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))
|
.header("Authorization", format!("Bearer {}", access_token))
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await
|
||||||
@@ -522,7 +522,7 @@ pub async fn oauth_refresh_token(
|
|||||||
let client = &state_guard.http_client;
|
let client = &state_guard.http_client;
|
||||||
|
|
||||||
let response = client
|
let response = client
|
||||||
.post("https://sectl.top/api/oauth/token")
|
.post("https://appwrite.sectl.top/api/oauth/token")
|
||||||
.json(&serde_json::json!({
|
.json(&serde_json::json!({
|
||||||
"grant_type": "refresh_token",
|
"grant_type": "refresh_token",
|
||||||
"refresh_token": refresh_token,
|
"refresh_token": refresh_token,
|
||||||
|
|||||||
@@ -549,7 +549,11 @@ export const normalizeActionDrafts = (drafts: ActionDraft[] | null | undefined):
|
|||||||
export const actionsToDrafts = (actions: AutoScoreAction[]): ActionDraft[] => {
|
export const actionsToDrafts = (actions: AutoScoreAction[]): ActionDraft[] => {
|
||||||
const mapped = actions
|
const mapped = actions
|
||||||
.map((action) => {
|
.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 null
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -27,11 +27,7 @@ const buildNextIntervalValue = (
|
|||||||
const getDisplayValue = (value: number | undefined, fallback = 0) =>
|
const getDisplayValue = (value: number | undefined, fallback = 0) =>
|
||||||
typeof value === "number" && Number.isFinite(value) ? value : fallback
|
typeof value === "number" && Number.isFinite(value) ? value : fallback
|
||||||
|
|
||||||
export const IntervalValueWidget: React.FC<WidgetProps> = ({
|
export const IntervalValueWidget: React.FC<WidgetProps> = ({ value, setValue, readonly }) => {
|
||||||
value,
|
|
||||||
setValue,
|
|
||||||
readonly,
|
|
||||||
}) => {
|
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const parsedValue = parseIntervalTriggerValue(value)
|
const parsedValue = parseIntervalTriggerValue(value)
|
||||||
|
|
||||||
|
|||||||
@@ -441,7 +441,7 @@ function AutoScoreManager({ canEdit }: AutoScoreManagerProps): React.JSX.Element
|
|||||||
} finally {
|
} finally {
|
||||||
setRollingBackBatchId(null)
|
setRollingBackBatchId(null)
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -620,7 +620,11 @@ function AutoScoreManager({ canEdit }: AutoScoreManagerProps): React.JSX.Element
|
|||||||
name="name"
|
name="name"
|
||||||
rules={[{ required: true, message: t("autoScore.nameRequired") }]}
|
rules={[{ required: true, message: t("autoScore.nameRequired") }]}
|
||||||
>
|
>
|
||||||
<Input placeholder={t("autoScore.namePlaceholder")} disabled={!canEdit} autoComplete="off"/>
|
<Input
|
||||||
|
placeholder={t("autoScore.namePlaceholder")}
|
||||||
|
disabled={!canEdit}
|
||||||
|
autoComplete="off"
|
||||||
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label={t("autoScore.applicableStudents")} name="studentNames">
|
<Form.Item label={t("autoScore.applicableStudents")} name="studentNames">
|
||||||
<Select
|
<Select
|
||||||
@@ -637,7 +641,10 @@ function AutoScoreManager({ canEdit }: AutoScoreManagerProps): React.JSX.Element
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: "12px" }}>
|
<div style={{ display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gap: "12px" }}>
|
||||||
<Form.Item label={t("autoScore.cooldownMinutes")} name={["execution", "cooldownMinutes"]}>
|
<Form.Item
|
||||||
|
label={t("autoScore.cooldownMinutes")}
|
||||||
|
name={["execution", "cooldownMinutes"]}
|
||||||
|
>
|
||||||
<InputNumber min={1} style={{ width: "100%" }} disabled={!canEdit} />
|
<InputNumber min={1} style={{ width: "100%" }} disabled={!canEdit} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label={t("autoScore.maxRunsPerDay")} name={["execution", "maxRunsPerDay"]}>
|
<Form.Item label={t("autoScore.maxRunsPerDay")} name={["execution", "maxRunsPerDay"]}>
|
||||||
|
|||||||
@@ -293,7 +293,9 @@ export const ScoreManager: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
|
|||||||
mode="multiple"
|
mode="multiple"
|
||||||
showSearch
|
showSearch
|
||||||
placeholder={t("score.pleaseSelectStudent")}
|
placeholder={t("score.pleaseSelectStudent")}
|
||||||
filterOption={(input, option) => matchStudentName(getOptionLabel(option), input)}
|
filterOption={(input, option) =>
|
||||||
|
matchStudentName(getOptionLabel(option), input)
|
||||||
|
}
|
||||||
options={students.map((s) => ({ label: s.name, value: s.name }))}
|
options={students.map((s) => ({ label: s.name, value: s.name }))}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|||||||
Reference in New Issue
Block a user