Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: activation page reload issue after activating (#964)

Matri916d8be0ae3f
diff --git a/web/app/activate/activateForm.tsx b/web/app/activate/activateForm.tsx
index bfbfcebfb06..7a11faeea8f 100644
--- a/web/app/activate/activateForm.tsx
+++ b/web/app/activate/activateForm.tsx
@@ -47,13 +47,14 @@ const ActivateForm = () => {
const [showSuccess, setShowSuccess] = useState(false)
const defaultLanguage = useCallback(() => (window.navigator.language.startsWith('zh') ? languageMaps['zh-Hans'] : languageMaps.en) || languageMaps.en, [])
- const showErrorMessage = (message: string) => {
+ const showErrorMessage = useCallback((message: string) => {
Toast.notify({
type: 'error',
message,
})
- }
- const valid = () => {
+ }, [])
+
+ const valid = useCallback(() => {
if (!name.trim()) {
showErrorMessage(t('login.error.nameEmpty'))
return false
@@ -66,9 +67,9 @@ const ActivateForm = () => {
showErrorMessage(t('login.error.passwordInvalid'))
return true
- }
+ }, [name, password, showErrorMessage, t])
- const handleActivate = async () => {
+ const handleActivate = useCallback(async () => {
if (!valid())
return
try {
@@ -84,13 +85,13 @@ const ActivateForm = () => {
timezone,
},
})
- setLocaleOnClient(language.startsWith('en') ? 'en' : 'zh-Hans')
+ setLocaleOnClient(language.startsWith('en') ? 'en' : 'zh-Hans', false)
setShowSuccess(true)
}
catch {
recheck()
}
- }
+ }, [email, language, name, password, recheck, setLocaleOnClient, timezone, token, valid, workspaceID])
return (
<div className={
diff --git a/web/context/i18n.ts b/web/context/i18n.ts
index 1870b65302a..5e3eda02e87 100644
--- a/web/context/i18n.ts
+++ b/web/context/i18n.ts
@@ -3,15 +3,15 @@ import type { Locale } from '@/i18n'
type II18NContext = {
locale: Locale
- i18n: Record<string, any>,
- setLocaleOnClient: (locale: Locale) => void
+ i18n: Record<string, any>
+ setLocaleOnClient: (locale: Locale, reloadPage?: boolean) => void
// setI8N: (i18n: Record<string, string>) => void,
}
const I18NContext = createContext<II18NContext>({
locale: 'en',
i18n: {},
- setLocaleOnClient: (lang: Locale) => { }
+ setLocaleOnClient: (lang: Locale, reloadPage?: boolean) => { },
// setI8N: () => {},
})
diff --git a/web/i18n/client.ts b/web/i18n/client.ts
index 39b6d016562..b69af85d04a 100644
--- a/web/i18n/client.ts
+++ b/web/i18n/client.ts
@@ -9,8 +9,8 @@ export const getLocaleOnClient = (): Locale => {
return Cookies.get(LOCALE_COOKIE_NAME) as Locale || i18n.defaultLocale
}
-export const setLocaleOnClient = (locale: Locale) => {
+export const setLocaleOnClient = (locale: Locale, reloadPage = true) => {
Cookies.set(LOCALE_COOKIE_NAME, locale)
changeLanguage(locale)
- location.reload()
+ reloadPage && location.reload()
}