Fix can not autoload in production mode bug

This commit is contained in:
2024-01-15 15:57:48 +08:00
parent bcf29f74ef
commit 6d08e1a8e8
24 changed files with 36 additions and 57 deletions

View File

@@ -1,4 +1,3 @@
import { useUpdatedEffect } from '@/util/hooks'
import '@/components/Playground/Output/Preview/preview.scss'
import { IFiles, IImportMap } from '@/components/Playground/shared'
import Compiler from '@/components/Playground/compiler'
@@ -52,7 +51,7 @@ const Preview = ({ iframeKey, files, importMap }: PreviewProps) => {
}
}
useUpdatedEffect(() => {
useEffect(() => {
window.addEventListener('message', handleMessage)
return () => {
@@ -60,7 +59,7 @@ const Preview = ({ iframeKey, files, importMap }: PreviewProps) => {
}
}, [])
useUpdatedEffect(() => {
useEffect(() => {
Compiler.compile(files, importMap)
.then((result) => {
if (loaded) {
@@ -70,7 +69,7 @@ const Preview = ({ iframeKey, files, importMap }: PreviewProps) => {
} as IMessage)
}
})
.catch((e) => {
.catch((e: Error) => {
setErrorMsg(`编译失败:${e.message}`)
})
}, [files, Compiler, loaded])

View File

@@ -1,6 +1,7 @@
[data-component=playground-preview] {
display: flex;
position: relative;
iframe {
border: none;
flex: 1;

View File

@@ -1,7 +1,6 @@
import MonacoEditor from '@monaco-editor/react'
import { Loader } from 'esbuild-wasm'
import '@/components/Playground/Output/Transform/transform.scss'
import { useUpdatedEffect } from '@/util/hooks'
import { IFile, ITheme } from '@/components/Playground/shared'
import { cssToJs, jsonToJs, addReactImport } from '@/components/Playground/files'
import Compiler from '@/components/Playground/compiler'
@@ -32,7 +31,7 @@ const Transform = ({ file, theme }: OutputProps) => {
})
}
useUpdatedEffect(() => {
useEffect(() => {
if (file) {
try {
const code = file.value

View File

@@ -1,5 +1,4 @@
import '@/components/Playground/playground.scss'
import { useUpdatedEffect } from '@/util/hooks'
import { IFiles, IImportMap, ITsconfig } from '@/components/Playground/shared'
import {
IMPORT_MAP_FILE_NAME,
@@ -54,7 +53,7 @@ const Playground = ({ initFiles, initImportMapRaw, initTsconfigRaw }: Playground
setFiles(files)
}
useUpdatedEffect(() => {
useEffect(() => {
try {
setImportMap(JSON.parse(importMapRaw) as IImportMap)
} catch (e) {
@@ -62,7 +61,7 @@ const Playground = ({ initFiles, initImportMapRaw, initTsconfigRaw }: Playground
}
}, [importMapRaw])
useUpdatedEffect(() => {
useEffect(() => {
try {
setTsconfig(JSON.parse(tsconfigRaw) as ITsconfig)
} catch (e) {
@@ -76,12 +75,12 @@ const Playground = ({ initFiles, initImportMapRaw, initTsconfigRaw }: Playground
tsconfig={tsconfig}
files={{
...files,
'import-map.json': {
[IMPORT_MAP_FILE_NAME]: {
name: IMPORT_MAP_FILE_NAME,
language: 'json',
value: importMapRaw
},
'tsconfig.json': {
[TS_CONFIG_FILE_NAME]: {
name: TS_CONFIG_FILE_NAME,
language: 'json',
value: tsconfigRaw

View File

@@ -1,7 +1,6 @@
import Icon from '@ant-design/icons'
import { COLOR_ERROR } from '@/constants/common.constants'
import { getRedirectUrl } from '@/util/route'
import { useUpdatedEffect } from '@/util/hooks'
import { getAvatar, getLoginStatus, getNickname, removeToken } from '@/util/auth'
import { r_auth_logout } from '@/services/auth'
@@ -42,7 +41,7 @@ const Footer = () => {
const loginStatus = getLoginStatus()
useUpdatedEffect(() => {
useEffect(() => {
if (getLoginStatus()) {
void getNickname().then((nickname) => {
setNickname(nickname)

View File

@@ -8,7 +8,6 @@ import {
PERMISSION_USER_NOT_FOUND,
SYSTEM_INVALID_CAPTCHA_CODE
} from '@/constants/common.constants'
import { useUpdatedEffect } from '@/util/hooks'
import { r_auth_forget, r_auth_retrieve } from '@/services/auth'
import FitCenter from '@/components/common/FitCenter'
import FlexBox from '@/components/common/FlexBox'
@@ -45,7 +44,7 @@ const Forget = () => {
const [captchaCode, setCaptchaCode] = useState('')
const [retrieveCaptchaCode, setRetrieveCaptchaCode] = useState('')
useUpdatedEffect(() => {
useEffect(() => {
if (!isSending) {
setCaptchaCode('')
turnstileRef.current?.reset()
@@ -53,7 +52,7 @@ const Forget = () => {
}
}, [isSending])
useUpdatedEffect(() => {
useEffect(() => {
if (!isChanging) {
setRetrieveCaptchaCode('')
retrieveTurnstileRef.current?.reset()

View File

@@ -8,7 +8,6 @@ import {
PERMISSION_USERNAME_NOT_FOUND,
SYSTEM_INVALID_CAPTCHA_CODE
} from '@/constants/common.constants'
import { useUpdatedEffect } from '@/util/hooks'
import { getUserInfo, setToken } from '@/util/auth'
import { utcToLocalTime } from '@/util/datetime'
import { r_auth_login } from '@/services/auth'
@@ -33,7 +32,7 @@ const SignIn = () => {
const [isSigningIn, setIsSigningIn] = useState(false)
const [captchaCode, setCaptchaCode] = useState('')
useUpdatedEffect(() => {
useEffect(() => {
if (!isSigningIn) {
setCaptchaCode('')
turnstileRef.current?.reset()

View File

@@ -7,7 +7,6 @@ import {
SYSTEM_INVALID_CAPTCHA_CODE,
SYSTEM_MATCH_SENSITIVE_WORD
} from '@/constants/common.constants'
import { useUpdatedEffect } from '@/util/hooks'
import { getLoginStatus, setToken } from '@/util/auth'
import { r_auth_register, r_auth_resend } from '@/services/auth'
import FitCenter from '@/components/common/FitCenter'
@@ -32,7 +31,7 @@ const SignUp = () => {
const [isSending, setIsSending] = useState(false)
const [captchaCode, setCaptchaCode] = useState('')
useUpdatedEffect(() => {
useEffect(() => {
if (!isSigningUp) {
setCaptchaCode('')
turnstileRef.current?.reset()
@@ -40,7 +39,7 @@ const SignUp = () => {
}
}, [isSigningUp])
useUpdatedEffect(() => {
useEffect(() => {
if (location.pathname !== '/register') {
return
}

View File

@@ -5,7 +5,6 @@ import {
PERMISSION_VERIFY_SUCCESS,
SYSTEM_MATCH_SENSITIVE_WORD
} from '@/constants/common.constants'
import { useUpdatedEffect } from '@/util/hooks'
import { getLoginStatus, getUserInfo, requestUserInfo } from '@/util/auth'
import { getRedirectUrl } from '@/util/route'
import { r_auth_resend, r_auth_verify } from '@/services/auth'
@@ -26,7 +25,7 @@ const Verify = () => {
const [avatar, setAvatar] = useState('')
const [isVerifying, setIsVerifying] = useState(false)
useUpdatedEffect(() => {
useEffect(() => {
if (location.pathname !== '/verify') {
return
}

View File

@@ -1,5 +1,4 @@
import '@/assets/css/pages/sign.scss'
import { useUpdatedEffect } from '@/util/hooks'
import FitFullscreen from '@/components/common/FitFullscreen'
import FitCenter from '@/components/common/FitCenter'
import FlexBox from '@/components/common/FlexBox'
@@ -16,7 +15,7 @@ const Sign = () => {
const leftPage = ['register', 'verify', 'forget']
useUpdatedEffect(() => {
useEffect(() => {
lastPage.current = currentPage.current
currentPage.current = match.id

View File

@@ -10,7 +10,6 @@ import {
DATABASE_SELECT_SUCCESS,
DATABASE_UPDATE_SUCCESS
} from '@/constants/common.constants'
import { useUpdatedEffect } from '@/util/hooks'
import { hasPermission } from '@/util/auth'
import { utcToLocalTime } from '@/util/datetime'
import {
@@ -484,7 +483,7 @@ const Group = () => {
}
}, [formValues])
useUpdatedEffect(() => {
useEffect(() => {
getGroup()
}, [
JSON.stringify(tableParams.filters),

View File

@@ -1,7 +1,6 @@
import { ChangeEvent, KeyboardEvent } from 'react'
import dayjs from 'dayjs'
import { COLOR_FONT_SECONDARY, DATABASE_SELECT_SUCCESS } from '@/constants/common.constants'
import { useUpdatedEffect } from '@/util/hooks'
import { dayjsToUtc, utcToLocalTime } from '@/util/datetime'
import { r_sys_log_get } from '@/services/system'
import FitFullscreen from '@/components/common/FitFullscreen'
@@ -223,7 +222,7 @@ const Log = () => {
})
}
useUpdatedEffect(() => {
useEffect(() => {
getLog()
}, [
JSON.stringify(tableParams.filters),

View File

@@ -10,7 +10,6 @@ import {
DATABASE_SELECT_SUCCESS,
DATABASE_UPDATE_SUCCESS
} from '@/constants/common.constants'
import { useUpdatedEffect } from '@/util/hooks'
import { utcToLocalTime } from '@/util/datetime'
import { hasPermission, powerListToPowerTree } from '@/util/auth'
import {
@@ -493,7 +492,7 @@ const Role = () => {
}
}, [formValues])
useUpdatedEffect(() => {
useEffect(() => {
getRole()
}, [
JSON.stringify(tableParams.filters),

View File

@@ -1,4 +1,3 @@
import { useUpdatedEffect } from '@/util/hooks'
import { hasPermission } from '@/util/auth'
import { r_sys_settings_base_get, r_sys_settings_base_update } from '@/services/system'
import { SettingsCard } from '@/pages/System/Settings'
@@ -40,7 +39,7 @@ const Base = () => {
})
}
useUpdatedEffect(() => {
useEffect(() => {
getBaseSettings()
}, [])

View File

@@ -1,5 +1,4 @@
import Icon from '@ant-design/icons'
import { useUpdatedEffect } from '@/util/hooks'
import { hasPermission } from '@/util/auth'
import {
r_sys_settings_mail_get,
@@ -95,7 +94,7 @@ const Mail = () => {
})
}
useUpdatedEffect(() => {
useEffect(() => {
getMailSettings()
}, [])

View File

@@ -1,7 +1,6 @@
import { ChangeEvent } from 'react'
import Icon from '@ant-design/icons'
import { DATABASE_DUPLICATE_KEY, DATABASE_INSERT_SUCCESS } from '@/constants/common.constants'
import { useUpdatedEffect } from '@/util/hooks'
import {
r_sys_settings_sensitive_add,
r_sys_settings_sensitive_delete,
@@ -95,7 +94,7 @@ const SensitiveWord = () => {
})
}
useUpdatedEffect(() => {
useEffect(() => {
getSensitiveWordSettings()
}, [])

View File

@@ -1,6 +1,5 @@
import Icon from '@ant-design/icons'
import * as echarts from 'echarts/core'
import { useUpdatedEffect } from '@/util/hooks'
import { getTimesBetweenTwoTimes } from '@/util/datetime'
import { r_sys_statistics_active } from '@/services/system'
import FlexBox from '@/components/common/FlexBox'
@@ -13,7 +12,7 @@ const ActiveInfo = () => {
const [isLoading, setIsLoading] = useState(false)
const [scope, setScope] = useState('WEAK')
useUpdatedEffect(() => {
useEffect(() => {
const chartResizeObserver = new ResizeObserver(() => {
activeInfoEChartsRef.current?.resize()
})
@@ -25,7 +24,7 @@ const ActiveInfo = () => {
}
}, [isLoading])
useUpdatedEffect(() => {
useEffect(() => {
getActiveInfo()
}, [])

View File

@@ -1,6 +1,5 @@
import * as echarts from 'echarts/core'
import { BarSeriesOption } from 'echarts/charts'
import { useUpdatedEffect } from '@/util/hooks'
import { r_sys_statistics_cpu } from '@/services/system'
import FlexBox from '@/components/common/FlexBox'
import {
@@ -26,7 +25,7 @@ const CPUInfo = () => {
}
}
useUpdatedEffect(() => {
useEffect(() => {
const chartResizeObserver = new ResizeObserver(() => {
cpuInfoEChartsRef.current.forEach((value) => value.resize())
})
@@ -38,7 +37,7 @@ const CPUInfo = () => {
}
}, [cpuInfoDivRef.current])
useUpdatedEffect(() => {
useEffect(() => {
const intervalId = setInterval(getCpuInfo(), parseInt(refreshInterval) * 1000)
return () => {

View File

@@ -1,4 +1,3 @@
import { useUpdatedEffect } from '@/util/hooks'
import { r_sys_statistics_hardware } from '@/services/system'
import FlexBox from '@/components/common/FlexBox'
import { CommonCard } from '@/pages/System/Statistics'
@@ -6,7 +5,7 @@ import { CommonCard } from '@/pages/System/Statistics'
const HardwareInfo = () => {
const [hardwareInfoData, setHardwareInfoData] = useState<HardwareInfoVo>()
useUpdatedEffect(() => {
useEffect(() => {
void r_sys_statistics_hardware().then((res) => {
const response = res.data
if (response.success) {

View File

@@ -1,6 +1,5 @@
import Icon from '@ant-design/icons'
import * as echarts from 'echarts/core'
import { useUpdatedEffect } from '@/util/hooks'
import { getTimesBetweenTwoTimes } from '@/util/datetime'
import { r_sys_statistics_online } from '@/services/system'
import FlexBox from '@/components/common/FlexBox'
@@ -14,7 +13,7 @@ const OnlineInfo = () => {
const [currentOnlineCount, setCurrentOnlineCount] = useState(-1)
const [scope, setScope] = useState('WEAK')
useUpdatedEffect(() => {
useEffect(() => {
const chartResizeObserver = new ResizeObserver(() => {
onlineInfoEChartsRef.current?.resize()
})
@@ -26,7 +25,7 @@ const OnlineInfo = () => {
}
}, [isLoading])
useUpdatedEffect(() => {
useEffect(() => {
getOnlineInfo()
}, [])

View File

@@ -1,4 +1,3 @@
import { useUpdatedEffect } from '@/util/hooks'
import { utcToLocalTime } from '@/util/datetime'
import { r_sys_statistics_software } from '@/services/system'
import FlexBox from '@/components/common/FlexBox'
@@ -7,7 +6,7 @@ import { CommonCard } from '@/pages/System/Statistics'
const SoftwareInfo = () => {
const [softwareInfoData, setSoftwareInfoData] = useState<SoftwareInfoVo>()
useUpdatedEffect(() => {
useEffect(() => {
void r_sys_statistics_software().then((res) => {
const response = res.data
if (response.success) {

View File

@@ -1,7 +1,6 @@
import * as echarts from 'echarts/core'
import { BarSeriesOption } from 'echarts/charts'
import { formatByteSize } from '@/util/common'
import { useUpdatedEffect } from '@/util/hooks'
import { r_sys_statistics_storage } from '@/services/system'
import FlexBox from '@/components/common/FlexBox'
import {
@@ -25,7 +24,7 @@ const StorageInfo = () => {
tooltip: { valueFormatter: (value) => formatByteSize(value as number) }
}
useUpdatedEffect(() => {
useEffect(() => {
const chartResizeObserver = new ResizeObserver(() => {
storageInfoEChartsRef.current.forEach((value) => value.resize())
})
@@ -37,7 +36,7 @@ const StorageInfo = () => {
}
}, [storageInfoDivRef.current])
useUpdatedEffect(() => {
useEffect(() => {
const intervalId = setInterval(getStorageInfo(), parseInt(refreshInterval) * 1000)
return () => {

View File

@@ -11,7 +11,6 @@ import {
DATABASE_SELECT_SUCCESS,
DATABASE_UPDATE_SUCCESS
} from '@/constants/common.constants'
import { useUpdatedEffect } from '@/util/hooks'
import { hasPermission } from '@/util/auth'
import { utcToLocalTime, isPastTime, localTimeToUtc, dayjsToUtc, getNowUtc } from '@/util/datetime'
import {
@@ -748,7 +747,7 @@ const User = () => {
}
}, [formValues])
useUpdatedEffect(() => {
useEffect(() => {
getUser()
}, [
JSON.stringify(tableParams.filters),

View File

@@ -5,7 +5,7 @@ import FitFullscreen from '@/components/common/FitFullscreen'
import Sidebar from '@/components/common/Sidebar'
import FullscreenLoadingMask from '@/components/common/FullscreenLoadingMask'
const ToolsFramework = () => {
const UserFramework = () => {
return (
<>
<FitFullscreen data-component={'user-framework'} className={'flex-horizontal'}>
@@ -62,4 +62,4 @@ const ToolsFramework = () => {
)
}
export default ToolsFramework
export default UserFramework