diff --git a/ui/src/components/sidebar/index.tsx b/ui/src/components/sidebar/index.tsx
index afe9148..384d1cb 100644
--- a/ui/src/components/sidebar/index.tsx
+++ b/ui/src/components/sidebar/index.tsx
@@ -6,6 +6,7 @@ import { Modal } from '@c-x/ui';
import { useMemo, useState } from 'react';
import Qrcode from '@/assets/images/qrcode.png';
import Version from './version';
+import { useCommonContext } from '@/hooks/context';
const ADMIN_MENUS = [
{
@@ -14,6 +15,7 @@ const ADMIN_MENUS = [
pathname: 'dashboard',
icon: 'icon-yibiaopan',
show: true,
+ disabled: false,
},
{
label: '对话记录',
@@ -21,6 +23,7 @@ const ADMIN_MENUS = [
pathname: 'chat',
icon: 'icon-duihuajilu1',
show: true,
+ disabled: false,
},
{
label: '补全记录',
@@ -28,6 +31,7 @@ const ADMIN_MENUS = [
pathname: 'completion',
icon: 'icon-buquanjilu',
show: true,
+ disabled: false,
},
{
label: '代码安全',
@@ -35,6 +39,7 @@ const ADMIN_MENUS = [
pathname: 'code-security',
icon: 'icon-daimaanquan1',
show: true,
+ disabled: false,
},
{
label: '模型管理',
@@ -42,6 +47,7 @@ const ADMIN_MENUS = [
pathname: 'model',
icon: 'icon-moxingguanli',
show: true,
+ disabled: false,
},
{
label: '成员管理',
@@ -49,6 +55,7 @@ const ADMIN_MENUS = [
pathname: 'user-management',
icon: 'icon-yonghuguanli1',
show: true,
+ disabled: false,
},
{
label: '管理员',
@@ -56,6 +63,7 @@ const ADMIN_MENUS = [
pathname: 'admin',
icon: 'icon-guanliyuan1',
show: true,
+ disabled: false,
},
];
@@ -66,6 +74,7 @@ const USER_MENUS = [
pathname: '/user/dashboard',
icon: 'icon-yibiaopan',
show: true,
+ disabled: false,
},
{
label: '对话记录',
@@ -73,6 +82,7 @@ const USER_MENUS = [
pathname: '/user/chat',
icon: 'icon-duihuajilu1',
show: true,
+ disabled: false,
},
{
label: '补全记录',
@@ -80,6 +90,7 @@ const USER_MENUS = [
pathname: '/user/completion',
icon: 'icon-buquanjilu',
show: true,
+ disabled: false,
},
// {
// label: '设置',
@@ -111,12 +122,15 @@ const Sidebar = () => {
const { pathname } = useLocation();
const theme = useTheme();
const [showQrcode, setShowQrcode] = useState(false);
+ const { isConfigModel } = useCommonContext();
const menus = useMemo(() => {
if (pathname.startsWith('/user/')) {
return USER_MENUS;
}
- return ADMIN_MENUS;
- }, [pathname]);
+ return isConfigModel
+ ? ADMIN_MENUS.map((item) => ({ ...item, disabled: false }))
+ : ADMIN_MENUS.map((item) => ({ ...item, disabled: true }));
+ }, [pathname, isConfigModel]);
return (
{
zIndex: isActive ? 2 : 1,
color: isActive ? '#FFFFFF' : 'text.primary',
}}
+ onClick={(e) => {
+ if (it.disabled) {
+ e.preventDefault();
+ }
+ }}
>
{
size='small'
onChange={(e) => setTimeRange(e.target.value as TimeRange)}
sx={{ fontSize: 14 }}
+ disabled
>
diff --git a/ui/src/pages/model/components/modelCard.tsx b/ui/src/pages/model/components/modelCard.tsx
index 3daf42b..d3404a9 100644
--- a/ui/src/pages/model/components/modelCard.tsx
+++ b/ui/src/pages/model/components/modelCard.tsx
@@ -48,7 +48,7 @@ const ModelItem = ({
},
});
};
-
+
const onRemoveModel = () => {
Modal.confirm({
title: '删除模型',
@@ -114,18 +114,6 @@ const ModelItem = ({
boxShadow:
'rgba(54, 59, 76, 0.3) 0px 10px 30px 0px, rgba(54, 59, 76, 0.03) 0px 0px 1px 1px',
},
- // '&::before': {
- // content: '""',
- // position: 'absolute',
- // top: 0,
- // left: 0,
- // right: 0,
- // height: 3,
- // background: data.is_active
- // ? 'linear-gradient(90deg, #4CAF50, #66BB6A)'
- // : 'linear-gradient(90deg, #E0E0E0, #BDBDBD)',
- // transition: 'all 0.3s ease',
- // },
}}
>
-
-
+
+
{data.show_name || '未命名'}
-
+
/ {data.model_name}
@@ -187,13 +194,11 @@ const ModelItem = ({
sx={{ mt: 2 }}
>
- {data.is_active && 正在使用}
+ {data.is_active && (
+ 正在使用
+ )}
-
+
{!data.is_active && (
)}
- {!data.is_internal && onEdit(data)}
- >
- 编辑
- }
+ {!data.is_internal && (
+ onEdit(data)}
+ >
+ 编辑
+
+ )}
{data.is_active && (
void;
}
-const ModelCard: React.FC = ({ title, modelType }) => {
+const ModelCard: React.FC = ({
+ title,
+ modelType,
+ data,
+ refreshModel,
+}) => {
const [open, setOpen] = useState(false);
const [editData, setEditData] = useState(null);
@@ -259,12 +273,6 @@ const ModelCard: React.FC = ({ title, modelType }) => {
setEditData(data);
};
- const { data: modelList = [], refresh } = useRequest(() =>
- getMyModelList({
- model_type: modelType,
- })
- );
-
return (
@@ -277,21 +285,18 @@ const ModelCard: React.FC = ({ title, modelType }) => {
添加模型
- {modelList?.length > 0 ? (
+ {data?.length > 0 ? (
- {modelList.map((item) => (
-
-
+ {data.map((item) => (
+
+
))}
) : (
-
+
-
+
暂无模型,请先添加模型
@@ -303,7 +308,7 @@ const ModelCard: React.FC = ({ title, modelType }) => {
setOpen(false);
setEditData(null);
}}
- refresh={refresh}
+ refresh={refreshModel}
data={editData}
type={modelType}
/>
diff --git a/ui/src/pages/model/index.tsx b/ui/src/pages/model/index.tsx
index 44576db..7b612b1 100644
--- a/ui/src/pages/model/index.tsx
+++ b/ui/src/pages/model/index.tsx
@@ -1,16 +1,54 @@
-import React from 'react';
+import React, { useEffect, useRef } from 'react';
import TokenUsage from './components/tokenUsage';
import ModelCard from './components/modelCard';
import { Stack } from '@mui/material';
import { ConstsModelType } from '@/api/types';
+import { useCommonContext } from '@/hooks/context';
+import { Modal } from '@c-x/ui';
const Model = () => {
+ const { coderModel, llmModel, refreshModel, isConfigModel } =
+ useCommonContext();
+ const isFirst = useRef(true);
+ useEffect(() => {
+ if (isFirst.current && !isConfigModel) {
+ isFirst.current = false;
+ let text = '';
+ if (
+ (coderModel || []).length === 0 ||
+ coderModel.every((it) => !it.is_active)
+ ) {
+ text = '代码补全模型尚未配置激活,平台功能暂不可用!';
+ } else if (
+ (llmModel || []).length === 0 ||
+ llmModel.every((it) => !it.is_active)
+ ) {
+ text = '对话模型尚未配置激活,平台功能暂不可用!';
+ } else {
+ text = '模型尚未配置激活,平台功能暂不可用!';
+ }
+ Modal.confirm({
+ title: '提示',
+ content: text,
+ showCancel: false,
+ okText: '去配置',
+ });
+ }
+ }, [isConfigModel, coderModel, llmModel]);
+
return (
-
+
diff --git a/ui/src/pages/user-management/index.tsx b/ui/src/pages/user-management/index.tsx
index fb5dcbd..c4c5757 100644
--- a/ui/src/pages/user-management/index.tsx
+++ b/ui/src/pages/user-management/index.tsx
@@ -115,8 +115,9 @@ const User = () => {
color='info'
sx={{ gap: 2 }}
onClick={() => setThirdPartyLoginSettingModalOpen(true)}
+ disabled
>
- 配置
+ 配置 (敬请期待)
diff --git a/ui/src/pages/user/dashboard/index.tsx b/ui/src/pages/user/dashboard/index.tsx
index 3d5171f..ffa1636 100644
--- a/ui/src/pages/user/dashboard/index.tsx
+++ b/ui/src/pages/user/dashboard/index.tsx
@@ -20,6 +20,7 @@ const Dashboard = () => {
size='small'
onChange={(e) => setTimeRange(e.target.value as TimeRange)}
sx={{ fontSize: 14 }}
+ disabled
>