diff --git a/gyxtp/package.json b/gyxtp/package.json index a01b340..d10f9d9 100644 --- a/gyxtp/package.json +++ b/gyxtp/package.json @@ -17,10 +17,12 @@ "element-plus": "^2.8.8", "fabric": "^6.4.3", "neovis.js": "^2.1.0", + "pdfjs-dist": "^5.4.149", "relation-graph-vue3": "^2.2.11", "view-ui-plus": "^1.3.7", "vue": "^3.2.13", "vue-i18n": "9.0.0", + "vue-pdf-embed": "^2.1.3", "vue-router": "^4.4.5", "vue3-treeselect": "^0.1.10" }, diff --git a/gyxtp/src/api/api/article.js b/gyxtp/src/api/api/article.js index 4ae17e6..957f674 100644 --- a/gyxtp/src/api/api/article.js +++ b/gyxtp/src/api/api/article.js @@ -12,4 +12,16 @@ export const getArticleInfo = (id) => { url: '/api/article/getArticleInfo/'+id, method: 'get', }); -}; \ No newline at end of file +}; + + +export const updateArticle = (params) => { + return request({ + url: '/api/article/updateArticle', + method: 'post', + data:params, + headers:{ + 'token':localStorage.getItem('token') + } + }) +} \ No newline at end of file diff --git a/gyxtp/src/api/api/upload.js b/gyxtp/src/api/api/upload.js index 922d0b6..d72f5f8 100644 --- a/gyxtp/src/api/api/upload.js +++ b/gyxtp/src/api/api/upload.js @@ -8,3 +8,15 @@ export const uploadInfo = (params) => { data: params, }); }; + + +export const getFileByUrl = (params) => { + return request({ + url: '/api/updateload/file/info', // 你的接口路径 + method: 'post', + data: params, // 使用 data 发送 JSON + headers:{ + 'token':localStorage.getItem('token') + } + }); +}; \ No newline at end of file diff --git a/gyxtp/src/view/Home.vue b/gyxtp/src/view/Home.vue index be25f79..fec97fa 100644 --- a/gyxtp/src/view/Home.vue +++ b/gyxtp/src/view/Home.vue @@ -14,25 +14,15 @@
- -
- -
-
+ +
+
@@ -68,25 +58,7 @@
-
- -
- - - - - -
- -
diff --git a/gyxtp/src/view/articleInfo.vue b/gyxtp/src/view/articleInfo.vue index d6f89a2..4c2090a 100644 --- a/gyxtp/src/view/articleInfo.vue +++ b/gyxtp/src/view/articleInfo.vue @@ -36,7 +36,8 @@ -
+ +
@@ -61,8 +62,9 @@ import RelationGraph from 'relation-graph-vue3'; import HeaderInfo from '../components/UseAll/headerInfo' import LeftInfo from "../components/UseAll/leftInfo"; import {ElMessage} from 'element-plus' -import {getArticleInfo} from "@/api/api/article"; - +import {getArticleInfo, updateArticle} from "@/api/api/article"; +import VuePdfEmbed from 'vue-pdf-embed' +import {getFileByUrl, uploadPdf} from "@/api/api/upload"; const graphOptions = { debug: true, backgrounImageNoRepeat: true, @@ -103,7 +105,8 @@ export default { name: 'articleInfo', components: { LeftInfo, - HeaderInfo + HeaderInfo, + VuePdfEmbed }, data() { @@ -936,8 +939,39 @@ export default { mounted() { // this.getInfoInit(); this.id = this.$route.query.id; - getArticleInfo(this.id).then(res=>{ - this.content=res + getArticleInfo(this.id).then(async res => { + this.content = res + if(this.content.uploadUrl==null && this.content.uploadUrl==''){ + const localFilePath = this.content.localUrl; + + try { + const response = await getFileByUrl({ + filePath: localFilePath + }); + + if (response.code === 200) { + this.pdfInfo = response; + this.content.uploadUrl = this.pdfInfo.url + updateArticle(this.content).then((res)=>{ + console.log(res) + }) + console.log('PDF 可访问地址:', this.pdfInfo.url); + this.content.uploadUrl = this.pdfInfo.url + + + } else { + this.$message.error('获取文件失败:' + response.msg); + } + } catch (error) { + console.error('请求异常:', error); + this.$message.error('网络错误或文件不存在'); + } + + } + + + + // this.content.content=this.content.content.replace(/\n/g, '
'); }) // this.level = this.$route.query.level; diff --git a/gyxtp/src/view/graphPageCopy.vue b/gyxtp/src/view/graphPageCopy.vue index fe68f52..1edd266 100644 --- a/gyxtp/src/view/graphPageCopy.vue +++ b/gyxtp/src/view/graphPageCopy.vue @@ -197,10 +197,10 @@ - + - +