From 7099f45d364be9782ce02b8a241ba957f8f184e4 Mon Sep 17 00:00:00 2001 From: caoyuchun Date: Wed, 10 Jul 2024 16:49:16 +0800 Subject: [PATCH] cyc --- src/service/getData.js | 12 +++++++- src/views/Book.vue | 67 ++++++++++++++++++++++++++++++++---------- vue.config.js | 19 ++++++++++++ 3 files changed, 81 insertions(+), 17 deletions(-) diff --git a/src/service/getData.js b/src/service/getData.js index 7e722ba..5e70d76 100644 --- a/src/service/getData.js +++ b/src/service/getData.js @@ -38,7 +38,17 @@ var bookinfo ={ method: 'GET', data: params, }) - }, + }, + + // 集合 + json: (params) =>{ + + return request({ + url :`${prefix}/smile/get/remote/book/jsom/url`, + method :'GET', + data : params + }) + } } // 笔记 diff --git a/src/views/Book.vue b/src/views/Book.vue index 5c683c0..114c47d 100644 --- a/src/views/Book.vue +++ b/src/views/Book.vue @@ -112,6 +112,9 @@ export default { created() { this.bookId = this.$route.query.bookId + if (this.$route.query.chapterId){ + this.chapterId = this.$route.query.chapterId + } // this.userType = this.$route.query.userType || 'student' this.$store.state.redirecturl = this.$route.query.redirecturl var userType = getStore("userType") @@ -160,34 +163,66 @@ export default { // this.location = locationData.location - + var res = await bookApi.bookinfo.json({bookId:this.bookId}) - try { - this.textBookData = await bookApi.bookinfo.detail({bookId:this.bookId}) - this.$store.state.textBookData = this.textBookData + // res = JSON.stringify(res) + // res = res.replaceAll("https://smile-ebook.oss-cn-qingdao.aliyuncs.com/", "fileapi/") + // res = JSON.parse(res) - } catch (error) { - this.fullscreenLoading = false - this.show= false - this.showError = true - this.errormsg = error - this.$message.error(error); - } + if (res){ + var res1 = await fetch(res.LOCAL_VIEW_DETAIL,{ + mode: 'cors' + }) + this.textBookData = await res1.json() + var res2 = await fetch (res.LOCAL_VIEW_CATALOG,{ + mode: 'cors' + }) + debugger + this.catalogList = await res2.json() + var res3 = await fetch(res.LOCAL_VIEW_DATA,{ + mode: 'cors' + }) + console.log(this.catalogList) + this.looseLeafData = await res3.json() + + this.basisPath = res.basisPath + debugger + } + + debugger + + // debugger + // console.log(res) + // return + // try { + // this.textBookData = await bookApi.bookinfo.detail({bookId:this.bookId}) + // this.$store.state.textBookData = this.textBookData + + // } catch (error) { + // this.fullscreenLoading = false + // this.show= false + // this.showError = true + // this.errormsg = error + // this.$message.error(error); + // } + debugger this.basisPath = this.textBookData.basisPath - this.catalogList = await bookApi.bookinfo.category({bookId:this.bookId}) - this.looseLeafData = await bookApi.bookinfo.data({bookId:this.bookId}) - this.show = true - this.fullscreenLoading = false + // this.catalogList = await bookApi.bookinfo.category({bookId:this.bookId}) + // this.looseLeafData = await bookApi.bookinfo.data({bookId:this.bookId}) + this.data.resources.list = await bookApi.resource.list({bookId:this.bookId}) - this.digitalTeaching = true if (this.$route.query.chapterId){ this.chapterId = this.$route.query.chapterId } + this.show = true + this.fullscreenLoading = false + this.digitalTeaching = true + }, methods: { diff --git a/vue.config.js b/vue.config.js index 72b6ad3..3e8cea5 100644 --- a/vue.config.js +++ b/vue.config.js @@ -19,7 +19,26 @@ module.exports = { }); console.log('Proxy response:', res.statusCode); } + }, + '/remote':{ + target : "https://smile-ebook.oss-cn-qingdao.aliyuncs.com", + changeOrigin : true, + pathRewrite: { + '^/remote': '/' + }, + logLevel : 'debug', + onProxyRes(proxyRes, req, res) { + let responseBody = ''; + proxyRes.on('data', (chunk) => { + responseBody += chunk; + }); + proxyRes.on('end', () => { + // console.log('Proxy response body:', responseBody); + }); + console.log('Proxy response:', res.statusCode); + } } + } },