@liujitcn/kratos-taro-app-core 0.0.75 → 0.0.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "type": "git",
8
8
  "url": "git@github.com:liujitcn/kratos-admin.git"
9
9
  },
10
- "version": "0.0.75",
10
+ "version": "0.0.76",
11
11
  "type": "module",
12
12
  "files": [
13
13
  "dist",
@@ -3,6 +3,7 @@
3
3
  * 各语言 JSON 由模块定义文件导入,不能在 JSON 文件内添加注释。
4
4
  */
5
5
  import Taro from '@tarojs/taro'
6
+ import { useCallback } from 'react'
6
7
  import { create } from 'zustand'
7
8
  import type { KratosTaroModule } from '../module'
8
9
  import type { I18nCustomItem } from '../rpc/base/v1/config'
@@ -196,10 +197,14 @@ export function t(key: string, params: LocaleParams = {}, locale = getCurrentLoc
196
197
  export function useI18n() {
197
198
  useLocaleMessagesRevision()
198
199
  const locale = useLocaleStore((state) => state.locale)
200
+ const translate = useCallback(
201
+ (key: string, params: LocaleParams = {}) => t(key, params, locale),
202
+ [locale],
203
+ )
199
204
  return {
200
205
  locale,
201
206
  setLocale: setCurrentLocale,
202
- t: (key: string, params: LocaleParams = {}) => t(key, params, locale),
207
+ t: translate,
203
208
  }
204
209
  }
205
210
 
@@ -171,7 +171,7 @@ export default function LoginPage() {
171
171
 
172
172
  useEffect(() => {
173
173
  void Taro.setNavigationBarTitle({ title: t('common.action.login') })
174
- }, [locale])
174
+ }, [locale, t])
175
175
 
176
176
  useEffect(() => {
177
177
  return () => {