From bf05991f5d722d0fa789c0b6861c4f8236bfc82c Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Wed, 23 Apr 2025 15:11:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E7=AE=A1=E7=90=86=E5=91=98=E9=99=90=E5=88=B6=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=80=9A=E7=94=A8=E6=99=BA=E8=83=BD=E4=B8=8E?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E8=AF=8D=E9=83=A8=E5=88=86=E7=9A=84=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E5=8F=82=E6=95=B0=E9=80=89=E6=8B=A9=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/upload-file.vue | 18 ++++- src/views/pages/login.vue | 1 + src/views/pages/register.vue | 1 + src/views/system/gen-chat.vue | 134 ++++++++++++++++++++++++++++---- src/views/system/prompt-gen.vue | 91 ++++++++++++++++++++-- 5 files changed, 220 insertions(+), 25 deletions(-) diff --git a/src/components/upload-file.vue b/src/components/upload-file.vue index 1d96121..453c85f 100644 --- a/src/components/upload-file.vue +++ b/src/components/upload-file.vue @@ -29,7 +29,7 @@ const handle = (rawFile: any) => { console.log(rawFile); }; const allowedTypes = ['doc', 'docx', 'pdf', 'txt', 'png', 'jpg', 'jpeg','md', "epub", 'go', 'java', 'py', 'js', 'html', 'css', 'json', 'xml', 'yaml', 'yml']; - +const userRole = localStorage.getItem('ms_role') || ''; interface UploadData { upload_type: string; auth_type: string; @@ -62,17 +62,27 @@ const headers = { }; const beforeUpload = (file: any) => { + if(userRole == "admin"){ + } const fileExtension = file.name.split('.').pop().toLowerCase(); const isAllowedType = allowedTypes.includes(fileExtension); - if (!isAllowedType) { + if (!isAllowedType && userRole != "admin") { ElMessage.error('不允许的文件类型,仅支持 doc, docx, pdf, txt, png, jpg, jpeg, md, epub 及代码文本格式'); return false; - } + } + if(!isAllowedType && userRole == "admin"){ + //提示不允许的文件类型,是否继续上传,确认后继续上传 + confirm('不允许的文件类型,是否继续上传?') ? isAllowedType : false; + } // 可以在这里进行文件验证等操作 const isLt2M = file.size / 1024 / 1024 < 5; - if (!isLt2M) { + if (!isLt2M && userRole != "admin") { ElMessage.error('上传文件大小不能超过 5MB'); } + if(!isLt2M && userRole == "admin"){ + //提示文件过大,是否继续上传,确认后继续上传 + confirm('文件过大,是否继续上传?') ? isLt2M : false; + } return isLt2M; }; diff --git a/src/views/pages/login.vue b/src/views/pages/login.vue index 07e6572..5964b14 100644 --- a/src/views/pages/login.vue +++ b/src/views/pages/login.vue @@ -151,6 +151,7 @@ const getMyUserInfo = async (id) => { localStorage.setItem("ms_imgurl", result["data"]["Avatar"]); permiss.handleSet(keys); localStorage.setItem("ms_keys", JSON.stringify(keys)); + localStorage.setItem("ms_role", result["data"]["Role"]); router.push("/"); //alert("video_func:" + localStorage.getItem("video_func")+" type:" +typeof(localStorage.getItem("video_func"))); diff --git a/src/views/pages/register.vue b/src/views/pages/register.vue index 20d0380..a5e46e4 100644 --- a/src/views/pages/register.vue +++ b/src/views/pages/register.vue @@ -111,6 +111,7 @@ const getMyUserInfo = async (id) => { permiss.defaultList[result["data"]["Role"] == "admin" ? "admin" : "user"]; permiss.handleSet(keys); localStorage.setItem("ms_keys", JSON.stringify(keys)); + localStorage.setItem("ms_role", result["data"]["Role"]); router.push("/"); //alert("video_func:" + localStorage.getItem("video_func")+" type:" +typeof(localStorage.getItem("video_func"))); diff --git a/src/views/system/gen-chat.vue b/src/views/system/gen-chat.vue index 97e514b..0858d6a 100644 --- a/src/views/system/gen-chat.vue +++ b/src/views/system/gen-chat.vue @@ -100,18 +100,75 @@ :disabled="loading" >发送 -
模型参数
-