fix: fix serveral bugs of frontend
This commit is contained in:
1 parent
482d2d73a3
commit
45ed2ed72a
4 files changed
+102
-21
No files matched your search
@@ -1518,7 +1518,49 @@ const getColumnWidthStyle = (key: string) => {
|
||||
maxWidth: `${col.width}px`,
|
||||
};
|
||||
};
|
||||
const getReportCellValue = (row: any, key: string) => row?.[key];
|
||||
|
||||
// 报表值翻译辅助:优先返回 i18n 文案;若没有配置对应翻译则回退原始值
|
||||
const getTranslatedValue = (i18nKey: string, fallbackValue: any) => {
|
||||
const translated = t(i18nKey);
|
||||
return translated && translated !== i18nKey ? translated : fallbackValue;
|
||||
};
|
||||
|
||||
const getReportCellValue = (row: any, key: string) => {
|
||||
const value = row?.[key];
|
||||
// 根据 is_active 这一列的值进行多语言翻译(布尔值兼容多种后端返回格式)
|
||||
if (key === 'is_active') {
|
||||
const truthy = value === true || value === 1 || value === '1' || value === 'true' || value === 'True';
|
||||
return truthy ? t('admin.status.active') : t('admin.status.disabled');
|
||||
}
|
||||
|
||||
// 用户报表值翻译:角色(guest/user/admin) -> 中文角色名
|
||||
if (key === 'role' && typeof value === 'string') {
|
||||
return getTranslatedValue(`admin.role.${value}`, value);
|
||||
}
|
||||
|
||||
// 用户报表值翻译:状态(active/disabled/pending/rejected) -> 中文状态名
|
||||
if (key === 'status' && typeof value === 'string') {
|
||||
return getTranslatedValue(`admin.status.${value}`, value);
|
||||
}
|
||||
|
||||
// 用户报表值翻译:主题偏好(light/dark/system) -> 中文主题名
|
||||
if (key === 'theme_preference' && typeof value === 'string') {
|
||||
return getTranslatedValue(`theme.${value}`, value);
|
||||
}
|
||||
|
||||
// 用户报表值翻译:语言(zh-CN/zh-TW/en/th) -> 语言名称
|
||||
if (key === 'language' && typeof value === 'string') {
|
||||
const languageLabelMap: Record<string, string> = {
|
||||
'zh-CN': '简体中文',
|
||||
'zh-TW': '繁體中文',
|
||||
en: 'English',
|
||||
th: 'ไทย',
|
||||
};
|
||||
return languageLabelMap[value] || value;
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
const normalizeSortValue = (v: any) => {
|
||||
if (v === null || v === undefined) return null;
|
||||
if (typeof v === 'number') return v;
|
||||
@@ -1971,13 +2013,13 @@ const handlePermissionImport = async (event: Event) => {
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button
|
||||
<!-- <button
|
||||
@click="saveConfig"
|
||||
class="hidden md:flex items-center gap-2 px-5 py-2.5 bg-slate-900 dark:bg-slate-700 text-white rounded-xl hover:bg-slate-800 dark:hover:bg-slate-600 transition-all shadow-lg shadow-slate-200 active:scale-95"
|
||||
>
|
||||
<Save class="w-4 h-4" />
|
||||
<span class="font-medium text-sm">{{ t('admin.save') }}</span>
|
||||
</button>
|
||||
</button> -->
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -2108,13 +2150,6 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<h2 class="text-lg font-bold text-slate-900">{{ t('admin.approval.title') }}</h2>
|
||||
<p class="text-sm text-slate-500 mt-1">{{ t('admin.approval.subtitle') }}</p>
|
||||
</div>
|
||||
<button
|
||||
@click="openCreateUserModal"
|
||||
class="flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-xl hover:bg-brand-700 transition-all shadow-lg shadow-brand-200 active:scale-95 text-sm font-medium"
|
||||
>
|
||||
<Plus class="w-4 h-4" />
|
||||
<span class="font-medium">{{ t('admin.approval.addUser') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full">
|
||||
@@ -3142,7 +3177,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
</div>
|
||||
|
||||
<div v-if="tableData.length === 0" class="text-center text-slate-400 py-20 bg-slate-50 rounded-2xl border border-dashed border-slate-300">
|
||||
<p>{{ t('admin.report.noData', { table: currentTable }) }}</p>
|
||||
<p>{{ t('admin.report.noData', { table: getReportTableLabel(currentTable) }) }}</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="overflow-x-auto rounded-2xl border border-slate-200 bg-white shadow-[0_12px_40px_-28px_rgba(15,23,42,0.5)]">
|
||||
|
||||
Reference in new issue
Block a user