From 48453314270428d3822c8b54050fecf3de6caab1 Mon Sep 17 00:00:00 2001 From: shengsuan-cloud Date: Mon, 19 Jan 2026 15:49:38 +0800 Subject: [PATCH] ... --- package.json | 2 +- src/services/account/SSYAccountService.ts | 5 +++-- webview-ui/src/components/chat/ErrorRow.tsx | 4 ++-- .../src/context/ShengSuanYunAuthContext.tsx | 17 +++++++++++++++++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 2c2952da..ac1f922d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "cline-shengsuan", "displayName": "Cline 中文版", "description": "Cline 中文汉化版,由胜算云进行汉化,打造国内版的OpenRouter,让中国开发者更方便进行 AI 编程。", - "version": "3.46.5", + "version": "3.46.6", "icon": "assets/icons/icon.png", "engines": { "vscode": "^1.84.0" diff --git a/src/services/account/SSYAccountService.ts b/src/services/account/SSYAccountService.ts index 3cd1284e..662c027f 100644 --- a/src/services/account/SSYAccountService.ts +++ b/src/services/account/SSYAccountService.ts @@ -11,15 +11,16 @@ export class SSYAccountService { private async authenticatedRequest(endpoint: string, config: AxiosRequestConfig = {}): Promise { const ssyApiKey = await this.getSSYApiKey() if (!ssyApiKey) { - throw new Error("未找到胜算云 Auth API") + throw new Error("未找到胜算云 Auth API Key") } const reqConfig: AxiosRequestConfig = { ...config, headers: { + ...config.headers, "x-token": ssyApiKey, "Content-Type": "application/json", - ...config.headers, }, + timeout: 20000, } const url = `${this.baseUrl}${endpoint}` // console.log("SSYAccountService.authenticatedRequest():", url, reqConfig) diff --git a/webview-ui/src/components/chat/ErrorRow.tsx b/webview-ui/src/components/chat/ErrorRow.tsx index f1dcc597..5db5814c 100644 --- a/webview-ui/src/components/chat/ErrorRow.tsx +++ b/webview-ui/src/components/chat/ErrorRow.tsx @@ -2,8 +2,8 @@ import { ClineMessage } from "@shared/ExtensionMessage" import { VSCodeButton } from "@vscode/webview-ui-toolkit/react" import { memo } from "react" import CreditLimitErrorSSY from "@/components/chat/CreditLimitErrorSSY" -import { useClineSignIn } from "@/context/ClineAuthContext" import { useExtensionState } from "@/context/ExtensionStateContext" +import { useSignIn } from "@/context/ShengSuanYunAuthContext" import { SSYError, SSYErrorType } from "../../../../src/services/error/SSYError" // const _errorColor = "var(--vscode-errorForeground)" @@ -18,7 +18,7 @@ interface ErrorRowProps { const ErrorRow = memo(({ message, errorType, apiRequestFailedMessage, apiReqStreamingFailedMessage }: ErrorRowProps) => { const { userInfo } = useExtensionState() const rawApiError = apiRequestFailedMessage || apiReqStreamingFailedMessage - const { isLoginLoading, handleSignIn } = useClineSignIn() + const { isLoginLoading, handleSignIn } = useSignIn() const renderErrorContent = () => { switch (errorType) { diff --git a/webview-ui/src/context/ShengSuanYunAuthContext.tsx b/webview-ui/src/context/ShengSuanYunAuthContext.tsx index 692b0d12..eefb1985 100644 --- a/webview-ui/src/context/ShengSuanYunAuthContext.tsx +++ b/webview-ui/src/context/ShengSuanYunAuthContext.tsx @@ -110,3 +110,20 @@ export const useShengSuanYunAuth = () => { } return context } + +export const useSignIn = () => { + const [isLoading, setIsLoading] = useState(false) + const handleSignIn = useCallback(() => { + try { + setIsLoading(true) + AccountServiceClient.shengSuanYunLoginClicked(EmptyRequest.create()) + .catch((err) => console.error("Failed to get login URL:", err)) + .finally(() => { + setIsLoading(false) + }) + } catch (error) { + console.error("Error signing in:", error) + } + }, []) + return { isLoginLoading: isLoading, handleSignIn } +}