Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"rehype-raw": "^7.0.0",
"rehype-sanitize": "^6.0.0",
"remark-breaks": "^4.0.0",
"remark-gfm": "^4.0.1"
"remark-gfm": "^4.0.1",
"unist-util-visit": "^5.0.0"
},
"devDependencies": {
"@c-x/cx-swagger-api": "^0.0.10",
Expand Down
3 changes: 3 additions & 0 deletions ui/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 18 additions & 3 deletions ui/src/api/Dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import {
DomainUserEvent,
DomainUserHeatmapResp,
DomainUserStat,
GetCategoryStatDashboardParams,
GetTimeStatDashboardParams,
GetUserCodeRankDashboardParams,
GetUserEventsDashboardParams,
GetUserHeatmapDashboardParams,
GetUserStatDashboardParams,
Expand All @@ -38,14 +41,18 @@ import {
})` OK
*/

export const getCategoryStatDashboard = (params: RequestParams = {}) =>
export const getCategoryStatDashboard = (
query: GetCategoryStatDashboardParams,
params: RequestParams = {},
) =>
request<
WebResp & {
data?: DomainCategoryStat;
}
>({
path: `/api/v1/dashboard/category-stat`,
method: "GET",
query: query,
type: ContentType.Json,
format: "json",
...params,
Expand Down Expand Up @@ -90,14 +97,18 @@ export const getStatisticsDashboard = (params: RequestParams = {}) =>
})` OK
*/

export const getTimeStatDashboard = (params: RequestParams = {}) =>
export const getTimeStatDashboard = (
query: GetTimeStatDashboardParams,
params: RequestParams = {},
) =>
request<
WebResp & {
data?: DomainTimeStat;
}
>({
path: `/api/v1/dashboard/time-stat`,
method: "GET",
query: query,
type: ContentType.Json,
format: "json",
...params,
Expand All @@ -116,14 +127,18 @@ export const getTimeStatDashboard = (params: RequestParams = {}) =>
})` OK
*/

export const getUserCodeRankDashboard = (params: RequestParams = {}) =>
export const getUserCodeRankDashboard = (
query: GetUserCodeRankDashboardParams,
params: RequestParams = {},
) =>
request<
WebResp & {
data?: DomainUserCodeRank[];
}
>({
path: `/api/v1/dashboard/user-code-rank`,
method: "GET",
query: query,
type: ContentType.Json,
format: "json",
...params,
Expand Down
108 changes: 86 additions & 22 deletions ui/src/api/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
/* tslint:disable */
// @ts-nocheck
/*
Expand All @@ -11,32 +10,37 @@
*/

export enum ConstsUserStatus {
UserStatusActive = "active",
UserStatusInactive = "inactive",
UserStatusLocked = "locked",
UserStatusActive = 'active',
UserStatusInactive = 'inactive',
UserStatusLocked = 'locked',
}

export enum ConstsUserPlatform {
UserPlatformEmail = "email",
UserPlatformDingTalk = "dingtalk",
UserPlatformEmail = 'email',
UserPlatformDingTalk = 'dingtalk',
}

export enum ConstsModelType {
ModelTypeLLM = "llm",
ModelTypeCoder = "coder",
ModelTypeEmbedding = "embedding",
ModelTypeAudio = "audio",
ModelTypeReranker = "reranker",
ModelTypeLLM = 'llm',
ModelTypeCoder = 'coder',
ModelTypeEmbedding = 'embedding',
ModelTypeAudio = 'audio',
ModelTypeReranker = 'reranker',
}

export enum ConstsModelStatus {
ModelStatusActive = "active",
ModelStatusInactive = "inactive",
ModelStatusActive = 'active',
ModelStatusInactive = 'inactive',
}

export enum ConstsChatRole {
ChatRoleUser = 'user',
ChatRoleAssistant = 'assistant',
}

export enum ConstsAdminStatus {
AdminStatusActive = "active",
AdminStatusInactive = "inactive",
AdminStatusActive = 'active',
AdminStatusInactive = 'inactive',
}

export interface DomainAcceptCompletionReq {
Expand Down Expand Up @@ -91,9 +95,17 @@ export interface DomainCategoryStat {
work_mode?: DomainCategoryPoint[];
}

export interface DomainChatInfo {
export interface DomainChatContent {
/** 内容 */
content?: string;
created_at?: number;
/** 角色,如user: 用户的提问 assistant: 机器人回复 */
role?: ConstsChatRole;
}

export interface DomainChatInfo {
/** 消息内容 */
contents?: DomainChatContent[];
id?: string;
}

Expand Down Expand Up @@ -622,9 +634,53 @@ export interface GetListCompletionRecordParams {
size?: number;
}

export interface GetCategoryStatDashboardParams {
/**
* 持续时间 (小时或天数)`
* @min 24
* @max 90
*/
duration?: number;
/** 精度: "hour", "day" */
precision: 'hour' | 'day';
/** 用户ID,可jj */
user_id?: string;
}

