diff --git a/config/utils.ts b/config/utils.ts new file mode 100644 index 00000000..0f7147f1 --- /dev/null +++ b/config/utils.ts @@ -0,0 +1,13 @@ +const child_process = require('child_process'); + +export const getBranchInfo = () => { + const latestCommit = child_process + .execSync('git rev-parse HEAD') + .toString() + .trim(); + const versionTag = child_process + .execSync(`git tag --contains ${latestCommit}`) + .toString() + .trim(); + return { version: versionTag, commitId: latestCommit }; +}; diff --git a/mock/userAPI.ts b/mock/userAPI.ts deleted file mode 100644 index 7ef80113..00000000 --- a/mock/userAPI.ts +++ /dev/null @@ -1,20 +0,0 @@ -const users = [ - { id: 0, name: 'Umi', nickName: 'U', gender: 'MALE' }, - { id: 1, name: 'Fish', nickName: 'B', gender: 'FEMALE' }, -]; - -export default { - 'GET /api/v1/queryUserList': (req: any, res: any) => { - res.json({ - success: true, - data: { list: users }, - errorCode: 0, - }); - }, - 'PUT /api/v1/user/': (req: any, res: any) => { - res.json({ - success: true, - errorCode: 0, - }); - }, -}; diff --git a/plugin.ts b/plugin.ts index 9e1f1b95..b1803031 100644 --- a/plugin.ts +++ b/plugin.ts @@ -2,6 +2,7 @@ import { IApi } from '@umijs/max'; export default (api: IApi) => { api.modifyHTML(($) => { + console.log('pllugins=========modifyHTML', $); return $; }); api.onStart(() => { diff --git a/src/components/echarts/config.ts b/src/components/echarts/config.ts index 33975fe1..d0418189 100644 --- a/src/components/echarts/config.ts +++ b/src/components/echarts/config.ts @@ -168,12 +168,12 @@ export const gaugeItemConfig = { }, rich: { value: { - fontSize: 20, + fontSize: 16, fontWeight: '500', color: 'rgba(0, 0, 0, 0.88)' }, unit: { - fontSize: 16, + fontSize: 14, color: 'rgba(0, 0, 0, 0.88)', fontWeight: '500', padding: [0, 0, 0, 2] diff --git a/src/components/seal-form/seal-input.tsx b/src/components/seal-form/seal-input.tsx index f6236008..3f0b4814 100644 --- a/src/components/seal-form/seal-input.tsx +++ b/src/components/seal-form/seal-input.tsx @@ -59,8 +59,9 @@ const SealInput: React.FC = (props) => { e.target.value = e.target.value?.trim?.(); if (!inputRef.current?.input?.value) { setIsFocus(false); - props.onBlur?.(e); } + props.onChange?.(e); + props.onBlur?.(e); }; const handleInput = (e: any) => { diff --git a/src/global.less b/src/global.less index df83f61d..f717513e 100644 --- a/src/global.less +++ b/src/global.less @@ -273,7 +273,8 @@ body { } .ant-pro-sider-logo { - padding-left: 20px; + padding-left: 18px; + border-block-end: none; } .ant-pro-sider-logo-collapsed { @@ -320,20 +321,12 @@ body { .ant-pro-layout { height: 100vh; - // .ant-pro-layout-content { - // padding-block: var(--layout-content-blockpadding); - // padding-inline: var(--layout-content-inlinepadding); - // } + .ant-pro-page-container-children-container { padding-block: var(--layout-content-blockpadding); padding-inline: var(--layout-content-inlinepadding); } - .ant-pro-sider-logo { - padding-left: 22px; - border-block-end: none; - } - .ant-layout { min-height: 100vh; } @@ -382,6 +375,18 @@ body { } } // ======== menu style end ============ +.ant-menu-submenu-popup { + .ant-menu-sub { + .ant-menu-item-only-child { + height: 40px; + line-height: 40px; + + .anticon { + font-size: var(--font-size-middle); + } + } + } +} .user-menu-container { .user-avatar.ant-menu-submenu { @@ -425,9 +430,7 @@ body { left: 0; bottom: 0; right: 0; - // background: url('@/assets/images/bg-11.png') center center no-repeat; - // background-size: cover; - background-color: #fff; + background-color: var(--color-white-1); &::after { content: ''; diff --git a/src/hooks/use-container-scorll.ts b/src/hooks/use-container-scorll.ts index 675aee68..b790679a 100644 --- a/src/hooks/use-container-scorll.ts +++ b/src/hooks/use-container-scorll.ts @@ -21,15 +21,14 @@ export default function useContainerScroll( scrollHeight > clientHeight + scrollTop ) { scroller.current.current.scrollTop = scrollHeight; - toBottomFlag.current = false; + // toBottomFlag.current = false; isWheeled.current = false; - } - if ( + } else if ( !isWheeled.current && scrollHeight > clientHeight + scrollTop && scroller.current?.current ) { - scroller.current.current.scrollTop += 5; + scroller.current.current.scrollTop += 10; window.requestAnimationFrame(scrollerRun); } }; diff --git a/src/layouts/rightRender.tsx b/src/layouts/rightRender.tsx index 9a2faf7d..fc433ea2 100644 --- a/src/layouts/rightRender.tsx +++ b/src/layouts/rightRender.tsx @@ -3,8 +3,14 @@ import avatarImg from '@/assets/images/avatar.png'; import langConfigMap from '@/locales/lang-config-map'; import { + DiscordOutlined, + GithubOutlined, GlobalOutlined, + HomeOutlined, + InfoCircleOutlined, LogoutOutlined, + QuestionCircleOutlined, + ReadOutlined, SettingOutlined } from '@ant-design/icons'; import { getAllLocales, history, setLocale } from '@umijs/max'; @@ -62,6 +68,66 @@ export function getRightRenderContent(opts: { ); } + const helpList = [ + { + key: 'site', + icon: , + label: 'GPUStack', + url: 'https://gpustack.ai/' + }, + { + key: 'github', + icon: , + label: 'GitHub' + }, + { + key: 'Discord', + icon: , + label: 'Discord' + }, + { + key: 'docs', + icon: , + label: intl.formatMessage({ id: 'common.button.docs' }) + }, + { + key: 'version', + icon: , + label: intl.formatMessage({ id: 'common.button.version' }) + } + ]; + + const helpMenu = { + selectedKeys: [], + className: collapsed + ? 'user-menu-container user-menu-collapsed' + : 'user-menu-container', + mode: 'vertical', + expandIcon: false, + inlineCollapsed: collapsed, + triggerSubMenuAction: 'hover', + items: [ + { + key: 'help', + icon: , + label: ( + {intl?.formatMessage?.({ id: 'common.button.help' })} + ), + children: helpList.map((item) => ({ + key: item.key, + label: ( + + {item.icon} + + {item.label} + + + ) + })) + } + ] + }; + const langMenu = { selectedKeys: [], className: collapsed @@ -84,7 +150,9 @@ export function getRightRenderContent(opts: { key, label: ( - {_.get(langConfigMap, [key, 'icon'])} + + {_.get(langConfigMap, [key, 'icon'])} + {_.get(langConfigMap, [key, 'label'])} @@ -139,7 +207,7 @@ export function getRightRenderContent(opts: { label: ( - + {intl?.formatMessage?.({ id: 'common.button.settings' })} @@ -153,7 +221,7 @@ export function getRightRenderContent(opts: { label: ( - + {intl?.formatMessage?.({ id: 'common.button.logout' })} @@ -169,6 +237,12 @@ export function getRightRenderContent(opts: { return (
+ = ({ {item.name} - {getWorkerIp(item)} + {item.worker_name || '-'} {item.source === 'huggingface' diff --git a/src/pages/llmodels/config/types.ts b/src/pages/llmodels/config/types.ts index dd60ea6f..6dd60301 100644 --- a/src/pages/llmodels/config/types.ts +++ b/src/pages/llmodels/config/types.ts @@ -37,6 +37,7 @@ export interface ModelInstanceListItem { download_progress: number; model_id: number; model_name: string; + worker_name: string; id: number; created_at: string; updated_at: string; diff --git a/src/pages/login/components/login-form.tsx b/src/pages/login/components/login-form.tsx index 7d68acf3..22a18ac1 100644 --- a/src/pages/login/components/login-form.tsx +++ b/src/pages/login/components/login-form.tsx @@ -60,7 +60,7 @@ const renderWelCome = (intl: any) => { const LoginForm = () => { const [userInfo, setUserInfo] = useAtom(userAtom); const [initialPassword, setInitialPassword] = useAtom(initialPasswordAtom); - const { initialState, setInitialState } = useModel('@@initialState'); + const { initialState, setInitialState } = useModel('@@initialState') || {}; const intl = useIntl(); const [form] = Form.useForm(); diff --git a/src/pages/playground/components/chat-footer.tsx b/src/pages/playground/components/chat-footer.tsx index 5d271e36..2ef0c43d 100644 --- a/src/pages/playground/components/chat-footer.tsx +++ b/src/pages/playground/components/chat-footer.tsx @@ -8,7 +8,7 @@ import { PlusOutlined } from '@ant-design/icons'; import { useIntl } from '@umijs/max'; -import { Button, Col, Dropdown, Row, Space } from 'antd'; +import { Button, Col, Row, Space } from 'antd'; import { useHotkeys } from 'react-hotkeys-hook'; import { Roles } from '../config'; import '../style/chat-footer.less'; @@ -22,6 +22,7 @@ interface ChatFooterProps { disabled?: boolean; feedback?: React.ReactNode; hasTokenResult?: boolean; + selectedModel?: string; } const ChatFooter: React.FC = (props) => { @@ -35,7 +36,8 @@ const ChatFooter: React.FC = (props) => { onView, feedback, disabled, - hasTokenResult + hasTokenResult, + selectedModel } = props; useHotkeys( HotKeys.SUBMIT.join(','), @@ -58,15 +60,25 @@ const ChatFooter: React.FC = (props) => { - - - - + */} + {!disabled ? ( - - ]} - request={async (params, sorter, filter) => { - const { data, success } = await queryUserList({ - ...params, - // FIXME: remove @ts-ignore - // @ts-ignore - sorter, - filter - }); - return { - data: data?.list || [], - success - }; - }} - columns={columns} - rowSelection={{ - onChange: (_, selectedRows) => setSelectedRows(selectedRows) - }} - /> - {selectedRowsState?.length > 0 && ( - - 已选择{' '} - {selectedRowsState.length}{' '} - 项   -
- } - > - - - - )} - handleModalVisible(false)} - modalVisible={createModalVisible} - > - - onSubmit={async (value) => { - const success = await handleAdd(value); - if (success) { - handleModalVisible(false); - if (actionRef.current) { - actionRef.current.reload(); - } - } - }} - rowKey="id" - type="form" - columns={columns} - /> - - {stepFormValues && Object.keys(stepFormValues).length ? ( - { - const success = await handleUpdate(value); - if (success) { - handleUpdateModalVisible(false); - setStepFormValues({}); - if (actionRef.current) { - actionRef.current.reload(); - } - } - }} - onCancel={() => { - handleUpdateModalVisible(false); - setStepFormValues({}); - }} - updateModalVisible={updateModalVisible} - values={stepFormValues} - /> - ) : null} - - { - setRow(undefined); - }} - closable={false} - > - {row?.name && ( - - column={2} - title={row?.name} - request={async () => ({ - data: row || {} - })} - params={{ - id: row?.name - }} - columns={columns} - /> - )} - - - ); -}; - -export default TableList; diff --git a/src/pages/users/index.tsx b/src/pages/users/index.tsx index df248af6..559dec16 100644 --- a/src/pages/users/index.tsx +++ b/src/pages/users/index.tsx @@ -290,6 +290,11 @@ const Users: React.FC = () => { ); }} /> + ('/api/v1/queryUserList', { - method: 'GET', - params: { - ...params, - }, - ...(options || {}), - }); -} - -/** 此处后端没有提供注释 POST /api/v1/user */ -export async function addUser( - body?: API.UserInfoVO, - options?: { [key: string]: any }, -) { - return request('/api/v1/user', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - data: body, - ...(options || {}), - }); -} - -/** 此处后端没有提供注释 GET /api/v1/user/${param0} */ -export async function getUserDetail( - params: { - // path - /** userId */ - userId?: string; - }, - options?: { [key: string]: any }, -) { - const { userId: param0 } = params; - return request(`/api/v1/user/${param0}`, { - method: 'GET', - params: { ...params }, - ...(options || {}), - }); -} - -/** 此处后端没有提供注释 PUT /api/v1/user/${param0} */ -export async function modifyUser( - params: { - // path - /** userId */ - userId?: string; - }, - body?: API.UserInfoVO, - options?: { [key: string]: any }, -) { - const { userId: param0 } = params; - return request(`/api/v1/user/${param0}`, { - method: 'PUT', - headers: { - 'Content-Type': 'application/json', - }, - params: { ...params }, - data: body, - ...(options || {}), - }); -} - -/** 此处后端没有提供注释 DELETE /api/v1/user/${param0} */ -export async function deleteUser( - params: { - // path - /** userId */ - userId?: string; - }, - options?: { [key: string]: any }, -) { - const { userId: param0 } = params; - return request(`/api/v1/user/${param0}`, { - method: 'DELETE', - params: { ...params }, - ...(options || {}), - }); -} diff --git a/src/services/demo/index.ts b/src/services/demo/index.ts deleted file mode 100644 index e0cfa732..00000000 --- a/src/services/demo/index.ts +++ /dev/null @@ -1,7 +0,0 @@ -/* eslint-disable */ -// 该文件由 OneAPI 自动生成,请勿手动修改! - -import * as UserController from './UserController'; -export default { - UserController, -}; diff --git a/src/services/demo/typings.d.ts b/src/services/demo/typings.d.ts deleted file mode 100644 index d0e2033c..00000000 --- a/src/services/demo/typings.d.ts +++ /dev/null @@ -1,68 +0,0 @@ -/* eslint-disable */ -// 该文件由 OneAPI 自动生成,请勿手动修改! - -declare namespace API { - interface PageInfo { - /** -1 */ - current?: number; - pageSize?: number; - total?: number; - list?: Array>; - } - - interface PageInfo_UserInfo_ { - /** -1 */ - current?: number; - pageSize?: number; - total?: number; - list?: Array; - } - - interface Result { - success?: boolean; - errorMessage?: string; - data?: Record; - } - - interface Result_PageInfo_UserInfo__ { - success?: boolean; - errorMessage?: string; - data?: PageInfo_UserInfo_; - } - - interface Result_UserInfo_ { - success?: boolean; - errorMessage?: string; - data?: UserInfo; - } - - interface Result_string_ { - success?: boolean; - errorMessage?: string; - data?: string; - } - - type UserGenderEnum = 'MALE' | 'FEMALE'; - - interface UserInfo { - id?: string; - name?: string; - /** nick */ - nickName?: string; - /** email */ - email?: string; - gender?: UserGenderEnum; - } - - interface UserInfoVO { - name?: string; - /** nick */ - nickName?: string; - /** email */ - email?: string; - } - - type definitions_0 = null; -}