ac9bbfd472
补齐历史缺译并统一整句插值。九语覆盖 100%,静态检查及 713 项单测通过。
119 lines
3.7 KiB
React
119 lines
3.7 KiB
React
/*
|
||
Copyright (C) 2025 QuantumNous
|
||
|
||
This program is free software: you can redistribute it and/or modify
|
||
it under the terms of the GNU Affero General Public License as
|
||
published by the Free Software Foundation, either version 3 of the
|
||
License, or (at your option) any later version.
|
||
|
||
This program is distributed in the hope that it will be useful,
|
||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
GNU Affero General Public License for more details.
|
||
|
||
You should have received a copy of the GNU Affero General Public License
|
||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||
|
||
For commercial licensing, please contact support@quantumnous.com
|
||
*/
|
||
|
||
import { I18N_TECHNICAL_TEXT } from '../../../i18n/technicalText.js';
|
||
import React from 'react';
|
||
import { Button, Drawer, Tag } from 'antd';
|
||
import { useTranslation } from 'react-i18next';
|
||
|
||
/**
|
||
* 原型 .sm-detail-drawer:Ant Design Drawer(620px,窄屏 100vw),正文为描述 + 来源 / 标签 / 适用场景 /
|
||
* 触发词分节与更新时间,页脚「关闭」+ 页面已有操作。children 插在来源之后(如企业治理参考)。
|
||
* Portal 挂 .sm-theme 并复用页面的主题变量(themeStyle),不新增 ConfigProvider。
|
||
*/
|
||
const SkillDetailDrawer = ({
|
||
skill,
|
||
open,
|
||
onClose,
|
||
sourceText,
|
||
tagLabel,
|
||
themeStyle,
|
||
actions = null,
|
||
children = null,
|
||
}) => {
|
||
const { t, i18n } = useTranslation();
|
||
return (
|
||
<Drawer
|
||
title={skill?.name}
|
||
open={open}
|
||
onClose={onClose}
|
||
size={620}
|
||
rootClassName='sm-detail-drawer sm-theme'
|
||
rootStyle={themeStyle}
|
||
footer={
|
||
skill ? (
|
||
<div className='sm-detail-footer'>
|
||
<Button onClick={onClose}>{t('关闭')}</Button>
|
||
{actions}
|
||
</div>
|
||
) : null
|
||
}
|
||
mask={{ closable: true }}
|
||
>
|
||
{skill ? (
|
||
<>
|
||
<p className='sm-detail-description'>{skill.description}</p>
|
||
<section>
|
||
<h3>{t('来源')}</h3>
|
||
<p>
|
||
{sourceText} · {skill.canonical_id}{' '}
|
||
{I18N_TECHNICAL_TEXT.VERSION_PREFIX}
|
||
{skill.version_no}
|
||
</p>
|
||
</section>
|
||
{children}
|
||
{skill.tags?.length ? (
|
||
<section>
|
||
<h3>{t('标签')}</h3>
|
||
<div className='sm-detail-tags'>
|
||
{skill.tags.map((tag) => (
|
||
<Tag key={tag} variant='filled'>
|
||
{tagLabel(tag)}
|
||
</Tag>
|
||
))}
|
||
</div>
|
||
</section>
|
||
) : null}
|
||
{skill.scenarios?.length ? (
|
||
<section>
|
||
<h3>{t('适用场景')}</h3>
|
||
<ul>
|
||
{skill.scenarios.map((item) => (
|
||
<li key={item}>{item}</li>
|
||
))}
|
||
</ul>
|
||
</section>
|
||
) : null}
|
||
{skill.triggers?.length ? (
|
||
<section>
|
||
<h3>{t('触发词')}</h3>
|
||
<p>{t('任务描述中出现这些词时,该技能会自动生效。')}</p>
|
||
<div className='sm-detail-tags'>
|
||
{skill.triggers.map((item) => (
|
||
<Tag key={item} variant='filled'>
|
||
{item}
|
||
</Tag>
|
||
))}
|
||
</div>
|
||
</section>
|
||
) : null}
|
||
<div className='sm-detail-updated'>
|
||
{t('更新时间')}:
|
||
{skill.updated_at
|
||
? new Date(skill.updated_at * 1000).toLocaleString(i18n.language)
|
||
: '-'}
|
||
</div>
|
||
</>
|
||
) : null}
|
||
</Drawer>
|
||
);
|
||
};
|
||
|
||
export default SkillDetailDrawer;
|