export interface GetTimeStatDashboardParams {
/**
* 持续时间 (小时或天数)`
* @min 24
* @max 90
*/
duration?: number;
/** 精度: "hour", "day" */
precision: 'hour' | 'day';
/** 用户ID,可jj */
user_id?: string;
}

export interface GetUserCodeRankDashboardParams {
/**
* 持续时间 (小时或天数)`
* @min 24
* @max 90
*/
duration?: number;
/** 精度: "hour", "day" */
precision: 'hour' | 'day';
/** 用户ID,可jj */
user_id?: string;
}

export interface GetUserEventsDashboardParams {
/** 用户ID */
user_id: string;
/**
* 持续时间 (小时或天数)`
* @min 24
* @max 90
*/
/** 用户ID,可jj */
user_id?: string;
}

export interface GetUserHeatmapDashboardParams {
Expand All @@ -633,18 +689,26 @@ export interface GetUserHeatmapDashboardParams {
}

export interface GetUserStatDashboardParams {
/** 用户ID */
/**
* 持续时间 (小时或天数)`
* @min 24
* @max 90
*/
duration?: number;
/** 精度: "hour", "day" */
precision: 'hour' | 'day';
/** 用户ID,可jj */
user_id?: string;
}

export interface GetMyModelListParams {
/** 模型类型 llm:对话模型 coder:代码模型 */
model_type?: "llm" | "coder" | "embedding" | "audio" | "reranker";
model_type?: 'llm' | 'coder' | 'embedding' | 'audio' | 'reranker';
}

export interface GetGetTokenUsageParams {
/** 模型类型 llm:对话模型 coder:代码模型 */
model_type: "llm" | "coder" | "embedding" | "audio" | "reranker";
model_type: 'llm' | 'coder' | 'embedding' | 'audio' | 'reranker';
}

export interface DeleteDeleteUserParams {
Expand Down Expand Up @@ -677,7 +741,7 @@ export interface GetUserOauthCallbackParams {

export interface GetUserOauthSignupOrInParams {
/** 第三方平台 dingtalk */
platform: "email" | "dingtalk";
platform: 'email' | 'dingtalk';
/** 登录成功后跳转的 URL */
redirect_url?: string;
/** 会话ID */
Expand Down
2 changes: 1 addition & 1 deletion ui/src/assets/fonts/iconfont.js

Large diffs are not rendered by default.

95 changes: 95 additions & 0 deletions ui/src/components/markDown/diff.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import React, { useRef, useEffect } from 'react';
import { DiffEditor } from '@monaco-editor/react';

interface DiffProps {
original: string;
modified: string;
language?: string;
height?: string | number;
}

const Diff: React.FC<DiffProps> = ({
original,
modified,
language = 'javascript',
height = 400,
}) => {
const editorRef = useRef<any>(null);
const monacoRef = useRef<any>(null);

// 卸载时主动 dispose
useEffect(() => {
return () => {
if (editorRef.current && monacoRef.current) {
const editor = editorRef.current;
// DiffEditor getModel() 返回 [original, modified]
const models = editor.getModel ? editor.getModel() : [];
if (models && Array.isArray(models)) {
models.forEach(
(model: any) => model && model.dispose && model.dispose()
);
}
}
};
}, []);

const handleMount = (editor: any, monaco: any) => {
editorRef.current = editor;
monacoRef.current = monaco;
};

// 处理高度和宽度样式
const boxHeight = typeof height === 'number' ? `${height}px` : height;
const boxWidth = 1000; // 默认宽度800px

return (
<div
style={{ height: boxHeight, width: boxWidth }}
className='monaco-diff-editor-wrapper'
>
<DiffEditor
height='100%'
width='100%'
language={language}
original={original || ''}
modified={modified || ''}
theme='vs-dark'
onMount={handleMount}
options={{
readOnly: true,
minimap: { enabled: false },
fontSize: 14,
scrollBeyondLastLine: false,
wordWrap: 'off',
lineNumbers: 'on',
glyphMargin: false,
folding: false,
overviewRulerLanes: 0,
guides: {
indentation: true,
highlightActiveIndentation: true,
highlightActiveBracketPair: false,
},
renderLineHighlight: 'none',
cursorStyle: 'line',
cursorBlinking: 'solid',
cursorWidth: 0,
contextmenu: false,
selectionHighlight: false,
selectOnLineNumbers: false,
occurrencesHighlight: 'off',
links: false,
hover: { enabled: false },
codeLens: false,
dragAndDrop: false,
mouseWheelZoom: false,
accessibilitySupport: 'off',
bracketPairColorization: { enabled: false },
matchBrackets: 'never',
}}
/>
</div>
);
};

export default Diff;
Loading