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/components/Playground/Output/Preview/iframe.html b/src/components/Playground/Output/Preview/iframe.html
index db6655a..5aae2e3 100644
--- a/src/components/Playground/Output/Preview/iframe.html
+++ b/src/components/Playground/Output/Preview/iframe.html
@@ -11,7 +11,7 @@
window.addEventListener("message", ({ data }) => {
if (data?.type === "UPDATE") {
// Record old styles that need to be removed
- const appStyleElement = document.querySelectorAll("style[id^=\"style_\"]") || [];
+ const appStyleElement = document.querySelectorAll("style:not(style[id$=\"_oxygen_base_style.css\"])") || [];
// Remove old app
const appSrcElement = document.querySelector("#appSrc");
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/System/Tools/Base.tsx b/src/pages/System/Tools/Base.tsx
index 40f44b7..46a313d 100644
--- a/src/pages/System/Tools/Base.tsx
+++ b/src/pages/System/Tools/Base.tsx
@@ -637,8 +637,10 @@ const Base = () => {
rules={[
{ required: true },
{
- pattern: /\.(jsx|tsx|js|ts|css|json)$/,
- message: '仅支持 *.jsx, *.tsx, *.js, *.ts, *.css, *.json 文件'
+ pattern:
+ /(\.jsx|\.tsx|\.js|\.ts|_oxygen_base_style\.css|\.json)$/,
+ message:
+ '仅支持 *.jsx, *.tsx, *.js, *.ts, *_oxygen_base_style.css, *.json 文件'
},
({ getFieldValue }) => ({
validator() {
@@ -829,9 +831,10 @@ const Base = () => {
rules={[
{ required: true },
{
- pattern: /\.(jsx|tsx|js|ts|css|json)$/,
+ pattern:
+ /(\.jsx|\.tsx|\.js|\.ts|_oxygen_base_style\.css|\.json)$/,
message:
- '仅支持 *.jsx, *.tsx, *.js, *.ts, *.css, *.json 文件'
+ '仅支持 *.jsx, *.tsx, *.js, *.ts, *_oxygen_base_style.css, *.json 文件'
},
({ getFieldValue }) => ({
validator() {
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}
-
+
diff --git a/src/util/navigation.ts b/src/util/navigation.ts
index 19da234..140215a 100644
--- a/src/util/navigation.ts
+++ b/src/util/navigation.ts
@@ -37,15 +37,15 @@ export const navigateToView = (
version?: string,
options?: NavigateOptions
) => {
- const url = new URL(
- `/view/${username}/${toolId}${version ? `/${version}` : ''}`,
- window.location.href
- )
+ const searchParams = new URLSearchParams()
if (platform !== import.meta.env.VITE_PLATFORM) {
- url.searchParams.append('platform', platform)
+ searchParams.append('platform', platform)
}
- navigate(`${url.pathname}${url.search}`, options)
+ navigate(
+ `/view/${username}/${toolId}${version ? `/${version}` : ''}${searchParams.size ? `?${searchParams.toString()}` : ''}`,
+ options
+ )
}
export const navigateToSource = (
@@ -56,14 +56,15 @@ export const navigateToSource = (
version?: string,
options?: NavigateOptions
) => {
- const url = new URL(
- `/source/${username}/${toolId}${version ? `/${version}` : ''}`,
- window.location.href
- )
+ const searchParams = new URLSearchParams()
if (platform !== import.meta.env.VITE_PLATFORM) {
- url.searchParams.append('platform', platform)
+ searchParams.append('platform', platform)
}
- navigate(`${url.pathname}${url.search}`, options)
+
+ navigate(
+ `/source/${username}/${toolId}${version ? `/${version}` : ''}${searchParams.size ? `?${searchParams.toString()}` : ''}`,
+ options
+ )
}
export const navigateToRedirect = (
@@ -113,12 +114,12 @@ export const navigateToEdit = (
platform: Platform,
options?: NavigateOptions
) => {
- const url = new URL(`/edit/${toolId}`, window.location.href)
+ const searchParams = new URLSearchParams()
if (platform !== import.meta.env.VITE_PLATFORM) {
- url.searchParams.append('platform', platform)
+ searchParams.append('platform', platform)
}
- navigate(`${url.pathname}${url.search}`, options)
+ navigate(`/edit/${toolId}${searchParams.size ? `?${searchParams.toString()}` : ''}`, options)
}
export const navigateToUser = (navigate: NavigateFunction, options?: NavigateOptions) => {
@@ -135,15 +136,12 @@ export const getViewPath = (
platform: Platform,
version?: string
) => {
- const url = new URL(
- `/view/${username}/${toolId}${version ? `/${version}` : ''}`,
- window.location.href
- )
+ const searchParams = new URLSearchParams()
if (platform !== import.meta.env.VITE_PLATFORM) {
- url.searchParams.append('platform', platform)
+ searchParams.append('platform', platform)
}
- return `${url.pathname}${url.search}`
+ return `/view/${username}/${toolId}${version ? `/${version}` : ''}${searchParams.size ? `?${searchParams.toString()}` : ''}`
}
export const getAndroidUrl = (username: string, toolId: string) =>