Merge pull request #17 from dr-forget/fix/bug

feat: 修复视图更新多次注入问题
This commit is contained in:
仓鼠 2024-12-16 14:56:40 +08:00 committed by GitHub
commit 0b8af1c4ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query"
import React, { useCallback } from "react"
import React, { useCallback, useEffect } from "react"
import { useTranslation } from "react-i18next"
import { Route, BrowserRouter as Router, Routes } from "react-router-dom"
@ -55,6 +55,12 @@ const App: React.FC = () => {
})
}, [])
useEffect(() => {
if (settingData?.data?.custom_code) {
InjectContext(settingData?.data?.custom_code)
}
}, [settingData?.data?.custom_code])
if (error) {
return <ErrorPage code={500} message={error.message} />
}
@ -67,10 +73,6 @@ const App: React.FC = () => {
i18n.changeLanguage(settingData?.data?.language)
}
if (settingData?.data?.custom_code) {
InjectContext(settingData?.data?.custom_code)
}
const customBackgroundImage =
// @ts-expect-error ShowNetTransfer is a global variable
(window.CustomBackgroundImage as string) !== "" ? window.CustomBackgroundImage : undefined