diff --git a/.env.development b/.env.development
index f31b978..a069028 100644
--- a/.env.development
+++ b/.env.development
@@ -9,8 +9,8 @@
# 只在开发模式中被载入
# 网站前缀
-VITE_BASE_API_URL = http://192.168.2.33:8089/server/
-# VITE_BASE_API_URL = http://43.137.2.78:8085/server/
+# VITE_BASE_API_URL = http://192.168.2.33:8089/server/
+VITE_BASE_API_URL = http://43.137.2.78:8085/server/
# base api
VITE_BASE_API = '/server/'
diff --git a/src/views/client/knowledgeBase/index.vue b/src/views/client/knowledgeBase/index.vue
index c24bd7b..8e7f156 100644
--- a/src/views/client/knowledgeBase/index.vue
+++ b/src/views/client/knowledgeBase/index.vue
@@ -48,6 +48,9 @@
>
+
+ {{ curRowDetail.description }}
+
+
+
@@ -84,11 +107,16 @@
DeleteOutlined,
ExportOutlined,
LeftOutlined,
+ PaperClipOutlined,
+ FileOutlined,
} from '@ant-design/icons-vue';
import { fetchKnowledgeBaseList, findOneById, addReadCount } from '@/api/knowledgeBase';
import { useRoute, useRouter } from 'vue-router';
import { useUserStore } from '@/store/modules/user';
-
+ // 添加下载方法
+ const handleDownload = (file) => {
+ window.open(file.url, '_blank');
+ };
const userStore = useUserStore();
const isAdmin = userStore.userInfo.isAdmin;
@@ -108,12 +136,20 @@
solution: string;
createTime: string;
readCount: any;
+ description: string;
+ files: Array<{
+ id: string;
+ originalFilename: string;
+ url: string;
+ }>;
}>({
title: '',
tags: '',
solution: '',
createTime: '',
readCount: 0,
+ description: '',
+ files: [],
});
const goBack = () => {
@@ -184,6 +220,62 @@
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
+ .attachments {
+ margin-top: 32px;
+ padding-top: 24px;
+ border-top: 1px solid #e2e8f0;
+
+ .attachments-header {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ margin-bottom: 16px;
+ color: #1e293b;
+ font-size: 16px;
+ font-weight: 500;
+
+ .anticon {
+ color: #3b82f6;
+ }
+ }
+
+ .attachments-list {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
+ gap: 16px;
+
+ .file-card {
+ cursor: pointer;
+ transition: all 0.3s ease;
+ border-radius: 8px;
+ overflow: hidden;
+
+ &:hover {
+ transform: translateY(-2px);
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
+ }
+
+ .file-icon {
+ font-size: 40px;
+ color: #3b82f6;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ padding: 24px 0;
+ background: #f8fafc;
+ }
+
+ :deep(.ant-card-meta-title) {
+ font-size: 14px;
+ text-align: center;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+ }
+ }
+ }
+
.card-title {
display: flex;
align-items: center;
@@ -221,6 +313,16 @@
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
.content-header {
+ .description {
+ margin: 16px 0;
+ padding: 12px 16px;
+ background: #f8fafc;
+ border-left: 4px solid #3b82f6;
+ border-radius: 0 8px 8px 0;
+ color: #475569;
+ font-size: 15px;
+ line-height: 1.6;
+ }
.header-main {
margin-bottom: 16px;
@@ -329,10 +431,7 @@
:deep(blockquote) {
margin: 20px 0;
padding: 16px 24px;
- background: #f8fafc;
- border-left: 4px solid #3b82f6;
- border-radius: 0 8px 8px 0;
- color: #475569;
+
font-style: italic;
}
diff --git a/src/views/question/commom/tools.ts b/src/views/question/commom/tools.ts
index 5bd3927..a03e0ba 100644
--- a/src/views/question/commom/tools.ts
+++ b/src/views/question/commom/tools.ts
@@ -6,6 +6,22 @@ const quillEditor = ref | null>(null);
export const quillImageUploadCustom = (quill) => {
quillEditor.value = quill;
+ console.log('quillEditor.value: ', quillEditor.value);
+ const editor = quillEditor.value?.getEditor();
+ editor?.addEventListener('drop', function (event: any) {
+ event.preventDefault(); // 防止默认行为
+ event.stopPropagation();
+
+ // 获取拖拽的文件
+ var files = event.dataTransfer.files;
+
+ // 处理文件上传逻辑,比如调用接口上传附件
+ if (files.length > 0) {
+ // 自定义处理上传的逻辑
+ console.log('上传的文件:', files);
+ customUploadAjax(files[0]);
+ }
+ });
const toolbar = quillEditor.value?.getToolbar();
const formats = toolbar?.querySelectorAll('.ql-formats');
@@ -38,25 +54,28 @@ const handleCustomImageUpload = () => {
input.onchange = async (e: any) => {
const file = e?.target?.files[0];
if (file) {
- const formData = new FormData();
- formData.append('file', file);
-
- // 发送文件到服务器进行上传
- try {
- const res = await commonUpload(formData);
- console.log('res: ', res);
-
- if (res?.url) {
- const fileUrl = res?.url;
- insertImage(fileUrl); // 将图片插入到 Quill 编辑器
- }
- } catch (error) {
- console.error('文件上传失败', error);
- }
+ customUploadAjax(file);
}
};
};
+const customUploadAjax = async (file) => {
+ const formData = new FormData();
+ formData.append('file', file);
+ // 发送文件到服务器进行上传
+ try {
+ const res = await commonUpload(formData);
+ console.log('res: ', res);
+
+ if (res?.url) {
+ const fileUrl = res?.url;
+ insertImage(fileUrl); // 将图片插入到 Quill 编辑器
+ }
+ } catch (error) {
+ console.error('文件上传失败', error);
+ }
+};
+
// 插入图片到 Quill 编辑器
const insertImage = (url) => {
const quill = quillEditor.value?.getQuill();
diff --git a/src/views/question/issue/index.vue b/src/views/question/issue/index.vue
index a5c15ce..6a82dcb 100644
--- a/src/views/question/issue/index.vue
+++ b/src/views/question/issue/index.vue
@@ -189,10 +189,10 @@
(newVal) => {
if (newVal) {
nextTick(() => {
- if (time.value === 0) {
- quillImageUploadCustom(quillEditor.value);
- time.value++;
- }
+ // if (time.value === 0) {
+ quillImageUploadCustom(quillEditor.value);
+ // time.value++;
+ // }
});
}
},
@@ -223,6 +223,8 @@
};
});
values.fileIds = values.files.map((e) => e.id).join(',');
+ } else {
+ values.fileIds = '';
}
if (values?.tags && Array.isArray(values.tags) && values.tags.length) {
@@ -396,6 +398,8 @@
};
});
values.fileIds = values.files.map((e) => e.id).join(',');
+ } else {
+ values.fileIds = '';
}
if (values?.tags && Array.isArray(values.tags) && values.tags.length) {
diff --git a/src/views/question/knowledge/index.vue b/src/views/question/knowledge/index.vue
index 849aa8b..0b4d050 100644
--- a/src/views/question/knowledge/index.vue
+++ b/src/views/question/knowledge/index.vue
@@ -156,10 +156,10 @@
(newVal) => {
if (newVal) {
nextTick(() => {
- if (time.value === 0) {
- quillImageUploadCustom(quillEditor.value);
- time.value++;
- }
+ // if (time.value === 0) {
+ quillImageUploadCustom(quillEditor.value);
+ // time.value++;
+ // }
});
}
},
@@ -190,6 +190,8 @@
};
});
values.fileIds = values.files.map((e) => e.id).join(',');
+ } else {
+ values.fileIds = '';
}
if (values?.tags && Array.isArray(values.tags) && values.tags.length) {
@@ -291,6 +293,8 @@
};
});
values.fileIds = values.files.map((e) => e.id).join(',');
+ } else {
+ values.fileIds = '';
}
await (record.id ? updateKnowledgeBase : createKnowledgeBase)(values);