File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -835,17 +835,19 @@ export class PawSQLTreeProvider
835835 email : string ;
836836 password : string ;
837837 backendUrl : string ;
838- frontendUrl : string ;
839838 } ) {
840- const apiKey = await ApiService . getUserKey ( config . email , config . password ) ;
841- console . log ( apiKey ) ;
842- if ( ! apiKey ) {
839+ const result = await ApiService . getUserKey ( config . email , config . password ) ;
840+ if ( ! result ) {
843841 throw Error ( "error.login.invalidCredentials" ) ;
844842 }
843+ const { apikey, frontendUrl } = result ;
844+
845845 await vscode . workspace
846846 . getConfiguration ( "pawsql" )
847- . update ( "apiKey " , apiKey , true ) ;
847+ . update ( "frontendUrl " , frontendUrl , true ) ;
848848
849- return apiKey ;
849+ await vscode . workspace
850+ . getConfiguration ( "pawsql" )
851+ . update ( "apiKey" , apikey , true ) ;
850852 }
851853}
Original file line number Diff line number Diff line change @@ -312,7 +312,7 @@ export const validateUserKey = async (userKey: string): Promise<boolean> => {
312312export const getUserKey = async (
313313 email : string ,
314314 password : string
315- ) : Promise < string | null > => {
315+ ) : Promise < { apikey : string ; frontendUrl : string } | null > => {
316316 const { DOMAIN } = getUrls ( ) ;
317317 const url = `${ DOMAIN . Backend } /api/v1/getUserKey` ;
318318
Original file line number Diff line number Diff line change @@ -19,7 +19,6 @@ interface Config {
1919 email : string ;
2020 password : string ;
2121 backendUrl : string ;
22- frontendUrl : string ;
2322}
2423
2524interface ConfigFormProps {
@@ -59,24 +58,6 @@ const ConfigForm: React.FC<ConfigFormProps> = ({
5958 const handleSubmit = ( event : React . FormEvent ) => {
6059 event . preventDefault ( ) ;
6160
62- if ( ! formState . email || ! formState . password ) {
63- setSnackbarMessage (
64- formatMessage ( { id : "form.config.validation.credentials.required" } )
65- ) ;
66- setSnackbarSeverity ( "error" ) ;
67- setSnackbarOpen ( true ) ;
68- return ;
69- }
70-
71- if ( ! formState . backendUrl || ! formState . frontendUrl ) {
72- setSnackbarMessage (
73- formatMessage ( { id : "form.config.validation.urls.required" } )
74- ) ;
75- setSnackbarSeverity ( "error" ) ;
76- setSnackbarOpen ( true ) ;
77- return ;
78- }
79-
8061 onSubmit ( formState ) ;
8162 setSnackbarMessage (
8263 formatMessage ( { id : "webview.settings.save.config.success" } )
@@ -193,23 +174,6 @@ const ConfigForm: React.FC<ConfigFormProps> = ({
193174 } }
194175 sx = { { mb : 2 } }
195176 />
196- < TextField
197- fullWidth
198- name = "frontendUrl"
199- label = { formatMessage ( { id : "form.config.frontendUrl.label" } ) }
200- variant = "outlined"
201- margin = "normal"
202- value = { formState . frontendUrl }
203- onChange = { handleInputChange }
204- InputProps = { {
205- startAdornment : (
206- < InputAdornment position = "start" >
207- < LinkIcon sx = { { color : "#666" } } />
208- </ InputAdornment >
209- ) ,
210- } }
211- sx = { { mb : 3 } }
212- />
213177 < Button
214178 type = "submit"
215179 variant = "contained"
Original file line number Diff line number Diff line change @@ -19,15 +19,13 @@ interface Config {
1919 email : string ;
2020 password : string ;
2121 backendUrl : string ;
22- frontendUrl : string ;
2322}
2423
2524const App : React . FC = ( ) => {
2625 const [ config , setConfig ] = React . useState < Config > ( {
2726 email : "" ,
2827 password : "" ,
2928 backendUrl : "" ,
30- frontendUrl : "" ,
3129 } ) ;
3230
3331 const [ locale , setLocale ] = React . useState < "en" | "zh-cn" > ( "en" ) ; // 使用字面量类型
@@ -56,7 +54,6 @@ const App: React.FC = () => {
5654 email : message . email || "" ,
5755 password : message . password || "" ,
5856 backendUrl : message . backendUrl || "" ,
59- frontendUrl : message . frontendUrl || "" ,
6057 } ;
6158 console . log ( "Updating config:" , newConfig ) ;
6259 setConfig ( newConfig ) ;
Original file line number Diff line number Diff line change @@ -114,8 +114,6 @@ export class WebviewProvider {
114114 password : await this . passwordManager . getPassword ( ) ,
115115 backendUrl :
116116 vscode . workspace . getConfiguration ( "pawsql" ) . get ( "backendUrl" ) || "" ,
117- frontendUrl :
118- vscode . workspace . getConfiguration ( "pawsql" ) . get ( "frontendUrl" ) || "" ,
119117 } ;
120118
121119 panel . webview . postMessage ( { command : "configResponse" , ...config } ) ;
@@ -126,7 +124,6 @@ export class WebviewProvider {
126124 email : string ;
127125 password : string ;
128126 backendUrl : string ;
129- frontendUrl : string ;
130127 } ) {
131128 try {
132129 // 分别更新每个配置项
@@ -143,9 +140,7 @@ export class WebviewProvider {
143140 await vscode . workspace
144141 . getConfiguration ( "pawsql" )
145142 . update ( "backendUrl" , config . backendUrl , true ) ;
146- await vscode . workspace
147- . getConfiguration ( "pawsql" )
148- . update ( "frontendUrl" , config . frontendUrl , true ) ;
143+
149144 await this . treeProvider . updateApikey ( config ) ;
150145 await this . treeProvider . refresh ( ) ;
151146 // 配置保存成功反馈
You can’t perform that action at this time.
0 commit comments