feat: more language

This commit is contained in:
jialin
2024-05-22 19:28:08 +08:00
parent 46a9e6a931
commit 7ff9b44644
20 changed files with 424 additions and 42 deletions
+8 -5
View File
@@ -32,11 +32,14 @@ export default defineConfig({
model: {},
initialState: {},
request: {},
// locale: {
// // 默认使用 src/locales/zh-CN.ts 作为多语言文件
// default: 'zh-CN',
// baseSeparator: '-',
// },
locale: {
antd: true,
baseNavigator: true,
baseSeparator: '-',
default: 'zh-CN',
title: false,
useLocalStorage: true
},
layout: false,
routes,
npmClient: 'pnpm'
+1 -1
View File
@@ -26,7 +26,7 @@ export default [
path: '/models',
key: 'models',
icon: 'Block',
component: './models'
component: './llm-models'
},
{
name: 'Nodes',
+1 -1
View File
@@ -5,7 +5,7 @@
// 全局初始化数据配置,用于 Layout 用户信息和权限初始化
// 更多信息见文档:https://umijs.org/docs/api/runtime-config#getinitialstate
export async function getInitialState(): Promise<{ name: string }> {
return { name: 'admin', logout: true };
return { name: 'admin' };
}
// export const layout: RunTimeLayoutConfig = () => {
-5
View File
@@ -43,10 +43,6 @@ const SealSelect: React.FC<SelectProps & SealFormItemProps> = (props) => {
props.onBlur?.(e);
};
const handleOnSearch = (val: any) => {
props.onSearch?.(val);
};
return (
<Wrapper
status={status}
@@ -60,7 +56,6 @@ const SealSelect: React.FC<SelectProps & SealFormItemProps> = (props) => {
ref={inputRef}
onFocus={handleOnFocus}
onBlur={handleOnBlur}
onSearch={handleOnSearch}
onChange={handleChange}
notFoundContent={null}
>
+2 -1
View File
@@ -87,7 +87,8 @@ export default (props: any) => {
const userConfig = {
title: '',
layout: 'mix'
layout: 'mix',
locale: true
};
const formatMessage = undefined;
+9
View File
@@ -0,0 +1,9 @@
import common from './en-US/common';
import menu from './en-US/menu';
import models from './en-US/models';
export default {
...common,
...menu,
...models
};
+178
View File
@@ -0,0 +1,178 @@
export default {
'common.button.resetdefault': 'Reset to default',
'common.button.perview': 'Preview',
'common.button.readonly': 'Readonly',
'common.button.editmode': 'Edit mode',
'common.button.add': 'Add',
'common.button.continue': 'Continue',
'common.button.upload': 'Upload',
'common.button.save': 'Save',
'common.button.saverun': 'Save and Run',
'common.button.run': 'Run',
'common.button.cancel': 'Cancel',
'common.button.approval': 'Approve',
'common.button.reject': 'Reject',
'common.button.more': 'More',
'common.button.discard': 'Sure to discard',
'common.button.submit': 'Submit',
'settings.system': 'System settings',
'common.button.search': 'Search',
'common.button.clear': 'Clear',
'common.holder.search': 'Search',
'common.button.view': 'View details',
'common.button.detail': 'View details',
'common.button.reset': 'Reset',
'common.button.export': 'Export',
'common.button.import': 'Import',
'common.button.retry': 'Retry',
'common.button.apply': 'Apply',
'common.button.create.now': 'Create now',
'common.button.add.now': 'Add now',
'common.button.refresh': 'Refresh',
'common.button.delete': 'Delete',
'common.button.create': 'Create',
'common.button.clone': 'Clone',
'common.button.rollback': 'Rollback',
'common.button.new': 'New { text }',
'common.button.enabled': 'Enabled',
'common.button.disabled': 'Disabled',
'common.button.upgrade': 'Upgrade',
'common.input.holder': 'Please enter',
'common.button.edit': 'Edit',
'common.button.authorize': 'Role Authorization',
'common.button.confirm': 'Confirm',
'common.table.operation': 'Operation',
'common.table.createTime': 'Created',
'common.table.updateTime': 'Updated',
'common.table.description': 'Description',
'common.table.name': 'Name',
'common.table.status': 'Status',
'common.table.name.list': '{type} Name',
'common.search.name.placeholder': 'filter by name',
'common.search.id.placeholder': 'filter by ID',
'common.filter.byId': 'filter by ID',
'common.table.type': 'Type',
'common.table.default': 'Default Value',
'common.copy.success': 'Copied success!',
'common.copy.fail': 'Copied failed!',
'common.delete.success': 'delete success!',
'common.delete.fail': 'delete failed',
'common.edit.success': 'update success!',
'common.edit.fail': 'update failed',
'common.title.config': 'Configuration',
'common.message.fail': 'failed!',
'common.message.success': 'succeed!',
'common.delete.tips': 'Are you sure you want to delete?',
'common.button.close': 'Close',
'common.button.done': 'Done',
'common.button.next': 'Next',
'common.button.prev': 'Previous',
'common.button.back': 'Back',
'common.button.discardChange': 'Discard',
'common.tips.save':
'You have unsaved changes, leaving this page will discard changes.',
'common.tips.cancel':
'You have unsaved changes. Are you sure you want to discard changes?',
'common.tips.discard': 'Discard Changes?',
'common.tips.title': 'Tips:',
'common.input.range.start': 'start value',
'common.input.range.end': 'end value',
'common.footer.version': 'Versions',
'common.footer.version.title': 'Version Information',
'common.footer.version.web': 'UI',
'common.footer.version.server': 'Server',
'common.form.field.optional': 'optional',
'common.form.field.input.required': 'required',
'common.form.field.select.required': 'required',
'common.select.option': 'All',
'common.checbox.all': 'All',
'common.select.all': 'All {type}',
'common.data.unkonwn': 'Unknown',
'common.data.none': 'No Data',
'common.action.none': 'Not Available',
'common.button.addfile': 'Add File',
'common.logout.msg': 'Logout succeeded',
'common.button.logout': 'Logout',
'common.form.rule.select': 'please select {name}',
'common.form.rule.input': '{name} is required',
'common.form.key': 'the same key exists',
'common.date.utc': 'UTC time',
'common.date.local': 'Local time',
'common.button.deploy': 'Deploy',
'common.button.logs': 'Logs',
'common.ws.close': 'The connection was lost, do you want to reconnect?',
'common.ws.reconnect': 'Reconnect',
'common.input.key': 'key',
'common.input.value': 'value',
'common.input.type': 'type',
'common.input.visible': 'visibility',
'common.input.description': 'description',
'common.time.day': 'day',
'common.chart.filter.holder': 'filter data items',
'common.chart.filter.tips': 'View more by filter',
'common.permission.401': 'Not logged in',
'common.permission.403': 'Permission Denied',
'common.permission.action.post': 'Create',
'common.permission.action.get': 'Search',
'common.permission.action.delete': 'Delete',
'common.permission.action.put': 'Update',
'common.button.settings': 'Settings',
'common.button.management': 'Management',
'common.cli.download': 'Download CLI',
'common.button.download': 'Download',
'common.table.sensitive': 'Sensitive',
'common.table.createdBy': 'Operator',
'common.table.yes': 'Yes',
'common.table.no': 'No',
'common.validate.labelName':
'Only contains lowercase alphanumeric or "-", starts with an alphanumeric and ends with an alphanumeric.',
'common.search.nodata': 'no matching data',
'common.data.empty': 'No Data',
'common.tips.change': 'there are unsaved changes!',
'common.copy.notSupport': 'Your browser does not support Clipboard API',
'common.title.basicInfo': 'Basic',
'common.help.need': 'Need help?',
'common.help.eg': 'e.g.:',
'common.filter.label': 'Filters',
'common.filter.isrequired.holder': 'Optional',
'common.filter.isrequired.true': 'Required',
'common.filter.isrequired.false': 'Not Required',
'common.filter.attrs': 'Attributes',
'common.filter.filled.holder': 'Fill in',
'common.filter.filled.true': 'Filled',
'common.filter.filled.false': 'Not Filled',
'common.environment.development': 'Development',
'common.environment.production': 'Production',
'common.environment.staging': 'Staging',
'common.time.label': 'Duration',
'common.time.hour': 'hour',
'common.time.minute': 'minutes',
'common.issue.report': 'Report an issue',
'common.social.discord': 'Join Our Discord',
'common.table.mark': 'Comment',
'common.table.rollback.mark': 'Rollback Comment',
'common.button.saveDeploy': 'Save & Deploy',
'common.button.savePreview': 'Save & Preview',
'common.button.rollbackPreview': 'Rollback Preview',
'common.button.deployPreview': 'Deployment Preview',
'common.button.draft': 'Save Draft',
'common.button.stop': 'Stop',
'common.button.start': 'Start',
'common.rule.object.key': 'key cannot be empty',
'common.confirm.title': 'Are you sure you want to {action}?',
'common.rule.name': 'Name is required',
'common.rule.wordlimit': 'Maximum {length} characters',
'common.docs.link.tips': 'View Documentation',
'common.docs.link': 'here',
'common.result.nodata.subtitle': 'Please check if it has been created',
'common.result.nodata.title': '{type} not found',
'common.rule.array': 'should be in array format',
'common.rule.object': 'should be in object format',
'common.rule.syntaxerror': 'syntax error',
'common.code.hide.tips': '... Hide {rows} lines, click to expand ...',
'common.nodata.created': 'No {type} has been created yet',
'common.nodata.added': 'No {type} has been added yet',
'common.status.edited': 'Edited',
'common.table.user': '用户',
'common.settings.instructions': 'Instructions'
};
+1
View File
@@ -0,0 +1 @@
export default {};
+3
View File
@@ -0,0 +1,3 @@
export default {
'models.button.deploy': 'Deploy Model'
};
+9
View File
@@ -0,0 +1,9 @@
import menu from './en-US/menu';
import common from './zh-CN/common';
import models from './zh-CN/models';
export default {
...common,
...menu,
...models
};
+174
View File
@@ -0,0 +1,174 @@
export default {
'common.button.resetdefault': '恢复默认',
'common.button.perview': '预览',
'common.button.readonly': '只读',
'common.button.editmode': '编辑模式',
'common.button.add': '添加',
'common.button.continue': '继续',
'common.button.upload': '上传',
'common.button.save': '保存',
'common.button.saverun': '保存并运行',
'common.button.run': '运行',
'common.button.submit': '提交',
'common.button.approval': '同意',
'common.button.reject': '不同意',
'common.button.more': '更多',
'common.button.discard': '确定放弃',
'common.button.cancel': '取消',
'common.button.search': '查询',
'common.button.clear': '清除',
'common.button.reset': '重置',
'common.button.export': '导出',
'common.button.import': '导入',
'common.button.retry': '重试',
'common.button.apply': '应用',
'common.button.create.now': '立即创建',
'common.button.add.now': '立即添加',
'common.button.refresh': '刷新',
'common.button.enabled': '启用',
'common.button.disabled': '禁用',
'common.button.view': '查看明细',
'common.button.detail': '详情',
'common.button.delete': '删除',
'common.button.create': '新建',
'common.button.clone': '克隆',
'common.button.rollback': '回滚',
'common.button.new': '新建{ text }',
'common.button.upgrade': '升级',
'common.input.holder': '请输入',
'common.holder.search': '搜索',
'common.button.edit': '编辑',
'common.button.authorize': '角色授权',
'common.button.confirm': '确定',
'common.table.operation': '操作',
'common.table.createTime': '创建时间',
'common.table.updateTime': '更新时间',
'common.table.description': '描述',
'common.table.name': '名称',
'common.table.status': '状态',
'common.table.name.list': '{type}名称',
'common.search.name.placeholder': '名称搜索',
'common.search.id.placeholder': 'ID搜索',
'common.table.type': '类型',
'common.table.default': '默认值',
'common.copy.success': '复制成功',
'common.copy.fail': '复制失败',
'common.delete.success': '删除成功',
'common.delete.fail': '删除失败',
'common.edit.success': '编辑成功',
'common.edit.fail': '编辑失败',
'common.message.fail': '失败!',
'common.message.success': '成功!',
'common.delete.tips': '是否确定删除?',
'common.button.close': '关闭',
'common.button.done': '完成',
'common.button.next': '下一步',
'common.button.prev': '上一步',
'common.button.back': '返回',
'common.button.discardChange': '放弃',
'common.tips.save': '您有未保存的更改,离开此页面将放弃更改。',
'common.tips.cancel': '您有未保存的更改。确定放弃更改?',
'common.tips.discard': '放弃更改?',
'common.tips.title': '提示:',
'common.input.range.start': '起始值',
'common.input.range.end': '结束值',
'common.footer.version': '版本',
'common.footer.version.title': '版本信息',
'common.footer.version.web': 'UI',
'common.footer.version.server': '服务端',
'common.form.field.optional': '可选',
'common.form.field.input.required': '必填',
'common.form.field.select.required': '必选',
'common.select.option': '全部',
'common.data.unkonwn': '未知',
'common.data.none': '暂无',
'common.action.none': '无',
'common.checbox.all': '全选',
'common.select.all': '全部{type}',
'common.button.addfile': '添加文件',
'common.logout.msg': '登出成功',
'common.button.logout': '登出',
'common.form.rule.select': '请选择{name}',
'common.form.rule.input': '{name}必填',
'common.form.key': '存在相同的key',
'common.date.utc': 'UTC时间',
'common.date.local': '本地时间',
'common.button.deploy': '部署',
'common.button.logs': '查看日志',
'common.ws.close': '连接已断开,是否重新连接?',
'common.ws.reconnect': '重新连接',
'common.input.key': '键',
'common.input.value': '值',
'common.input.type': '类型',
'common.input.visible': '是否可见',
'common.input.description': '描述',
'common.time.day': '天',
'common.chart.filter.holder': '过滤数据项',
'common.chart.filter.tips': '过滤查看更多数据项',
'common.permission.401': '未登录',
'common.permission.403': '权限不足',
'common.permission.action.post': '新增',
'common.permission.action.get': '查询',
'common.permission.action.delete': '删除',
'common.permission.action.put': '更新',
'common.button.settings': '设置',
'common.button.management': '管理',
'common.title.config': '配置',
'common.cli.download': '客户端下载',
'common.button.download': '下载',
'common.table.sensitive': '是否敏感',
'common.table.createdBy': '执行人',
'common.table.yes': '是',
'common.table.no': '否',
'common.validate.labelName':
'仅包含小写字母数字或"-",以字母数字开头,以字母数字结尾。',
'common.search.nodata': '无匹配数据',
'common.data.empty': '暂无数据',
'common.tips.change': '有未保存的更改!',
'common.copy.notSupport': '您的浏览器不支持剪贴板 API',
'common.title.basicInfo': '基本信息',
'common.help.need': '需要帮助?',
'common.help.eg': '例:',
'common.filter.label': '筛选',
'common.filter.isrequired.holder': '是否必填',
'common.filter.isrequired.true': '必填',
'common.filter.isrequired.false': '非必填',
'common.filter.attrs': '属性名',
'common.filter.filled.holder': '是否填写',
'common.filter.filled.true': '已填写',
'common.filter.filled.false': '未填写',
'common.environment.development': '开发',
'common.environment.production': '生产',
'common.environment.staging': '预发布',
'common.time.label': '时间',
'common.time.hour': '小时',
'common.time.minute': '分钟',
'common.issue.report': '问题反馈',
'common.social.discord': '加入我们的Discord',
'common.table.mark': '备注',
'common.table.rollback.mark': '回滚备注',
'common.button.saveDeploy': '保存并部署',
'common.button.savePreview': '保存并预览',
'common.button.rollbackPreview': '回滚并预览',
'common.button.deployPreview': '部署预览',
'common.button.draft': '保存草稿',
'common.button.stop': '停止',
'common.button.start': '启动',
'common.rule.object.key': '键不能为空',
'common.confirm.title': '确定要{action}吗?',
'common.rule.name': '名称必填',
'common.rule.wordlimit': '最多输入{length}个字符',
'common.docs.link.tips': '查看文档',
'common.docs.link': '这里',
'common.result.nodata.subtitle': '请检查是否已创建',
'common.result.nodata.title': '未找到{type}',
'common.rule.array': '必须为数组格式',
'common.rule.object': '必须为对象格式',
'common.rule.syntaxerror': '输入语法有误',
'common.code.hide.tips': '... 隐藏 {rows} 行,点击展开 ...',
'common.nodata.created': '尚未创建{type}',
'common.nodata.added': '尚未添加{type}',
'common.status.edited': '已编辑',
'common.table.user': '用户',
'common.settings.instructions': '操作指引'
};
+1
View File
@@ -0,0 +1 @@
export default {};
+3
View File
@@ -0,0 +1,3 @@
export default {
'models.button.deploy': '部署模型'
};
@@ -36,7 +36,7 @@ const dataSource: NodeItem[] = [
state: 'ALIVE'
},
{
id: 1,
id: 2,
name: '192.168.1.2',
address: '192.168.1.5',
hostname: 'node-2',
@@ -81,7 +81,7 @@ const dataSource: NodeItem[] = [
}
];
const Models: React.FC = () => {
const ModelNodes: React.FC = () => {
const rowSelection = useTableRowSelection();
const [selectName, setSelectName] = useState<string>('llama3:latest');
@@ -186,6 +186,7 @@ const Models: React.FC = () => {
></PageTools>
<Table
dataSource={dataSource}
rowKey={(record) => record.id}
loading={loading}
onChange={handleTableChange}
pagination={false}
@@ -265,4 +266,4 @@ const Models: React.FC = () => {
);
};
export default Models;
export default ModelNodes;
+1 -2
View File
@@ -25,9 +25,8 @@ const Overview: React.FC = (props) => {
return (
<Row gutter={[20, 20]} className={styles.row}>
{overviewConfigs.map((config, index) => (
<Col span={5}>
<Col span={5} key={config.key}>
<CardItem
key={config.key}
label={config.label}
value={data[config.key] || 0}
bgColor={config.backgroundColor}
@@ -46,6 +46,7 @@ const UtilizationOvertime: React.FC = () => {
color: ['red', 'blue', 'green'],
colorField: 'type',
slider: false,
shapeField: 'smooth',
axis: {
x: {
textStyle: {
@@ -53,24 +54,22 @@ const UtilizationOvertime: React.FC = () => {
}
}
},
xAxis: {
autoRotate: true
},
yAxis: {
nice: true,
label: {
autoRotate: true
}
},
point: {
shapeField: 'circle',
sizeField: 2
},
style: {
lineWidth: 1.4
},
legend: {
color: {
layout: { justifyContent: 'center' }
}
},
tooltip: {
title: 'time',
items: [{ channel: 'y' }]
},
label: {
autoRotate: true
}
@@ -11,13 +11,12 @@ type AddModalProps = {
onOk: () => void;
onCancel: () => void;
};
const AddModal: React.FC<AddModalProps> = ({
title,
action,
open,
onOk,
onCancel
}) => {
const AddModal: React.FC<AddModalProps> = (props) => {
const { title, action, open, onOk, onCancel } = props || {};
if (!open) {
return null;
}
console.log('modal open', open);
const [form] = Form.useForm();
return (
<Modal
@@ -10,8 +10,9 @@ import {
WechatWorkOutlined
} from '@ant-design/icons';
import { PageContainer } from '@ant-design/pro-components';
import { useNavigate } from '@umijs/max';
import { useIntl, useNavigate } from '@umijs/max';
import {
App,
Button,
Input,
Modal,
@@ -21,7 +22,7 @@ import {
Tooltip,
message
} from 'antd';
import { useState } from 'react';
import { StrictMode, useState } from 'react';
import AddModal from './components/add-modal';
const { Column } = Table;
@@ -44,6 +45,8 @@ const dataSource = [
];
const Models: React.FC = () => {
const { modal } = App.useApp();
const intl = useIntl();
const navigate = useNavigate();
const rowSelection = useTableRowSelection();
const { sortOrder, setSortOrder } = useTableSort({
@@ -125,7 +128,7 @@ const Models: React.FC = () => {
navigate('/playground');
};
return (
<>
<StrictMode>
<PageContainer
ghost
header={{
@@ -157,7 +160,7 @@ const Models: React.FC = () => {
type="primary"
onClick={handleAddModal}
>
Import Module
{intl?.formatMessage?.({ id: 'models.button.deploy' })}
</Button>
<Button
icon={<DeleteOutlined />}
@@ -246,7 +249,7 @@ const Models: React.FC = () => {
onCancel={handleModalCancel}
onOk={handleModalOk}
></AddModal>
</>
</StrictMode>
);
};
+2 -1
View File
@@ -34,7 +34,7 @@ const dataSource: NodeItem[] = [
state: 'ALIVE'
},
{
id: 1,
id: 2,
name: '192.168.1.2',
address: '192.168.1.5',
hostname: 'node-2',
@@ -173,6 +173,7 @@ const Models: React.FC = () => {
dataSource={dataSource}
rowSelection={rowSelection}
loading={loading}
rowKey="id"
onChange={handleTableChange}
pagination={{
showSizeChanger: true,
+5 -2
View File
@@ -44,7 +44,7 @@ const Playground: React.FC = () => {
<PageContainer
title={false}
extra={[
<Space size={20}>
<Space size={20} key="space">
<Select
showSearch
options={ModelList}
@@ -52,6 +52,7 @@ const Playground: React.FC = () => {
value={selectedModel}
onChange={handleSelectChange}
variant="filled"
key="model-select"
></Select>
<Popover
content={
@@ -65,17 +66,19 @@ const Playground: React.FC = () => {
overlayStyle={{ top: 70 }}
overlayInnerStyle={{ paddingRight: 0 }}
placement="bottomRight"
key="popover"
>
<Button
onClick={handleTogglePopover}
type="primary"
shape="circle"
key="button"
icon={<ControlOutlined />}
></Button>
</Popover>
</Space>
]}
footer={[<MessageInput />]}
footer={[<MessageInput key="message" />]}
>
<div style={{ display: 'flex', justifyContent: 'center' }}>
<ChatContent messageList={messageList}></ChatContent>