Parcourir la source

Merge branch 'hqyDev' of http://git.dayaedu.com/huangqiyong/pptList into test-online

黄琪勇 il y a 6 mois
Parent
commit
7288720779

+ 3 - 1
public/pptworker/pptJson.js

@@ -57497,7 +57497,9 @@
                         i = 1080
                         break
                   }
-                  var a = r.preview,
+                  // hqy 这里没有预览图的时候会报错,所以加了判空
+                  var a = r.preview || "",
+                  // hqy
                      s = a.indexOf("data:image") > -1,
                      l = {
                         path: s ? void 0 : a,

+ 2 - 2
public/pptworker/upload.js

@@ -36,7 +36,7 @@ function fileUpload({ host, token }, { fileName, file }) {
 }
 
 const getUploadSign = (fileName, host, token) => {
-  const fileUrl = "pptList/" + fileName
+  const fileUrl = `pptList/${filePath || "errPath/"}` + fileName
   return ajaxRequest(
     `${host}/edu-app/open/getUploadSign?pluginName=${ossType}`,
     "POST",
@@ -66,7 +66,7 @@ const onOnlyFileUpload = (signature, params) => {
   return cos.uploadFile({
     Bucket: tencentBucket /* 填写自己的 bucket,必须字段 */,
     Region: "ap-nanjing" /* 存储桶所在地域,必须字段 */,
-    Key: `pptList/${params.fileName}`,
+    Key: `pptList/${filePath || "errPath/"}${params.fileName}`,
     /* 存储在桶里的对象键(例如:1.jpg,a/b/test.txt,图片.jpg)支持中文,必须字段 */
     Body: params.file, // 上传文件对象
     SliceSize: 1024 * 1024 * 500 /* 触发分块上传的阈值,超过5MB使用分块上传,小于5MB使用简单上传。可自行设置,非必须 */,

+ 11 - 10
src/store/pptWork.ts

@@ -8,12 +8,14 @@ import { getHttpJson, jsonToPpt, getJsonToBlob } from "@/libs/jsonTool"
 import fileUpload from "@/utils/oss-file-upload"
 import { ElMessage } from "element-plus"
 import { toBlob } from "html-to-image"
+import { useSlidesStore } from "@/store"
 
 type pptWork = { id: string; coverImg: string; jsonUrl: string; isSave: boolean }
 const useStore = defineStore("pptWork", {
   state: (): pptWork => {
+    const route = useRoute()
     return {
-      id: "",
+      id: route.query.id as string,
       coverImg: "",
       jsonUrl: "",
       isSave: false // 当前是否保存,用来关闭页面时候判断 提不提示
@@ -22,16 +24,15 @@ const useStore = defineStore("pptWork", {
   actions: {
     /** 初始化 */
     async initPPTData() {
-      const route = useRoute()
-      const id = route.query.id as string | undefined
-      if (id) {
+      if (this.id) {
         LoadingBar.loading(true, "资源加载中,请稍等...")
-        const res = await httpAjaxErrMsg(getTeacherChapterKnowledgeMaterial, id)
+        const res = await httpAjaxErrMsg(getTeacherChapterKnowledgeMaterial, this.id)
         if (res.code === 200) {
-          const { id, dataJson } = res.data || {}
+          const { dataJson, chapterLessonCoursewareName } = res.data || {}
           const { coverImg, jsonUrl } = JSON.parse(dataJson)
-          this.id = id
           this.coverImg = coverImg || ""
+          const slidesStore = useSlidesStore()
+          slidesStore.setTitle(chapterLessonCoursewareName)
           if (jsonUrl) {
             const jsonRes = await getHttpJson(jsonUrl)
             if (jsonRes.code === 200) {
@@ -44,8 +45,8 @@ const useStore = defineStore("pptWork", {
     },
     async updatePPT() {
       await this.updateCoverImg()
-      const { blob, title } = getJsonToBlob()
-      fileUpload(title, blob)
+      const { blob } = getJsonToBlob()
+      fileUpload(`${this.id}ppt`, blob, `${this.id}/`, false)
         .then(url => {
           LoadingBar.loading(true, "课件保存中,请稍等...")
           httpAjaxErrMsg(putTeacherChapterKnowledgeMaterial, {
@@ -81,7 +82,7 @@ const useStore = defineStore("pptWork", {
         if (coverImgDom) {
           const dataBlob = await toBlob(coverImgDom)
           if (dataBlob) {
-            const url = await fileUpload("coverImg", dataBlob)
+            const url = await fileUpload(`${this.id}coverImg`, dataBlob, `${this.id}/`, false)
             url && (this.coverImg = url)
           }
         }

+ 1 - 1
src/store/slides.ts

@@ -33,7 +33,7 @@ export interface SlidesState {
 
 export const useSlidesStore = defineStore("slides", {
   state: (): SlidesState => ({
-    title: "未命名演示文稿", // 幻灯片标题
+    title: "", // 幻灯片标题
     theme: theme, // 主题样式
     slides: slides, // 幻灯片页面数据
     slideIndex: 0, // 当前页面索引

+ 11 - 8
src/utils/oss-file-upload.ts

@@ -6,16 +6,19 @@ import loadingBar from "@/plugins/loadingBar"
 const tencentBucket = "daya-online-1303457149"
 const ossType = "tencent"
 
-export default async function fileUpload(fileName: string, file: Blob) {
+export default async function fileUpload(fileName: string, file: Blob, filePath: string, isAddTimestamp = true) {
   loadingBar.loading(true, "资源上传中")
   // 上传名称加上时间戳
-  fileName = addTimestampBeforeExtension(fileName)
-  const resUploadSign = await getUploadSign(fileName)
+  if (isAddTimestamp) {
+    fileName = addTimestampBeforeExtension(fileName)
+  }
+  const resUploadSign = await getUploadSign(fileName, filePath)
   if (resUploadSign.code === 200) {
     try {
       const resUpload = await onOnlyFileUpload(resUploadSign.data.signature, {
         fileName,
-        file
+        file,
+        filePath
       })
       loadingBar.loading(false)
       if (resUpload.statusCode === 200) {
@@ -33,8 +36,8 @@ export default async function fileUpload(fileName: string, file: Blob) {
   }
 }
 
-const getUploadSign = async (fileName: string) => {
-  const fileUrl = "pptList/" + fileName
+const getUploadSign = async (fileName: string, filePath: string) => {
+  const fileUrl = `pptList/${filePath || "errPath/"}` + fileName
   return httpAjax(
     getUploadSignApi,
     {
@@ -49,7 +52,7 @@ const getUploadSign = async (fileName: string) => {
   )
 }
 
-const onOnlyFileUpload = (signature: string, params: { fileName: string; file: Blob }) => {
+const onOnlyFileUpload = (signature: string, params: { fileName: string; file: Blob; filePath: string }) => {
   const cos = new COS({
     Domain: "https://oss.dayaedu.com",
     Protocol: "https",
@@ -60,7 +63,7 @@ const onOnlyFileUpload = (signature: string, params: { fileName: string; file: B
   return cos.uploadFile({
     Bucket: tencentBucket /* 填写自己的 bucket,必须字段 */,
     Region: "ap-nanjing" /* 存储桶所在地域,必须字段 */,
-    Key: `pptList/${params.fileName}`,
+    Key: `pptList/${params.filePath || "errPath/"}${params.fileName}`,
     /* 存储在桶里的对象键(例如:1.jpg,a/b/test.txt,图片.jpg)支持中文,必须字段 */
     Body: params.file, // 上传文件对象
     SliceSize: 1024 * 1024 * 500 /* 触发分块上传的阈值,超过5MB使用分块上传,小于5MB使用简单上传。可自行设置,非必须 */,

BIN
src/views/Editor/CanvasTool/imgs/bf.png


+ 4 - 8
src/views/Editor/CanvasTool/index.vue

@@ -29,7 +29,6 @@
           <PopoverMenuItem @click="enterScreening()">从当前页开始</PopoverMenuItem>
         </template>
         <div class="arrow-btn">
-          <img src="./imgs/bf.png" alt="" />
           <div>播放</div>
         </div>
       </Popover>
@@ -294,7 +293,9 @@ import PopoverMenuItem from "@/components/PopoverMenuItem.vue"
 import { ElUpload, ElMessage, type UploadRequestOptions } from "element-plus"
 import cloudCoachList from "@/views/components/element/cloudCoachElement/cloudCoachList"
 import fileUpload from "@/utils/oss-file-upload"
+import usePptWork from "@/store/pptWork"
 
+const usePptWorkHook = usePptWork()
 const mainStore = useMainStore()
 const { creatingElement, creatingCustomShape, showSelectPanel, showSearchPanel, showNotesPanel } = storeToRefs(mainStore)
 const { canUndo, canRedo } = storeToRefs(useSnapshotStore())
@@ -342,7 +343,7 @@ const moreToolsVisible = ref(false)
 // 音视频
 function handleUpload(fileData: UploadRequestOptions) {
   const type = /\.(mp3|wav|m4a)$/i.test(fileData.file.name) ? "audio" : "video"
-  fileUpload(fileData.file.name, fileData.file)
+  fileUpload(fileData.file.name, fileData.file, `${usePptWorkHook.id}/`)
     .then(res => {
       if (type === "audio") {
         createAudioElement(res)
@@ -468,7 +469,7 @@ const toggleNotesPanel = () => {
     display: flex;
     align-items: center;
     justify-content: center;
-    width: 88px;
+    width: 60px;
     height: 32px;
     background: linear-gradient(312deg, #1b7af8 0%, #3cbbff 100%);
     border-radius: 6px;
@@ -480,11 +481,6 @@ const toggleNotesPanel = () => {
     &:hover {
       opacity: 0.8;
     }
-    & > img {
-      margin-right: 8px;
-      width: 12px;
-      height: 14px;
-    }
   }
 }
 .add-element-handler {

+ 2 - 2
src/views/Editor/Thumbnails/index.vue

@@ -432,8 +432,8 @@ const contextmenusThumbnailItem = (): ContextmenuItem[] => {
       display: flex;
       & > img {
         cursor: pointer;
-        width: 32px;
-        height: 32px;
+        width: 28px;
+        height: 28px;
         &:hover {
           opacity: 0.8;
         }

BIN
src/views/components/element/cloudCoachElement/cloudCoachList/imgs/musicBg.png


+ 1 - 1
src/views/components/element/cloudCoachElement/cloudCoachPlayer/cloudCoachPlayer.vue

@@ -32,7 +32,7 @@ const props = withDefaults(
   }
 )
 const url = computed(() => {
-  return `${YJL_URL_API}?v=${Date.now()}&modelType=practise&id=${props.id}&platform=pc&zoom=0.8&instrumentId=&Authorization=${getToken()}`
+  return `${YJL_URL_API}?v=${Date.now()}&showGuide=true&showWebGuide=false&platform=pc&imagePos=right&zoom=0.8&modelType=practise&instrumentId=&id=${props.id}&Authorization=${getToken()}`
 })
 const loading = ref(true)
 function handleIframeLoad() {

+ 4 - 1
src/worker/useCoursewaresWorker.ts

@@ -2,6 +2,7 @@ import myWorker from "./index"
 import axios from "axios"
 import { getToken } from "@/libs/auth"
 import { URL_API } from "@/config/index"
+import usePptWork from "@/store/pptWork"
 
 let worker: any = null
 let useOnCoursewaresMessage = (e: any) => {}
@@ -13,10 +14,12 @@ export const initWorker = () => {
   // eslint-disable-next-line no-async-promise-executor
   return new Promise(async (resolve, reject) => {
     if (!worker) {
+      const usePptWorkHook = usePptWork()
       const str1 = await axios.get("./pptworker/cos-js-sdk-v5.min.js")
       const str2 = await axios.get("./pptworker/upload.js")
       const str3 = await axios.get("./pptworker/pptJson.js")
-      worker = new myWorker([str1.data, str2.data, str3.data])
+      /*  这里根据id 加上一个文件夹 */
+      worker = new myWorker([str1.data, `\r\nconst filePath = "${usePptWorkHook.id}/"\r\n`, str2.data, str3.data])
       worker.ready
         .then(() => worker.createTaskController())
         .then(() => {

+ 1 - 1
vite.config.ts

@@ -28,7 +28,7 @@ export default defineConfig({
     proxy: {
       // 正则表达式写法
       "^/pptApi/.*": {
-        target: "https://dev.kt.colexiu.com",
+        target: "https://test.kt.colexiu.com",
         changeOrigin: true,
         rewrite: path => path.replace(/^\/pptApi/, "")
       }