From d2030ba753a12133558cfc9e309e8b0ea6e26a5a Mon Sep 17 00:00:00 2001
From: zhangxiaomeng <1362468712@qq.com>
Date: Fri, 7 Feb 2025 10:44:04 +0800
Subject: [PATCH] =?UTF-8?q?=E9=A1=B5=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
kcui/src/view/Graph.vue | 44 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
diff --git a/kcui/src/view/Graph.vue b/kcui/src/view/Graph.vue
index 42ba803..15d2426 100644
--- a/kcui/src/view/Graph.vue
+++ b/kcui/src/view/Graph.vue
@@ -33,12 +33,25 @@
+
@@ -111,7 +124,7 @@ import {getgraphInfo, test} from "@/api/login";
import VisGraph from '@/assets/js/graphvis.min.20241008.js'
import LayoutFactory from '@/assets/js/graphvis.layout.min.js'
import {config} from '@/assets/defaultConfig.js'
-import {addNode, getFileIdByDocId} from "@/api/file";
+import {addFile, addNode, getFileIdByDocId} from "@/api/file";
export default {
// eslint-disable-next-line vue/multi-word-component-names
@@ -164,6 +177,35 @@ export default {
},
methods: {
+ openFileInput() {
+ // 触发隐藏的文件输入框点击事件
+ this.$refs.fileInput.click();
+ },
+ handleFileChange(event) {
+ const file = event.target.files[0];
+ if (file) {
+ this.uploadFile(file);
+ }
+ },
+ uploadFile(file) {
+ // 调用API函数进行文件上传
+ addFile(file)
+ .then(response => {
+ if (response.code === 200) {
+ this.$message.success('文件上传成功');
+ } else {
+ this.$message.error('文件上传失败');
+ }
+ })
+ .catch(error => {
+ console.error('文件上传错误:', error);
+ this.$message.error('文件上传失败');
+ })
+ .finally(() => {
+ // 清除文件选择框的内容以便下次使用
+ this.$refs.fileInput.value = null;
+ });
+ },
goInfo(info) {
console.log(info)
this.$router.push('/' + info)