2025-05-06 06:45:49 +00:00
|
|
|
import { Notification, toast } from '@/components/ui'
|
2025-08-12 08:39:06 +00:00
|
|
|
import { generateBackgroundWorkers } from '@/services/background-worker.service'
|
2025-08-18 19:13:26 +00:00
|
|
|
import { getLocalization } from '@/services/localization.service'
|
|
|
|
|
import { store } from '@/store'
|
2026-01-16 14:52:52 +00:00
|
|
|
import { clearRedisCache } from './languageText.service'
|
2025-05-06 06:45:49 +00:00
|
|
|
|
|
|
|
|
export abstract class UiEvalService {
|
|
|
|
|
static Init = () => {
|
|
|
|
|
//console.log('init')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ApiGenerateBackgroundWorkers = () => {
|
2025-08-18 19:13:26 +00:00
|
|
|
// Get store state directly instead of using hook
|
|
|
|
|
const state = store.getState()
|
|
|
|
|
const { texts, config } = state.abpConfig
|
|
|
|
|
|
|
|
|
|
// Create translate function similar to useLocalization hook
|
2025-09-01 14:07:03 +00:00
|
|
|
const translate = (
|
|
|
|
|
localizationKey: string,
|
|
|
|
|
params?: Record<string, string | number>,
|
|
|
|
|
defaultResourceName?: string,
|
|
|
|
|
): string => {
|
2025-08-18 19:13:26 +00:00
|
|
|
if (!texts) {
|
|
|
|
|
return localizationKey
|
|
|
|
|
}
|
|
|
|
|
return getLocalization(
|
|
|
|
|
texts,
|
|
|
|
|
defaultResourceName ?? config?.localization?.defaultResourceName,
|
|
|
|
|
localizationKey,
|
2025-09-01 14:07:03 +00:00
|
|
|
params,
|
2025-08-18 19:13:26 +00:00
|
|
|
)
|
|
|
|
|
}
|
2025-05-28 13:47:54 +00:00
|
|
|
|
2025-05-06 06:45:49 +00:00
|
|
|
const asyncCall = async () => {
|
|
|
|
|
await generateBackgroundWorkers()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
asyncCall()
|
|
|
|
|
|
|
|
|
|
toast.push(
|
|
|
|
|
<Notification type="success" duration={2000}>
|
2025-05-28 13:47:54 +00:00
|
|
|
{translate('::App.BackgroundWorkers.Message')}
|
2025-05-06 06:45:49 +00:00
|
|
|
</Notification>,
|
|
|
|
|
{
|
2025-09-01 14:07:03 +00:00
|
|
|
placement: 'top-end',
|
2025-05-06 06:45:49 +00:00
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
}
|
2026-01-16 14:52:52 +00:00
|
|
|
|
|
|
|
|
static ApiClearRedisCache = () => {
|
|
|
|
|
// Get store state directly instead of using hook
|
|
|
|
|
const state = store.getState()
|
|
|
|
|
const { texts, config } = state.abpConfig
|
|
|
|
|
|
|
|
|
|
// Create translate function similar to useLocalization hook
|
|
|
|
|
const translate = (
|
|
|
|
|
localizationKey: string,
|
|
|
|
|
params?: Record<string, string | number>,
|
|
|
|
|
defaultResourceName?: string,
|
|
|
|
|
): string => {
|
|
|
|
|
if (!texts) {
|
|
|
|
|
return localizationKey
|
|
|
|
|
}
|
|
|
|
|
return getLocalization(
|
|
|
|
|
texts,
|
|
|
|
|
defaultResourceName ?? config?.localization?.defaultResourceName,
|
|
|
|
|
localizationKey,
|
|
|
|
|
params,
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const asyncCall = async () => {
|
|
|
|
|
await clearRedisCache()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
asyncCall()
|
|
|
|
|
|
|
|
|
|
toast.push(
|
|
|
|
|
<Notification type="success" duration={2000}>
|
|
|
|
|
{translate('::App.ClearRedisCache.Message')}
|
|
|
|
|
</Notification>,
|
|
|
|
|
{
|
|
|
|
|
placement: 'top-end',
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
}
|
2025-05-06 06:45:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const _global = (window || global) as any
|
|
|
|
|
_global.UiEvalService = UiEvalService
|