mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-11-16 23:04:24 +08:00
fix(i18n): use English runtime text and localize system UI
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
'use client';
|
||||
|
||||
// Copyright 2026 Arctel.net
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { Code } from 'lucide-react';
|
||||
@@ -22,6 +22,8 @@ import { TableTab } from './tabs/table-tab';
|
||||
import { ControlsTab } from './tabs/controls-tab';
|
||||
|
||||
export default function HeaderDemoPage() {
|
||||
const rt = useTranslations('runtime');
|
||||
|
||||
const t = useTranslations('admin.demo');
|
||||
const [activeTab, setActiveTab] = React.useState('dashboard');
|
||||
|
||||
@@ -59,7 +61,8 @@ export default function HeaderDemoPage() {
|
||||
{t('rules.structureFocus.description')}
|
||||
</li>
|
||||
<li>
|
||||
<strong>{t('rules.containerAlignment.title')}</strong>:使用{' '}
|
||||
<strong>{t('rules.containerAlignment.title')}</strong>
|
||||
{rt('use_1b3d699e')}{' '}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
flex items-center gap-2
|
||||
</code>{' '}
|
||||
@@ -67,22 +70,23 @@ export default function HeaderDemoPage() {
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
py-6 px-1
|
||||
</code>{' '}
|
||||
(或{' '}
|
||||
{rt('or_07d4e3c0')}{' '}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
py-6
|
||||
</code>
|
||||
) {t('rules.containerAlignment.description2')}
|
||||
</li>
|
||||
<li>
|
||||
<strong>{t('rules.iconPresentation.title')}</strong>:直接将
|
||||
Lucide 图标组件嵌套于标题容器中,应用{' '}
|
||||
<strong>{t('rules.iconPresentation.title')}</strong>
|
||||
{rt('place_the_lucide_icon_directly_inside_the_104f794c')}{' '}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
size-5 text-primary
|
||||
</code>{' '}
|
||||
{t('rules.iconPresentation.description')}
|
||||
</li>
|
||||
<li>
|
||||
<strong>{t('rules.textStyle.title')}</strong>:文本使用且仅使用{' '}
|
||||
<strong>{t('rules.textStyle.title')}</strong>
|
||||
{rt('use_only_5e12eecb')}{' '}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
{'h1 className="text-2xl font-semibold tracking-tight"'}
|
||||
</code>
|
||||
@@ -93,10 +97,8 @@ export default function HeaderDemoPage() {
|
||||
{t('rules.textStyle.description2')}
|
||||
</li>
|
||||
<li>
|
||||
<strong>{t('rules.tabsModular.title')}</strong>:凡是带有多个
|
||||
Tab 页切换的页面,**禁止**将所有 Tab
|
||||
的渲染代码堆积在同一个物理页面主文件内。每个 Tab 页对应的
|
||||
Content 必须单独拆分为独立组件文件(如{' '}
|
||||
<strong>{t('rules.tabsModular.title')}</strong>
|
||||
{rt('for_pages_with_multiple_tabs_keep_each_5f721959')}{' '}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
tabs/events-tab.tsx
|
||||
</code>{' '}
|
||||
@@ -107,8 +109,8 @@ export default function HeaderDemoPage() {
|
||||
{t('rules.tabsModular.description2')}
|
||||
</li>
|
||||
<li>
|
||||
<strong>{t('rules.complexityDriven.title')}</strong>:不仅是
|
||||
Tabs 切换,当一个页面代码行数超过 600
|
||||
<strong>{t('rules.complexityDriven.title')}</strong>
|
||||
{rt('beyond_tabs_when_a_page_exceeds_600_d152cfdc')}
|
||||
{t('rules.complexityDriven.description')}{' '}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
app/(main)/admin/database/components/
|
||||
@@ -121,19 +123,19 @@ export default function HeaderDemoPage() {
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
/admin/database
|
||||
</code>
|
||||
) 的{' '}
|
||||
{rt('message_18ab4763')}{' '}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
table-browser.tsx
|
||||
</code>
|
||||
、
|
||||
{rt('list_separator')}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
cache-manager.tsx
|
||||
</code>{' '}
|
||||
与{' '}
|
||||
{rt('and_de1d5dd0')}{' '}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
sql-console.tsx
|
||||
</code>
|
||||
。
|
||||
{rt('sentence_end')}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use client';
|
||||
|
||||
// Copyright 2026 Arctel.net
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { Code } from 'lucide-react';
|
||||
@@ -26,6 +26,8 @@ import { Checkbox } from '@/components/ui/checkbox';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
export function ControlsTab() {
|
||||
const rt = useTranslations('runtime');
|
||||
|
||||
const t = useTranslations('admin.demo.controls');
|
||||
const [formData, setFormData] = React.useState({
|
||||
name: '',
|
||||
@@ -166,78 +168,71 @@ export function ControlsTab() {
|
||||
{t('spec.unifiedHeight')}
|
||||
</p>
|
||||
<p>
|
||||
输入框 (
|
||||
{rt('inputs_fabee312')}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
Input
|
||||
</code>
|
||||
) 与下拉选择器 (
|
||||
{rt('and_selectors_e4875cdf')}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
SelectTrigger
|
||||
</code>
|
||||
) 的高度应统一限制为小号高度{' '}
|
||||
{rt('should_share_the_compact_height_f1fe2218')}{' '}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
h-8
|
||||
</code>
|
||||
,字体大小使用{' '}
|
||||
{rt('with_font_size_e7c29991')}{' '}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
text-xs
|
||||
</code>
|
||||
,并使用{' '}
|
||||
{rt('and_use_ca398a12')}{' '}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
shadow-none
|
||||
</code>{' '}
|
||||
去除原生的重叠阴影。
|
||||
{rt('to_remove_overlapping_native_shadows_dd65b475')}
|
||||
</p>
|
||||
|
||||
<p className='font-semibold text-foreground text-[11px] pt-1'>
|
||||
{t('spec.checkboxAlignment')}
|
||||
</p>
|
||||
<p>
|
||||
Checkbox 应在左侧垂直偏上对齐,使用容器{' '}
|
||||
{rt('align_checkboxes_toward_the_top_left_using_092dcef0')}{' '}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
flex items-start gap-2.5
|
||||
</code>{' '}
|
||||
排列。Checkbox 组件本身添加{' '}
|
||||
{rt('add_bf15da3a')}{' '}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
mt-0.5
|
||||
</code>
|
||||
,从而在多行描述文本的情况下依然保持良好的顶对齐,避免出现居中对齐导致的凌乱感。
|
||||
{rt('to_the_checkbox_so_multiline_descriptions_stay_1bb85c4b')}
|
||||
</p>
|
||||
|
||||
<p className='font-semibold text-foreground text-[11px] pt-1'>
|
||||
{t('spec.buttonStrategy')}
|
||||
</p>
|
||||
<p>
|
||||
普通主表单及新增/保存按钮,一律使用默认 Primary 按钮或次要{' '}
|
||||
{rt('use_the_default_primary_or_secondary_db7513e5')}{' '}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
{'variant="secondary"'}
|
||||
</code>{' '}
|
||||
按钮,小号高度统一采用{' '}
|
||||
{rt('button_for_forms_and_create_save_actions_a657dba8')}{' '}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
h-8 text-xs
|
||||
</code>
|
||||
。线框按钮必须带有{' '}
|
||||
{rt('outline_buttons_must_include_the_66ace005')}{' '}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
border-dashed shadow-none
|
||||
</code>{' '}
|
||||
类。
|
||||
{rt('class_43eff5ff')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className='bg-background/80 p-3 rounded border border-border/40 font-mono text-[10px] space-y-2 overflow-x-auto'>
|
||||
<div>{`// 1. Label 与 Input 对齐`}</div>
|
||||
<div>{`<div className="space-y-1.5">
|
||||
<Label htmlFor="id" className="text-xs font-medium text-foreground">标题</Label>
|
||||
<Input id="id" className="h-8 text-xs shadow-none" />
|
||||
</div>`}</div>
|
||||
<div className='pt-2'>{`// 2. Checkbox 顶对齐`}</div>
|
||||
<div>{`<div className="flex items-start gap-2.5">
|
||||
<Checkbox id="c" className="mt-0.5" />
|
||||
<div className="grid gap-1">
|
||||
<label htmlFor="c" className="text-xs font-medium leading-none">标题</label>
|
||||
<p className="text-[10px] text-muted-foreground">多行说明内容</p>
|
||||
</div>
|
||||
</div>`}</div>
|
||||
<div>{rt('1_align_label_and_input_32d4558d')}</div>
|
||||
<div>{rt.raw('div_classname_space_y_1_5_label_32230ad7')}</div>
|
||||
<div className='pt-2'>
|
||||
{rt('2_align_checkbox_to_the_top_bdf68ad8')}
|
||||
</div>
|
||||
<div>{rt.raw('div_classname_flex_items_start_gap_2_ccf0d526')}</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use client';
|
||||
|
||||
// Copyright 2026 Arctel.net
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { Code, Cpu, Database, HardDrive } from 'lucide-react';
|
||||
@@ -10,6 +10,8 @@ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Progress } from '@/components/ui/progress';
|
||||
|
||||
export function DashboardTab() {
|
||||
const rt = useTranslations('runtime');
|
||||
|
||||
const t = useTranslations('admin.demo.dashboard');
|
||||
return (
|
||||
<div className='space-y-6'>
|
||||
@@ -129,17 +131,9 @@ export function DashboardTab() {
|
||||
</li>
|
||||
</ul>
|
||||
<pre className='text-[11px] font-mono text-muted-foreground overflow-x-auto p-3 bg-background rounded border border-border/40 leading-relaxed'>
|
||||
{`<Card className="border-dashed shadow-none">
|
||||
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||
<span className="text-xs font-medium text-muted-foreground">指标标题</span>
|
||||
<Cpu className="size-4 text-primary" />
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-2">
|
||||
<div className="text-2xl font-semibold tracking-tight">42.8 %</div>
|
||||
<Progress value={42.8} className="h-1.5" />
|
||||
<p className="text-[10px] text-muted-foreground">状态说明小字</p>
|
||||
</CardContent>
|
||||
</Card>`}
|
||||
{rt.raw(
|
||||
'card_classname_border_dashed_shadow_none_cardheader_35727acf',
|
||||
)}
|
||||
</pre>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use client';
|
||||
|
||||
// Copyright 2026 Arctel.net
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { Code, Edit, ListFilter, Plus, Search, Trash2 } from 'lucide-react';
|
||||
@@ -20,6 +20,8 @@ import { Badge } from '@/components/ui/badge';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
|
||||
export function TableTab() {
|
||||
const rt = useTranslations('runtime');
|
||||
|
||||
const t = useTranslations('admin.demo.table');
|
||||
const mockTableData = [
|
||||
{
|
||||
@@ -193,7 +195,7 @@ export function TableTab() {
|
||||
border border-dashed shadow-none rounded-lg overflow-hidden
|
||||
bg-background
|
||||
</code>
|
||||
。
|
||||
{rt('sentence_end')}
|
||||
</li>
|
||||
<li>
|
||||
{t('spec.headerBg')}
|
||||
@@ -204,7 +206,7 @@ export function TableTab() {
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
text-xs font-semibold
|
||||
</code>
|
||||
。
|
||||
{rt('sentence_end')}
|
||||
</li>
|
||||
<li>
|
||||
{t('spec.cellDivider')}
|
||||
@@ -215,14 +217,14 @@ export function TableTab() {
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
hover:bg-muted/10 transition-colors
|
||||
</code>
|
||||
。
|
||||
{rt('sentence_end')}
|
||||
</li>
|
||||
<li>
|
||||
{t('spec.monoFont')}
|
||||
<code className='bg-muted px-1 py-0.5 rounded font-mono'>
|
||||
font-mono text-xs
|
||||
</code>
|
||||
。
|
||||
{rt('sentence_end')}
|
||||
</li>
|
||||
<li>
|
||||
{t('spec.badgeStyle')}
|
||||
@@ -233,27 +235,7 @@ export function TableTab() {
|
||||
</li>
|
||||
</ul>
|
||||
<pre className='text-[11px] font-mono text-muted-foreground overflow-x-auto p-3 bg-background rounded border border-border/40 leading-relaxed'>
|
||||
{`<div className="border border-dashed shadow-none rounded-lg overflow-hidden bg-background">
|
||||
<Table>
|
||||
<TableHeader className="bg-muted/40">
|
||||
<TableRow className="border-dashed hover:bg-transparent">
|
||||
<TableHead className="text-xs font-semibold">编号</TableHead>
|
||||
<TableHead className="text-xs font-semibold">状态</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<TableRow className="border-dashed hover:bg-muted/10 transition-colors">
|
||||
<TableCell className="font-mono text-xs">ID-1001</TableCell>
|
||||
<TableCell>
|
||||
<Badge variant="outline" className="text-[10px] bg-emerald-500/10 border-emerald-500/20 text-emerald-600 rounded-full py-0 px-2">
|
||||
<span className="size-1 bg-emerald-500 rounded-full mr-1.5 shrink-0" />
|
||||
成功
|
||||
</Badge>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>`}
|
||||
{rt.raw('div_classname_border_border_dashed_shadow_none_b430b520')}
|
||||
</pre>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { getFormattingLocale } from '@/i18n/format';
|
||||
import * as React from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
@@ -72,7 +73,7 @@ function getFileIcon(mimeType: string, className = 'size-8') {
|
||||
}
|
||||
|
||||
function formatDate(dateStr: string) {
|
||||
return new Date(dateStr).toLocaleString('zh-CN', {
|
||||
return new Date(dateStr).toLocaleString(getFormattingLocale(), {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
|
||||
@@ -50,6 +50,12 @@ const categoryMap: Record<string, string> = {
|
||||
其他: 'others',
|
||||
};
|
||||
|
||||
// The API retains persisted category keys; labels always follow the UI locale.
|
||||
function categoryTranslationKey(name: string) {
|
||||
const key = categoryMap[name] || 'others';
|
||||
return `stats.cat${key.charAt(0).toUpperCase()}${key.slice(1)}`;
|
||||
}
|
||||
|
||||
function useStatsChartConfig() {
|
||||
const t = useTranslations('admin.files');
|
||||
return {
|
||||
@@ -158,11 +164,11 @@ export function FileStats() {
|
||||
stats.categories.forEach((cat) => {
|
||||
if (cat.count > maxCount) {
|
||||
maxCount = cat.count;
|
||||
maxCountName = cat.name;
|
||||
maxCountName = t(categoryTranslationKey(cat.name));
|
||||
}
|
||||
if (cat.size > maxSize) {
|
||||
maxSize = cat.size;
|
||||
maxSizeName = cat.name;
|
||||
maxSizeName = t(categoryTranslationKey(cat.name));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
'use client';
|
||||
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { isLogStorageDisabledMessage } from './log-storage-error';
|
||||
import {
|
||||
BarChart3,
|
||||
Globe,
|
||||
@@ -117,7 +118,7 @@ export function AccessAnalytics() {
|
||||
const errorInstance =
|
||||
err instanceof Error ? err : new Error(t('fetchFailed'));
|
||||
const errMsg = errorInstance.message || '';
|
||||
if (errMsg.includes('ClickHouse') || errMsg.includes('未启用')) {
|
||||
if (isLogStorageDisabledMessage(errMsg)) {
|
||||
setClickhouseDisabled(true);
|
||||
} else {
|
||||
setError(errorInstance);
|
||||
|
||||
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
'use client';
|
||||
|
||||
import { useMemo, useState } from 'react';
|
||||
import { isLogStorageDisabledMessage } from './log-storage-error';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { toast } from 'sonner';
|
||||
import { format } from 'date-fns';
|
||||
@@ -94,7 +95,7 @@ function statusVariant(status: number) {
|
||||
|
||||
function isClickhouseDisabledError(error: Error) {
|
||||
const errMsg = error.message || '';
|
||||
return errMsg.includes('ClickHouse') || errMsg.includes('未启用');
|
||||
return isLogStorageDisabledMessage(errMsg);
|
||||
}
|
||||
|
||||
export function AccessLogs() {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { getRuntimeTranslator } from '@/i18n/runtime';
|
||||
|
||||
export function isLogStorageDisabledMessage(message: string): boolean {
|
||||
const normalized = message.toLowerCase();
|
||||
return (
|
||||
message.includes('ClickHouse') ||
|
||||
(['en', 'zh-CN'] as const).some((locale) =>
|
||||
normalized.includes(
|
||||
getRuntimeTranslator(locale)('disabled_f95ea7f4').toLowerCase(),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
'use client';
|
||||
|
||||
// Copyright 2026 Arctel.net
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
@@ -81,6 +81,8 @@ import type {
|
||||
import { PushService } from '@/lib/services/push';
|
||||
|
||||
export function EventsTab() {
|
||||
const rt = useTranslations('runtime');
|
||||
|
||||
const t = useTranslations('admin.push.events');
|
||||
const queryClient = useQueryClient();
|
||||
const [deleteTarget, setDeleteTarget] = React.useState<PushEvent | null>(
|
||||
@@ -706,11 +708,11 @@ export function EventsTab() {
|
||||
</div>
|
||||
|
||||
<div className='space-y-1.5'>
|
||||
<div className='flex justify-between items-center'>
|
||||
<div className='flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between'>
|
||||
<Label className='text-xs font-semibold'>
|
||||
{t('contentTemplate')}
|
||||
</Label>
|
||||
<span className='text-[10px] text-muted-foreground font-mono flex items-center'>
|
||||
<span className='text-[10px] text-muted-foreground font-mono'>
|
||||
{newEventType === 'task'
|
||||
? t('taskTemplateVars')
|
||||
: t('eventTemplateVars')}
|
||||
@@ -721,7 +723,11 @@ export function EventsTab() {
|
||||
onChange={(e) => setNewEventTemplate(e.target.value)}
|
||||
rows={6}
|
||||
className='text-xs font-mono'
|
||||
placeholder='{"title": "管理员登录提醒", "content": "管理员 {{user.username}} ...", "level": "INFO"}'
|
||||
placeholder={rt.raw(
|
||||
newEventType === 'task'
|
||||
? 'task_notification_template_example'
|
||||
: 'title_administrator_login_alert_content_administrator_user_6f32cf7c',
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -886,11 +892,11 @@ export function EventsTab() {
|
||||
</div>
|
||||
|
||||
<div className='space-y-1.5'>
|
||||
<div className='flex justify-between items-center'>
|
||||
<div className='flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between'>
|
||||
<Label className='text-xs font-semibold'>
|
||||
{t('contentTemplate')}
|
||||
</Label>
|
||||
<span className='text-[10px] text-muted-foreground font-mono flex items-center'>
|
||||
<span className='text-[10px] text-muted-foreground font-mono'>
|
||||
{selectedEvent.task_type
|
||||
? t('taskTemplateVars')
|
||||
: t('eventTemplateVars')}
|
||||
@@ -901,7 +907,11 @@ export function EventsTab() {
|
||||
onChange={(e) => setEventTemplate(e.target.value)}
|
||||
rows={6}
|
||||
className='text-xs font-mono'
|
||||
placeholder='{"title": "管理员登录提醒", "content": "管理员 {{user.username}} ...", "level": "INFO"}'
|
||||
placeholder={rt.raw(
|
||||
selectedEvent.task_type
|
||||
? 'task_notification_template_example'
|
||||
: 'title_administrator_login_alert_content_administrator_user_6f32cf7c',
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use client';
|
||||
|
||||
// Copyright 2026 Arctel.net
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
@@ -62,6 +62,8 @@ import type {
|
||||
import { PushService } from '@/lib/services/push';
|
||||
|
||||
export function SettingsTab() {
|
||||
const rt = useTranslations('runtime');
|
||||
|
||||
const t = useTranslations('admin.push.settings');
|
||||
const queryClient = useQueryClient();
|
||||
const [deleteTarget, setDeleteTarget] = React.useState<PushChannel | null>(
|
||||
@@ -606,7 +608,7 @@ export function SettingsTab() {
|
||||
toast.success(t('loadedFeishuTemplate'));
|
||||
}}
|
||||
>
|
||||
飞书 Webhook
|
||||
{rt('lark_webhook_c2e0b312')}
|
||||
</Button>
|
||||
<Button
|
||||
variant='outline'
|
||||
@@ -623,7 +625,9 @@ export function SettingsTab() {
|
||||
msgtype: 'markdown',
|
||||
markdown: {
|
||||
title: '$title',
|
||||
text: '### $title\n$content\n\n[查看详情]($url)',
|
||||
text: rt(
|
||||
'title_content_view_details_url_7af4b7d5',
|
||||
),
|
||||
},
|
||||
},
|
||||
null,
|
||||
@@ -633,7 +637,7 @@ export function SettingsTab() {
|
||||
toast.success(t('loadedDingTalkTemplate'));
|
||||
}}
|
||||
>
|
||||
钉钉群机器人
|
||||
{rt('dingtalk_group_bot_5d8efec9')}
|
||||
</Button>
|
||||
<Button
|
||||
variant='outline'
|
||||
@@ -649,8 +653,9 @@ export function SettingsTab() {
|
||||
{
|
||||
msgtype: 'markdown',
|
||||
markdown: {
|
||||
content:
|
||||
'### $title\n$content\n\n[查看详情]($url)',
|
||||
content: rt(
|
||||
'title_content_view_details_url_7af4b7d5',
|
||||
),
|
||||
},
|
||||
},
|
||||
null,
|
||||
@@ -660,7 +665,7 @@ export function SettingsTab() {
|
||||
toast.success(t('loadedWeChatTemplate'));
|
||||
}}
|
||||
>
|
||||
企业微信群机器人
|
||||
{rt('wecom_group_bot_138ea7a8')}
|
||||
</Button>
|
||||
<Button
|
||||
variant='outline'
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { useLocale, useTranslations } from 'next-intl';
|
||||
import { localizeConfigDescription } from '@/i18n/builtin-metadata';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import {
|
||||
@@ -52,6 +53,7 @@ function SystemConfigDetailPanel({
|
||||
saving: boolean;
|
||||
}) {
|
||||
const t = useTranslations('admin.system');
|
||||
const locale = useLocale();
|
||||
return (
|
||||
<ManageDetailPanel isEmpty={!config} onSave={onSave} saving={saving}>
|
||||
<div className='grid grid-cols-1 gap-0'>
|
||||
@@ -138,8 +140,16 @@ function SystemConfigDetailPanel({
|
||||
type='text'
|
||||
value={
|
||||
editData.description !== undefined
|
||||
? editData.description
|
||||
: config?.description || ''
|
||||
? localizeConfigDescription(
|
||||
config?.key ?? '',
|
||||
editData.description,
|
||||
locale,
|
||||
)
|
||||
: localizeConfigDescription(
|
||||
config?.key ?? '',
|
||||
config?.description || '',
|
||||
locale,
|
||||
)
|
||||
}
|
||||
placeholder={t('optionalDescription')}
|
||||
onChange={(e) => {
|
||||
@@ -205,6 +215,7 @@ function SystemConfigDetailPanel({
|
||||
*/
|
||||
export function SystemConfigs() {
|
||||
const t = useTranslations('admin.system');
|
||||
const locale = useLocale();
|
||||
const {
|
||||
systemConfigs: configs,
|
||||
systemConfigsLoading: loading,
|
||||
@@ -309,9 +320,13 @@ export function SystemConfigs() {
|
||||
cell: (item) => (
|
||||
<span
|
||||
className='truncate max-w-[200px] inline-block text-muted-foreground'
|
||||
title={item.description}
|
||||
title={localizeConfigDescription(
|
||||
item.key,
|
||||
item.description,
|
||||
locale,
|
||||
)}
|
||||
>
|
||||
{item.description}
|
||||
{localizeConfigDescription(item.key, item.description, locale)}
|
||||
</span>
|
||||
),
|
||||
width: '200px',
|
||||
|
||||
@@ -47,7 +47,6 @@ import { Badge } from '@/components/ui/badge';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
import { format } from 'date-fns';
|
||||
import { zhCN } from 'date-fns/locale';
|
||||
import { Calendar } from '@/components/ui/calendar';
|
||||
import {
|
||||
Popover,
|
||||
@@ -177,7 +176,6 @@ function DatePickerWithTime({
|
||||
mode='single'
|
||||
selected={date}
|
||||
onSelect={handleDateSelect}
|
||||
locale={zhCN}
|
||||
/>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
|
||||
Reference in New Issue
Block a user