From c742827eb9a4cda3005d938af190f964ce873057 Mon Sep 17 00:00:00 2001
From: Monster <389264167@qq.com>
Date: Thu, 7 Aug 2025 23:50:53 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E5=89=8D=E7=AB=AF?=
=?UTF-8?q?=E6=8E=88=E6=9D=83=E6=BF=80=E6=B4=BB=E7=9A=84=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ui/src/api/License.ts | 74 ++++++++++++
ui/src/api/index.ts | 1 +
ui/src/api/types.ts | 19 +++
ui/src/components/sidebar/aboutModal.tsx | 89 ++++++++++++++
ui/src/components/sidebar/changeLicense.tsx | 82 +++++++++++++
ui/src/components/sidebar/version.tsx | 121 ++++++++++++--------
ui/src/pages/completion/index.tsx | 11 +-
ui/src/pages/user/chat/index.tsx | 19 ++-
8 files changed, 361 insertions(+), 55 deletions(-)
create mode 100644 ui/src/api/License.ts
create mode 100644 ui/src/components/sidebar/aboutModal.tsx
create mode 100644 ui/src/components/sidebar/changeLicense.tsx
diff --git a/ui/src/api/License.ts b/ui/src/api/License.ts
new file mode 100644
index 0000000..554846d
--- /dev/null
+++ b/ui/src/api/License.ts
@@ -0,0 +1,74 @@
+/* eslint-disable */
+/* tslint:disable */
+// @ts-nocheck
+/*
+ * ---------------------------------------------------------------
+ * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
+ * ## ##
+ * ## AUTHOR: acacode ##
+ * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
+ * ---------------------------------------------------------------
+ */
+
+import request, { ContentType, RequestParams } from "./httpClient";
+import {
+ GithubComChaitinMonkeyCodeBackendProDomainLicenseResp,
+ V1LicenseCreatePayload,
+ WebResp,
+} from "./types";
+
+/**
+ * @description Get license
+ *
+ * @tags license
+ * @name V1LicenseList
+ * @summary Get license
+ * @request GET:/api/v1/license
+ * @response `200` `(WebResp & {
+ data?: GithubComChaitinMonkeyCodeBackendProDomainLicenseResp,
+
+})` OK
+ */
+
+export const v1LicenseList = (params: RequestParams = {}) =>
+ request<
+ WebResp & {
+ data?: GithubComChaitinMonkeyCodeBackendProDomainLicenseResp;
+ }
+ >({
+ path: `/api/v1/license`,
+ method: "GET",
+ type: ContentType.Json,
+ format: "json",
+ ...params,
+ });
+
+/**
+ * @description Upload license
+ *
+ * @tags license
+ * @name V1LicenseCreate
+ * @summary Upload license
+ * @request POST:/api/v1/license
+ * @response `200` `(WebResp & {
+ data?: GithubComChaitinMonkeyCodeBackendProDomainLicenseResp,
+
+})` OK
+ */
+
+export const v1LicenseCreate = (
+ data: V1LicenseCreatePayload,
+ params: RequestParams = {},
+) =>
+ request<
+ WebResp & {
+ data?: GithubComChaitinMonkeyCodeBackendProDomainLicenseResp;
+ }
+ >({
+ path: `/api/v1/license`,
+ method: "POST",
+ body: data,
+ type: ContentType.FormData,
+ format: "json",
+ ...params,
+ });
diff --git a/ui/src/api/index.ts b/ui/src/api/index.ts
index 0641a1d..c01e459 100644
--- a/ui/src/api/index.ts
+++ b/ui/src/api/index.ts
@@ -3,6 +3,7 @@ export * from './Billing'
export * from './Cli'
export * from './CodeSnippet'
export * from './Dashboard'
+export * from './License'
export * from './Model'
export * from './OpenAiv1'
export * from './SecurityScanning'
diff --git a/ui/src/api/types.ts b/ui/src/api/types.ts
index 61496d4..94710b3 100644
--- a/ui/src/api/types.ts
+++ b/ui/src/api/types.ts
@@ -1179,6 +1179,13 @@ export interface GithubComChaitinMonkeyCodeBackendEntTypesPosition {
offset?: number;
}
+export interface GithubComChaitinMonkeyCodeBackendProDomainLicenseResp {
+ edition?: number;
+ expired_at?: number;
+ started_at?: number;
+ state?: number;
+}
+
export interface InternalCodesnippetHandlerHttpV1GetContextReq {
/** 返回结果数量限制,默认10 */
limit?: number;
@@ -1372,6 +1379,18 @@ export interface GetUserStatDashboardParams {
user_id?: string;
}
+export interface V1LicenseCreatePayload {
+ /** license type */
+ license_type: "file" | "code";
+ /**
+ * license file
+ * @format binary
+ */
+ license_file: File;
+ /** license code */
+ license_code: string;
+}
+
export interface DeleteDeleteModelParams {
/** 模型ID */
id: string;
diff --git a/ui/src/components/sidebar/aboutModal.tsx b/ui/src/components/sidebar/aboutModal.tsx
new file mode 100644
index 0000000..8a53b04
--- /dev/null
+++ b/ui/src/components/sidebar/aboutModal.tsx
@@ -0,0 +1,89 @@
+import dayjs from 'dayjs';
+import { useState } from 'react';
+import { Ellipsis, Modal } from '@c-x/ui';
+import { Box, Button, Link, Stack } from '@mui/material';
+import { GithubComChaitinMonkeyCodeBackendProDomainLicenseResp } from '@/api/types';
+import ChangeLicense from './changeLicense';
+
+interface LicenseModalProps {
+ open: boolean;
+ onClose: () => void;
+ curVersion: string;
+ latestVersion: string;
+ license: GithubComChaitinMonkeyCodeBackendProDomainLicenseResp | undefined;
+}
+
+const AboutModal = ({
+ open,
+ onClose,
+ curVersion,
+ latestVersion,
+ license
+}: LicenseModalProps) => {
+
+ const [openChangeLicense, setOpenChangeLicense] = useState(false);
+
+ const editionText = (edition: any) => {
+ if (edition === 0) {
+ return '开源版'
+ } else if (edition === 1) {
+ return '联创版'
+ } else if (edition === 2) {
+ return '企业版'
+ } else {
+ return '未知'
+ }
+ }
+
+ return (
+
+
+
+ 当前版本
+ {curVersion}
+
+
+ 产品型号
+ {editionText(license?.edition)}
+ {
+ setOpenChangeLicense(true);
+ }}>切换授权
+
+ {license && license?.edition !== 0 &&
+ 授权时间
+ {dayjs.unix(license.started_at!).format('YYYY-MM-DD')} ~ {dayjs.unix(license.expired_at!).format('YYYY-MM-DD')}
+ }
+
+ {setOpenChangeLicense(false)}} />
+
+ );
+};
+
+export default AboutModal;
\ No newline at end of file
diff --git a/ui/src/components/sidebar/changeLicense.tsx b/ui/src/components/sidebar/changeLicense.tsx
new file mode 100644
index 0000000..23fa232
--- /dev/null
+++ b/ui/src/components/sidebar/changeLicense.tsx
@@ -0,0 +1,82 @@
+import dayjs from 'dayjs';
+import { useState } from 'react';
+import { Ellipsis, message, Modal } from '@c-x/ui';
+import { Box, Button, Link, Stack, TextField } from '@mui/material';
+import { GithubComChaitinMonkeyCodeBackendProDomainLicenseResp } from '@/api/types';
+import { v1LicenseCreate } from '@/api';
+
+interface LicenseModalProps {
+ open: boolean;
+ onClose: () => void;
+}
+
+const ChangeLicense = ({
+ open,
+ onClose
+}: LicenseModalProps) => {
+ const [code, setCode] = useState('');
+ const [verifing, setVerifing] = useState(false);
+
+ const updateLicense = () => {
+ if (code.length === 0) {
+ message.error("授权码不能为空");
+ return;
+ }
+ setVerifing(true);
+ v1LicenseCreate({
+ license_type: 'code',
+ license_code: code,
+ license_file: '' as any
+ }).then((resp: GithubComChaitinMonkeyCodeBackendProDomainLicenseResp) => {
+ message.success("切换授权成功");
+ console.log(resp)
+ setVerifing(false);
+ onClose();
+ setTimeout(() => {
+ location.reload();
+ }, 1000)
+ }).catch(() => {
+ message.error("遇到一点意外,无法激活");
+ setVerifing(false);
+ })
+ }
+
+ return (
+
+
+
+ {
+ setCode(e.target.value);
+ }} />
+
+
+
+
+
+
+
+ );
+};
+
+export default ChangeLicense;
\ No newline at end of file
diff --git a/ui/src/components/sidebar/version.tsx b/ui/src/components/sidebar/version.tsx
index 0429e03..6b94a70 100644
--- a/ui/src/components/sidebar/version.tsx
+++ b/ui/src/components/sidebar/version.tsx
@@ -2,16 +2,32 @@ import HelpCenter from '@/assets/json/help-center.json';
import IconUpgrade from '@/assets/json/upgrade.json';
import LottieIcon from '@/components/lottieIcon';
import { Box, Stack, Tooltip } from '@mui/material';
-import { Icon } from '@c-x/ui';
import { useEffect, useState } from 'react';
import packageJson from '../../../package.json';
+import DiamondIcon from '@mui/icons-material/Diamond';
+import { useRequest } from 'ahooks';
+import { v1LicenseList } from '@/api/License';
+import AboutModal from './aboutModal';
const Version = () => {
- const curVersion =
- import.meta.env.VITE_APP_VERSION || `v${packageJson.version}`;
- const [latestVersion, setLatestVersion] = useState(
- undefined
- );
+ const curVersion = import.meta.env.VITE_APP_VERSION || packageJson.version
+ const [latestVersion, setLatestVersion] = useState(undefined)
+ const [licenseModalOpen, setLicenseModalOpen] = useState(false)
+ const license = useRequest(() => {
+ return v1LicenseList({})
+ }).data
+
+ const editionText = (edition: any) => {
+ if (edition === 0) {
+ return '开源版'
+ } else if (edition === 1) {
+ return '联创版'
+ } else if (edition === 2) {
+ return '企业版'
+ } else {
+ return '未知'
+ }
+ }
useEffect(() => {
fetch('https://release.baizhi.cloud/monkeycode/version.txt')
@@ -25,57 +41,64 @@ const Version = () => {
});
}, []);
- // if (latestVersion === undefined) return null;
-
return (
-
+ {
- window.open('https://monkeycode.docs.baizhi.cloud/welcome');
- }}
- >
-
-
- 免费版
+
+ }} onClick={() => setLicenseModalOpen(true)}>
+
+
+
+ 型号
+
+ {editionText(license?.edition)}
+
+
+ 版本
+ {curVersion}
+ {latestVersion !== `v${curVersion}` &&
+
+
+
+ }
+
+
-
- {curVersion}
- {latestVersion !== `${curVersion}` && (
-
-
-
-
-
- )}
-
-
- );
+ setLicenseModalOpen(false)}
+ latestVersion={latestVersion || ''}
+ curVersion={curVersion}
+ license={license} />
+ >
+ )
};
export default Version;
diff --git a/ui/src/pages/completion/index.tsx b/ui/src/pages/completion/index.tsx
index fdee495..4557e39 100644
--- a/ui/src/pages/completion/index.tsx
+++ b/ui/src/pages/completion/index.tsx
@@ -152,7 +152,16 @@ const Completion = () => {
title: '时间',
width: 200,
render(value: number) {
- return dayjs.unix(value).format('YYYY-MM-DD HH:mm:ss');
+ return (
+
+
+ {dayjs.unix(value).format('YYYY-MM-DD')}
+
+
+ {dayjs.unix(value).format('HH:mm:ss')}
+
+
+ )
},
},
];
diff --git a/ui/src/pages/user/chat/index.tsx b/ui/src/pages/user/chat/index.tsx
index 44b6797..bbb4617 100644
--- a/ui/src/pages/user/chat/index.tsx
+++ b/ui/src/pages/user/chat/index.tsx
@@ -62,7 +62,7 @@ const Chat = () => {
{
dataIndex: 'user',
title: '成员',
- width: 260,
+ width: 200,
render(value: DomainUser) {
return (
{
{
dataIndex: 'input_tokens',
title: '输入 Token',
- width: 150,
+ width: 120,
render(value: number) {
return addCommasToNumber(value);
},
@@ -141,7 +141,7 @@ const Chat = () => {
{
dataIndex: 'output_tokens',
title: '输出 Token',
- width: 150,
+ width: 120,
render(value: number) {
return addCommasToNumber(value);
},
@@ -149,9 +149,18 @@ const Chat = () => {
{
dataIndex: 'created_at',
title: '时间',
- width: 180,
+ width: 160,
render(value: number) {
- return dayjs.unix(value).format('YYYY-MM-DD HH:mm:ss');
+ return (
+
+
+ {dayjs.unix(value).format('YYYY-MM-DD')}
+
+
+ {dayjs.unix(value).format('HH:mm:ss')}
+
+
+ )
},
},
];