Fix:1; Refactor:2 #58
@@ -1,4 +1,5 @@
|
|||||||
VITE_PLATFORM=WEB
|
VITE_PLATFORM=WEB
|
||||||
|
VITE_UI_URL=${DEV_UI_URL}
|
||||||
VITE_API_URL=${DEV_API_URL}
|
VITE_API_URL=${DEV_API_URL}
|
||||||
VITE_API_TOKEN_URL=${VITE_API_URL}/token
|
VITE_API_TOKEN_URL=${VITE_API_URL}/token
|
||||||
VITE_TURNSTILE_SITE_KEY=${TURNSTILE_SITE_KEY}
|
VITE_TURNSTILE_SITE_KEY=${TURNSTILE_SITE_KEY}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
VITE_PLATFORM=WEB
|
VITE_PLATFORM=WEB
|
||||||
|
VITE_UI_URL=${PRODUCT_UI_URL}
|
||||||
VITE_API_URL=${PRODUCT_API_URL}
|
VITE_API_URL=${PRODUCT_API_URL}
|
||||||
VITE_API_TOKEN_URL=${VITE_API_URL}/token
|
VITE_API_TOKEN_URL=${VITE_API_URL}/token
|
||||||
VITE_TURNSTILE_SITE_KEY=${TURNSTILE_SITE_KEY}
|
VITE_TURNSTILE_SITE_KEY=${TURNSTILE_SITE_KEY}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
VITE_PLATFORM=WEB
|
VITE_PLATFORM=WEB
|
||||||
|
VITE_UI_URL=${TEST_UI_URL}
|
||||||
VITE_API_URL=${TEST_API_URL}
|
VITE_API_URL=${TEST_API_URL}
|
||||||
VITE_API_TOKEN_URL=${VITE_API_URL}/token
|
VITE_API_TOKEN_URL=${VITE_API_URL}/token
|
||||||
VITE_TURNSTILE_SITE_KEY=${TURNSTILE_SITE_KEY}
|
VITE_TURNSTILE_SITE_KEY=${TURNSTILE_SITE_KEY}
|
||||||
|
|||||||
@@ -70,6 +70,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.url {
|
.url {
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
> span {
|
> span {
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
window.addEventListener("message", ({ data }) => {
|
window.addEventListener("message", ({ data }) => {
|
||||||
if (data?.type === "UPDATE") {
|
if (data?.type === "UPDATE") {
|
||||||
// Record old styles that need to be removed
|
// 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
|
// Remove old app
|
||||||
const appSrcElement = document.querySelector("#appSrc");
|
const appSrcElement = document.querySelector("#appSrc");
|
||||||
|
|||||||
1
src/global.d.ts
vendored
1
src/global.d.ts
vendored
@@ -5,6 +5,7 @@ type Platform = 'WEB' | 'DESKTOP' | 'ANDROID'
|
|||||||
|
|
||||||
interface ImportMetaEnv {
|
interface ImportMetaEnv {
|
||||||
readonly VITE_PLATFORM: Platform
|
readonly VITE_PLATFORM: Platform
|
||||||
|
readonly VITE_UI_URL: string
|
||||||
readonly VITE_API_URL: string
|
readonly VITE_API_URL: string
|
||||||
readonly VITE_API_TOKEN_URL: string
|
readonly VITE_API_TOKEN_URL: string
|
||||||
readonly VITE_TURNSTILE_SITE_KEY: string
|
readonly VITE_TURNSTILE_SITE_KEY: string
|
||||||
|
|||||||
@@ -637,8 +637,10 @@ const Base = () => {
|
|||||||
rules={[
|
rules={[
|
||||||
{ required: true },
|
{ required: true },
|
||||||
{
|
{
|
||||||
pattern: /\.(jsx|tsx|js|ts|css|json)$/,
|
pattern:
|
||||||
message: '仅支持 *.jsx, *.tsx, *.js, *.ts, *.css, *.json 文件'
|
/(\.jsx|\.tsx|\.js|\.ts|_oxygen_base_style\.css|\.json)$/,
|
||||||
|
message:
|
||||||
|
'仅支持 *.jsx, *.tsx, *.js, *.ts, *_oxygen_base_style.css, *.json 文件'
|
||||||
},
|
},
|
||||||
({ getFieldValue }) => ({
|
({ getFieldValue }) => ({
|
||||||
validator() {
|
validator() {
|
||||||
@@ -829,9 +831,10 @@ const Base = () => {
|
|||||||
rules={[
|
rules={[
|
||||||
{ required: true },
|
{ required: true },
|
||||||
{
|
{
|
||||||
pattern: /\.(jsx|tsx|js|ts|css|json)$/,
|
pattern:
|
||||||
|
/(\.jsx|\.tsx|\.js|\.ts|_oxygen_base_style\.css|\.json)$/,
|
||||||
message:
|
message:
|
||||||
'仅支持 *.jsx, *.tsx, *.js, *.ts, *.css, *.json 文件'
|
'仅支持 *.jsx, *.tsx, *.js, *.ts, *_oxygen_base_style.css, *.json 文件'
|
||||||
},
|
},
|
||||||
({ getFieldValue }) => ({
|
({ getFieldValue }) => ({
|
||||||
validator() {
|
validator() {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const User = () => {
|
|||||||
return username
|
return username
|
||||||
? () => {
|
? () => {
|
||||||
void navigator.clipboard
|
void navigator.clipboard
|
||||||
.writeText(new URL(`/store/${username}`, location.href).href)
|
.writeText(new URL(`/store/${username}`, import.meta.env.VITE_UI_URL).href)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
void message.success('已复制到剪切板')
|
void message.success('已复制到剪切板')
|
||||||
})
|
})
|
||||||
@@ -153,8 +153,10 @@ const User = () => {
|
|||||||
onClick={handleOnCopyToClipboard(userWithInfoVo?.username)}
|
onClick={handleOnCopyToClipboard(userWithInfoVo?.username)}
|
||||||
>
|
>
|
||||||
{userWithInfoVo?.username &&
|
{userWithInfoVo?.username &&
|
||||||
new URL(`/store/${userWithInfoVo.username}`, location.href)
|
new URL(
|
||||||
.href}
|
`/store/${userWithInfoVo.username}`,
|
||||||
|
import.meta.env.VITE_UI_URL
|
||||||
|
).href}
|
||||||
<Icon component={IconOxygenCopy} />
|
<Icon component={IconOxygenCopy} />
|
||||||
</a>
|
</a>
|
||||||
</FlexBox>
|
</FlexBox>
|
||||||
|
|||||||
@@ -39,6 +39,18 @@ const User = () => {
|
|||||||
const [userWithPowerInfoVo, setUserWithPowerInfoVo] = useState<UserWithPowerInfoVo>()
|
const [userWithPowerInfoVo, setUserWithPowerInfoVo] = useState<UserWithPowerInfoVo>()
|
||||||
const [changePasswordForm] = AntdForm.useForm<ChangePasswordFields>()
|
const [changePasswordForm] = AntdForm.useForm<ChangePasswordFields>()
|
||||||
|
|
||||||
|
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 = () => {
|
const handleOnReset = () => {
|
||||||
getProfile()
|
getProfile()
|
||||||
}
|
}
|
||||||
@@ -474,20 +486,14 @@ const User = () => {
|
|||||||
</div>
|
</div>
|
||||||
<a
|
<a
|
||||||
className={'url'}
|
className={'url'}
|
||||||
href={
|
onClick={handleOnCopyToClipboard(userWithPowerInfoVo?.username)}
|
||||||
userWithPowerInfoVo?.username &&
|
|
||||||
new URL(
|
|
||||||
`/store/${userWithPowerInfoVo.username}`,
|
|
||||||
location.href
|
|
||||||
).href
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{userWithPowerInfoVo?.username &&
|
{userWithPowerInfoVo?.username &&
|
||||||
new URL(
|
new URL(
|
||||||
`/store/${userWithPowerInfoVo.username}`,
|
`/store/${userWithPowerInfoVo.username}`,
|
||||||
location.href
|
import.meta.env.VITE_UI_URL
|
||||||
).href}
|
).href}
|
||||||
<Icon component={IconOxygenShare} />
|
<Icon component={IconOxygenCopy} />
|
||||||
</a>
|
</a>
|
||||||
</FlexBox>
|
</FlexBox>
|
||||||
</FlexBox>
|
</FlexBox>
|
||||||
|
|||||||
@@ -37,15 +37,15 @@ export const navigateToView = (
|
|||||||
version?: string,
|
version?: string,
|
||||||
options?: NavigateOptions
|
options?: NavigateOptions
|
||||||
) => {
|
) => {
|
||||||
const url = new URL(
|
const searchParams = new URLSearchParams()
|
||||||
`/view/${username}/${toolId}${version ? `/${version}` : ''}`,
|
|
||||||
window.location.href
|
|
||||||
)
|
|
||||||
if (platform !== import.meta.env.VITE_PLATFORM) {
|
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 = (
|
export const navigateToSource = (
|
||||||
@@ -56,14 +56,15 @@ export const navigateToSource = (
|
|||||||
version?: string,
|
version?: string,
|
||||||
options?: NavigateOptions
|
options?: NavigateOptions
|
||||||
) => {
|
) => {
|
||||||
const url = new URL(
|
const searchParams = new URLSearchParams()
|
||||||
`/source/${username}/${toolId}${version ? `/${version}` : ''}`,
|
|
||||||
window.location.href
|
|
||||||
)
|
|
||||||
if (platform !== import.meta.env.VITE_PLATFORM) {
|
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 = (
|
export const navigateToRedirect = (
|
||||||
@@ -113,12 +114,12 @@ export const navigateToEdit = (
|
|||||||
platform: Platform,
|
platform: Platform,
|
||||||
options?: NavigateOptions
|
options?: NavigateOptions
|
||||||
) => {
|
) => {
|
||||||
const url = new URL(`/edit/${toolId}`, window.location.href)
|
const searchParams = new URLSearchParams()
|
||||||
if (platform !== import.meta.env.VITE_PLATFORM) {
|
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) => {
|
export const navigateToUser = (navigate: NavigateFunction, options?: NavigateOptions) => {
|
||||||
@@ -135,15 +136,12 @@ export const getViewPath = (
|
|||||||
platform: Platform,
|
platform: Platform,
|
||||||
version?: string
|
version?: string
|
||||||
) => {
|
) => {
|
||||||
const url = new URL(
|
const searchParams = new URLSearchParams()
|
||||||
`/view/${username}/${toolId}${version ? `/${version}` : ''}`,
|
|
||||||
window.location.href
|
|
||||||
)
|
|
||||||
if (platform !== import.meta.env.VITE_PLATFORM) {
|
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) =>
|
export const getAndroidUrl = (username: string, toolId: string) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user