Commit a227c996 by Lin

fix: 交互优化/打包配置修改

1 parent 96c5deb5
...@@ -311,7 +311,7 @@ const handleFileChange = async (file) => { ...@@ -311,7 +311,7 @@ const handleFileChange = async (file) => {
validation: { validation: {
allowedTypes: ['application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'], allowedTypes: ['application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
allowedExtensions: ['pdf', 'doc', 'docx'], allowedExtensions: ['pdf', 'doc', 'docx'],
maxSize: 50 * 1024 * 1024, // 50MB maxSize: 10 * 1024 * 1024, // 10MB
errorMessage: '文件格式错误,仅支持 PDF、Word 格式', errorMessage: '文件格式错误,仅支持 PDF、Word 格式',
}, },
onSuccess: (url) => { onSuccess: (url) => {
...@@ -538,7 +538,7 @@ const cancel = () => { ...@@ -538,7 +538,7 @@ const cancel = () => {
<img src="/images/icon-upload.png" alt="upload-file" class="w-[16px] h-[16px] mr-[4px]"> <span>选择文件</span> <img src="/images/icon-upload.png" alt="upload-file" class="w-[16px] h-[16px] mr-[4px]"> <span>选择文件</span>
</div> </div>
</el-upload> </el-upload>
<div class="mt-[5px] text-xs text-[#909399]">支持pdf, word格式,大小在50M以内</div> <div class="mt-[5px] text-xs text-[#909399]">支持pdf, word格式,大小在10M以内</div>
<!-- 已上传文件显示 --> <!-- 已上传文件显示 -->
<div v-if="fileInfo.name" class="mt-2 flex items-center gap-2"> <div v-if="fileInfo.name" class="mt-2 flex items-center gap-2">
<el-icon class="text-[#409eff]"><Document /></el-icon> <el-icon class="text-[#409eff]"><Document /></el-icon>
......
...@@ -82,10 +82,18 @@ import { getImageUrl } from '@/utils/assets' ...@@ -82,10 +82,18 @@ import { getImageUrl } from '@/utils/assets'
import { getPromptTemplate, updatePromptTemplate } from '@/api/agentic' import { getPromptTemplate, updatePromptTemplate } from '@/api/agentic'
const textarea = ref('') const textarea = ref('')
const originalTextarea = ref('') // 保存原始内容
const isEditing = ref(false) const isEditing = ref(false)
const promptTemplateId = ref('') const promptTemplateId = ref('')
// 切换编辑状态 // 切换编辑状态
const toggleEdit = () => { const toggleEdit = () => {
if (isEditing.value) {
// 取消编辑:恢复原始内容
textarea.value = originalTextarea.value
} else {
// 进入编辑模式:保存当前内容作为原始内容
originalTextarea.value = textarea.value
}
isEditing.value = !isEditing.value isEditing.value = !isEditing.value
} }
...@@ -147,6 +155,7 @@ const getPromptTemplateList = async () => { ...@@ -147,6 +155,7 @@ const getPromptTemplateList = async () => {
console.log('getPromptTemplateList:', res) console.log('getPromptTemplateList:', res)
promptTemplateId.value = res.id promptTemplateId.value = res.id
textarea.value = res.promptTemplate textarea.value = res.promptTemplate
originalTextarea.value = res.promptTemplate // 初始化时保存原始内容
} }
const updatePromptTemplateList = async () => { const updatePromptTemplateList = async () => {
if (!textarea.value) { if (!textarea.value) {
...@@ -155,6 +164,8 @@ const updatePromptTemplateList = async () => { ...@@ -155,6 +164,8 @@ const updatePromptTemplateList = async () => {
} }
const res = await updatePromptTemplate({ id: promptTemplateId.value, promptTemplate: textarea.value }) const res = await updatePromptTemplate({ id: promptTemplateId.value, promptTemplate: textarea.value })
console.log('updatePromptTemplateList:', res) console.log('updatePromptTemplateList:', res)
// 保存成功后,更新原始内容为当前内容
originalTextarea.value = textarea.value
toggleEdit() toggleEdit()
ElMessage.success('更新成功') ElMessage.success('更新成功')
} }
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
class="w-full upload-custom-size" class="w-full upload-custom-size"
drag drag
action="#" action="#"
multiple :multiple="false"
:auto-upload="false" :auto-upload="false"
:show-file-list="true" :show-file-list="true"
:file-list="formData.files" :file-list="formData.files"
...@@ -49,9 +49,9 @@ ...@@ -49,9 +49,9 @@
<div class="w-[376px] h-[120px] rounded-[5px] opacity-100 border border-[#e1e3e6] bg-[#f5f7fa] p-[16px] flex flex-col gap-3" > <div class="w-[376px] h-[120px] rounded-[5px] opacity-100 border border-[#e1e3e6] bg-[#f5f7fa] p-[16px] flex flex-col gap-3" >
<div> <div>
<div class="flex items-start gap-2"> <div class="flex items-start gap-2">
<el-icon class="text-[#00AD74] text-[16px] pt-[4px]" v-if="fileInfo.status"><CircleCheckFilled /></el-icon> <el-icon class="text-[#00AD74] text-[16px] pt-[4px]" v-show="fileInfo.status"><CircleCheckFilled /></el-icon>
<el-icon class="text-[#EB2F2F] text-[16px] pt-[4px]" v-else><WarningFilled /></el-icon> <el-icon class="text-[#EB2F2F] text-[16px] pt-[4px]" v-show="!fileInfo.status"><WarningFilled /></el-icon>
<div class="text-[14px] text-[#565D6B] font-normal truncate leading-5">{{fileInfo.name || material.filePath}}</div> <div class="text-[14px] text-[#565D6B] font-normal truncate leading-5">{{fileInfo.name || material?.filePath}}</div>
</div> </div>
<div class="text-[12px] text-[#969AA3] h-[40px]"> <div class="text-[12px] text-[#969AA3] h-[40px]">
<span v-if="fileInfo.status && fileInfo.size">文件大小: {{fileInfo.size}}</span> <span v-if="fileInfo.status && fileInfo.size">文件大小: {{fileInfo.size}}</span>
...@@ -350,8 +350,9 @@ const uploadFileToOSS = async (fileObj) => { ...@@ -350,8 +350,9 @@ const uploadFileToOSS = async (fileObj) => {
file, file,
(result) => { (result) => {
console.log("uploadFileToOSS成功",result); console.log("uploadFileToOSS成功",result);
// 确保文件名和状态同步更新,使用原始文件名而不是 result.attachment
fileInfo.value = { fileInfo.value = {
name: result.attachment, name: fileObj.name || file.name || result.attachment,
url: result.aliyunAddress, url: result.aliyunAddress,
size: result.size, size: result.size,
status: true, status: true,
...@@ -447,6 +448,13 @@ const handleFileChange = (file, fileList) => { ...@@ -447,6 +448,13 @@ const handleFileChange = (file, fileList) => {
} }
formData.files = fileList; formData.files = fileList;
// 立即设置文件名,确保文字和图标同步显示
if (file.name) {
fileInfo.value = {
...fileInfo.value,
name: file.name,
};
}
// 如果文件是新添加的且未上传,自动上传 // 如果文件是新添加的且未上传,自动上传
// 已有 URL 的文件(编辑模式)不需要重新上传 // 已有 URL 的文件(编辑模式)不需要重新上传
if (file.status === 'ready' && file.raw && !file.url) { if (file.status === 'ready' && file.raw && !file.url) {
...@@ -473,6 +481,13 @@ const handleFileChange = (file, fileList) => { ...@@ -473,6 +481,13 @@ const handleFileChange = (file, fileList) => {
*/ */
const handleFileRemove = (file, fileList) => { const handleFileRemove = (file, fileList) => {
formData.files = []; formData.files = [];
// 重置文件信息
fileInfo.value = {
name: '',
url: '',
size: '',
status: true,
};
}; };
/** /**
...@@ -940,7 +955,7 @@ const submitForm = async () => { ...@@ -940,7 +955,7 @@ const submitForm = async () => {
try { try {
await formRef.value.validate(async (valid) => { await formRef.value.validate(async (valid) => {
if (!valid) { if (!valid) {
ElMessage.error('请填写完整信息'); // ElMessage.error('请填写完整信息');
return; return;
} }
......
...@@ -717,7 +717,7 @@ onMounted(() => { ...@@ -717,7 +717,7 @@ onMounted(() => {
· {{ item.count }} · {{ item.count }}
</span> </span>
</p> </p>
<p class="item-right flex-shrink-0" v-if="item.name != '未分组'"> <p class="item-right flex-shrink-0" v-if="item.sysCategory != '1'">
<img <img
class="w-[14px] h-[14px] cursor-pointer" class="w-[14px] h-[14px] cursor-pointer"
src="/images/icon-edit-know.png" src="/images/icon-edit-know.png"
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
"scripts": { "scripts": {
"dev": "vite --host", "dev": "vite --host",
"build": "vue-tsc && vite build", "build": "vue-tsc && vite build",
"postbuild": "node ../../../../scripts/copy-dist-to-root.mjs",
"preview": "vite preview", "preview": "vite preview",
"type-check": "vue-tsc --noEmit" "type-check": "vue-tsc --noEmit"
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!