|
@@ -9,10 +9,13 @@ import fileUpload from "@/utils/oss-file-upload"
|
|
import { ElMessage } from "element-plus"
|
|
import { ElMessage } from "element-plus"
|
|
import { toBlob } from "html-to-image"
|
|
import { toBlob } from "html-to-image"
|
|
import { useSlidesStore } from "@/store"
|
|
import { useSlidesStore } from "@/store"
|
|
|
|
+import queryParams, { initQueryParams } from "@/queryParams"
|
|
|
|
|
|
type pptWork = { id: string; coverImg: string; jsonUrl: string; isSave: boolean }
|
|
type pptWork = { id: string; coverImg: string; jsonUrl: string; isSave: boolean }
|
|
|
|
+
|
|
const useStore = defineStore("pptWork", {
|
|
const useStore = defineStore("pptWork", {
|
|
state: (): pptWork => {
|
|
state: (): pptWork => {
|
|
|
|
+ initQueryParams()
|
|
const route = useRoute()
|
|
const route = useRoute()
|
|
return {
|
|
return {
|
|
id: route.query.id as string,
|
|
id: route.query.id as string,
|
|
@@ -26,7 +29,7 @@ const useStore = defineStore("pptWork", {
|
|
async initPPTData() {
|
|
async initPPTData() {
|
|
if (this.id) {
|
|
if (this.id) {
|
|
LoadingBar.loading(true, "资源加载中,请稍等...")
|
|
LoadingBar.loading(true, "资源加载中,请稍等...")
|
|
- const res = await httpAjaxErrMsg(getTeacherChapterKnowledgeMaterial, this.id)
|
|
|
|
|
|
+ const res = await httpAjaxErrMsg(getTeacherChapterKnowledgeMaterial, this.id, queryParams.fromType)
|
|
if (res.code === 200) {
|
|
if (res.code === 200) {
|
|
const { dataJson, chapterLessonCoursewareName } = res.data || {}
|
|
const { dataJson, chapterLessonCoursewareName } = res.data || {}
|
|
const { coverImg, jsonUrl } = JSON.parse(dataJson)
|
|
const { coverImg, jsonUrl } = JSON.parse(dataJson)
|
|
@@ -44,11 +47,11 @@ const useStore = defineStore("pptWork", {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
async updatePPT() {
|
|
async updatePPT() {
|
|
|
|
+ LoadingBar.loading(true, "课件保存中,请稍等...")
|
|
await this.updateCoverImg()
|
|
await this.updateCoverImg()
|
|
const { blob } = getJsonToBlob()
|
|
const { blob } = getJsonToBlob()
|
|
- fileUpload(`${this.id}ppt`, blob, `${this.id}/`, false)
|
|
|
|
|
|
+ fileUpload(`${this.id}ppt`, blob, `${this.id}/`, false, { isLoading: false })
|
|
.then(url => {
|
|
.then(url => {
|
|
- LoadingBar.loading(true, "课件保存中,请稍等...")
|
|
|
|
httpAjaxErrMsg(putTeacherChapterKnowledgeMaterial, {
|
|
httpAjaxErrMsg(putTeacherChapterKnowledgeMaterial, {
|
|
id: this.id,
|
|
id: this.id,
|
|
dataJson: JSON.stringify({
|
|
dataJson: JSON.stringify({
|
|
@@ -68,6 +71,7 @@ const useStore = defineStore("pptWork", {
|
|
})
|
|
})
|
|
})
|
|
})
|
|
.catch(() => {
|
|
.catch(() => {
|
|
|
|
+ LoadingBar.loading(false)
|
|
ElMessage({
|
|
ElMessage({
|
|
showClose: true,
|
|
showClose: true,
|
|
message: "保存失败!",
|
|
message: "保存失败!",
|
|
@@ -76,19 +80,16 @@ const useStore = defineStore("pptWork", {
|
|
})
|
|
})
|
|
},
|
|
},
|
|
async updateCoverImg() {
|
|
async updateCoverImg() {
|
|
- LoadingBar.loading(true, "资源上传中")
|
|
|
|
try {
|
|
try {
|
|
const coverImgDom = document.querySelector("#thumbnailSlide_0") as HTMLElement
|
|
const coverImgDom = document.querySelector("#thumbnailSlide_0") as HTMLElement
|
|
if (coverImgDom) {
|
|
if (coverImgDom) {
|
|
const dataBlob = await toBlob(coverImgDom)
|
|
const dataBlob = await toBlob(coverImgDom)
|
|
if (dataBlob) {
|
|
if (dataBlob) {
|
|
- const url = await fileUpload(`${this.id}coverImg`, dataBlob, `${this.id}/`, false)
|
|
|
|
|
|
+ const url = await fileUpload(`${this.id}coverImg`, dataBlob, `${this.id}/`, false, { isLoading: false })
|
|
url && (this.coverImg = url)
|
|
url && (this.coverImg = url)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- LoadingBar.loading(false)
|
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
- LoadingBar.loading(false)
|
|
|
|
console.log(err, "上传coverImg错误")
|
|
console.log(err, "上传coverImg错误")
|
|
}
|
|
}
|
|
}
|
|
}
|