diff --git a/.env.development b/.env.development
index 92ef92f..0c1ca3c 100644
--- a/.env.development
+++ b/.env.development
@@ -1,4 +1,5 @@
VITE_PLATFORM=WEB
+VITE_UI_URL=${DEV_UI_URL}
VITE_API_URL=${DEV_API_URL}
VITE_API_TOKEN_URL=${VITE_API_URL}/token
VITE_TURNSTILE_SITE_KEY=${TURNSTILE_SITE_KEY}
diff --git a/.env.production b/.env.production
index ef7c119..528d73a 100644
--- a/.env.production
+++ b/.env.production
@@ -1,4 +1,5 @@
VITE_PLATFORM=WEB
+VITE_UI_URL=${PRODUCT_UI_URL}
VITE_API_URL=${PRODUCT_API_URL}
VITE_API_TOKEN_URL=${VITE_API_URL}/token
VITE_TURNSTILE_SITE_KEY=${TURNSTILE_SITE_KEY}
diff --git a/.env.testing b/.env.testing
index 1b6606e..b5fb949 100644
--- a/.env.testing
+++ b/.env.testing
@@ -1,5 +1,6 @@
NODE_ENV=development
VITE_PLATFORM=WEB
+VITE_UI_URL=${TEST_UI_URL}
VITE_API_URL=${TEST_API_URL}
VITE_API_TOKEN_URL=${VITE_API_URL}/token
VITE_TURNSTILE_SITE_KEY=${TURNSTILE_SITE_KEY}
diff --git a/src/assets/css/pages/user/index.scss b/src/assets/css/pages/user/index.scss
index 6bcce1d..1b1bce0 100644
--- a/src/assets/css/pages/user/index.scss
+++ b/src/assets/css/pages/user/index.scss
@@ -70,6 +70,8 @@
}
.url {
+ cursor: pointer;
+
> span {
margin-left: 8px;
}
diff --git a/src/global.d.ts b/src/global.d.ts
index 41b47cc..5bcfef7 100644
--- a/src/global.d.ts
+++ b/src/global.d.ts
@@ -5,6 +5,7 @@ type Platform = 'WEB' | 'DESKTOP' | 'ANDROID'
interface ImportMetaEnv {
readonly VITE_PLATFORM: Platform
+ readonly VITE_UI_URL: string
readonly VITE_API_URL: string
readonly VITE_API_TOKEN_URL: string
readonly VITE_TURNSTILE_SITE_KEY: string
diff --git a/src/pages/Tools/User.tsx b/src/pages/Tools/User.tsx
index 4fb4cd1..4e33762 100644
--- a/src/pages/Tools/User.tsx
+++ b/src/pages/Tools/User.tsx
@@ -30,7 +30,7 @@ const User = () => {
return username
? () => {
void navigator.clipboard
- .writeText(new URL(`/store/${username}`, location.href).href)
+ .writeText(new URL(`/store/${username}`, import.meta.env.VITE_UI_URL).href)
.then(() => {
void message.success('已复制到剪切板')
})
@@ -153,8 +153,10 @@ const User = () => {
onClick={handleOnCopyToClipboard(userWithInfoVo?.username)}
>
{userWithInfoVo?.username &&
- new URL(`/store/${userWithInfoVo.username}`, location.href)
- .href}
+ new URL(
+ `/store/${userWithInfoVo.username}`,
+ import.meta.env.VITE_UI_URL
+ ).href}
diff --git a/src/pages/User/index.tsx b/src/pages/User/index.tsx
index b4415be..f470ff4 100644
--- a/src/pages/User/index.tsx
+++ b/src/pages/User/index.tsx
@@ -39,6 +39,18 @@ const User = () => {
const [userWithPowerInfoVo, setUserWithPowerInfoVo] = useState()
const [changePasswordForm] = AntdForm.useForm()
+ const handleOnCopyToClipboard = (username?: string) => {
+ return username
+ ? () => {
+ void navigator.clipboard
+ .writeText(new URL(`/store/${username}`, import.meta.env.VITE_UI_URL).href)
+ .then(() => {
+ void message.success('已复制到剪切板')
+ })
+ }
+ : undefined
+ }
+
const handleOnReset = () => {
getProfile()
}
@@ -474,20 +486,14 @@ const User = () => {
{userWithPowerInfoVo?.username &&
new URL(
`/store/${userWithPowerInfoVo.username}`,
- location.href
+ import.meta.env.VITE_UI_URL
).href}
-
+