diff --git a/web/src/App.tsx b/web/src/App.tsx
index d1e6ceeb..be3b0b35 100644
--- a/web/src/App.tsx
+++ b/web/src/App.tsx
@@ -83,15 +83,15 @@ export const App: React.FC = React.memo(() => {
-
-
-
-
-
-
- {/* 这个host用于处理独立页面的modal */}
- {/* NOTICE: Switch里不能出现动态路由 */}
-
+
+ {/* 这个host用于处理其他页面(非main)的modal */}
+
+
+
+
+
+
+ {/* NOTICE: Switch里不能出现动态路由 */}
{pluginRootRoute.map((r, i) => (
{
component={r.component}
/>
))}
-
-
-
-
+
+
+
+
);
diff --git a/web/src/components/modals/ServiceUrlSettings.tsx b/web/src/components/modals/ServiceUrlSettings.tsx
new file mode 100644
index 00000000..09236eae
--- /dev/null
+++ b/web/src/components/modals/ServiceUrlSettings.tsx
@@ -0,0 +1,42 @@
+import { Button, Input } from 'antd';
+import React, { useState } from 'react';
+import { t } from 'tailchat-shared';
+import { ModalWrapper } from '../Modal';
+
+export const ServiceUrlSettings: React.FC = React.memo(() => {
+ const [url, setUrl] = useState(
+ window.localStorage.getItem('serviceUrl') ?? ''
+ );
+
+ return (
+
+ setUrl(e.target.value)}
+ />
+
+
+
+
+
+
+ );
+});
+ServiceUrlSettings.displayName = 'ServiceUrlSettings';
diff --git a/web/src/init.tsx b/web/src/init.tsx
index 415089cc..df918290 100644
--- a/web/src/init.tsx
+++ b/web/src/init.tsx
@@ -33,8 +33,10 @@ setTokenGetter(async () => {
return await getUserJWT();
});
-if (window.localStorage.getItem('serviceUrl')) {
- setServiceUrl(() => String(window.localStorage.getItem('serviceUrl')));
+const localStorageServiceUrl = window.localStorage.getItem('serviceUrl');
+
+if (localStorageServiceUrl) {
+ setServiceUrl(() => localStorageServiceUrl);
} else if (process.env.SERVICE_URL) {
setServiceUrl(() => String(process.env.SERVICE_URL));
}
@@ -100,7 +102,8 @@ request
baseURL: '',
})
.then(({ data: config }) => {
- if (isValidStr(_get(config, 'serviceUrl'))) {
+ if (!localStorageServiceUrl && isValidStr(_get(config, 'serviceUrl'))) {
+ // 配置的优先级低于localStorage的优先级
setServiceUrl(() => _get(config, 'serviceUrl'));
}
})
diff --git a/web/src/routes/Entry/LoginView.tsx b/web/src/routes/Entry/LoginView.tsx
index a1cc50d6..6006e03c 100644
--- a/web/src/routes/Entry/LoginView.tsx
+++ b/web/src/routes/Entry/LoginView.tsx
@@ -9,6 +9,9 @@ import { setUserJWT } from '../../utils/jwt-helper';
import { setGlobalUserLoginInfo, tryAutoLogin } from '../../utils/user-helper';
import { useSearchParam } from '@/hooks/useSearchParam';
import { useNavToView } from './utils';
+import { IconBtn } from '@/components/IconBtn';
+import { openModal } from '@/components/Modal';
+import { ServiceUrlSettings } from '@/components/modals/ServiceUrlSettings';
/**
* TODO:
@@ -70,7 +73,7 @@ export const LoginView: React.FC = React.memo(() => {
const navToView = useNavToView();
return (
-
+
{t('登录 Tailchat')}
@@ -136,6 +139,14 @@ export const LoginView: React.FC = React.memo(() => {
+
+
+ openModal()}
+ />
+
);
});