浏览代码

feat(hiTeachSideMenu): 下載資源改為傳 URL 與 SAS

terry 3 月之前
父节点
当前提交
86a9392c48

+ 24 - 16
TEAMModelOS/ClientApp/src/components/hiTeachSideMenu/content/index.vue

@@ -319,8 +319,16 @@ export default {
   },
   methods: {
       clickCard(event, { value }) {
-          event.preventDefault();
-          callDesktopAppMethods.downloadResource(this.blobContainerName, value.blob);
+        event.preventDefault();
+        let url = value.url;
+        let sas;
+
+        if (value.extension === 'HTEX') {
+          url = url.replace('/index.json', '');
+        }
+        [url, sas] = url.split('?');
+        sas ??= '';
+        callDesktopAppMethods.downloadResource(url, sas);
       },
     onWxtClick() {
       this.$api.auth.xkwOauth({
@@ -795,12 +803,6 @@ export default {
         this.fileColumns.splice(2, 0, ...arr)
       }
       this.contentTypeList = [
-        //{
-        //  label: this.$t('teachContent.recent'),
-        //  type: 'recent',
-        //  icon: 'md-time',
-        //  tips: this.$t('teachContent.recentTips')
-        //},
         {
           label: this.$t('teachContent.filterRes'),
           type: 'res',
@@ -1129,7 +1131,16 @@ export default {
     },
 
     handleResource(row) {
-        callDesktopAppMethods.downloadResource(this.blobContainerName, row.blob);
+      let url = row.url;
+      let sas;
+      console.log(sas)
+
+      if (row.extension === 'HTEX') {
+        url = url.replace('/index.json', '');
+      }
+      [url, sas] = url.split('?');
+      sas ??= '';
+      callDesktopAppMethods.downloadResource(url, sas);
     },
 
     formatDate(timestamp) {
@@ -1230,11 +1241,7 @@ export default {
       this.extFilter = []
       this.selections.length = 0
       this.activeType = this.contentTypeList[index].type
-      //最近上传文件读取本地storage
-      if (this.activeType == 'recent') {
-        this.getCacheFiles()
-        return
-      }
+
       if (this.isFirst[this.activeType]) {
         this.fileListShow.length = 0
         this.findFileList()
@@ -1376,7 +1383,7 @@ export default {
       }
     },
     $route: {
-      handler: function (to, from) {
+      handler: async function (to, from) {
         this.initData()
         if (this.$route.fullPath.includes('school')) {
           this.routerScope = 'school'
@@ -1384,7 +1391,8 @@ export default {
           this.routerScope = 'private'
         }
 
-        this.getSasStr()
+        await this.getSasStr()
+        this.findFileList()
       },
       immediate: true
     },

+ 8 - 3
TEAMModelOS/ClientApp/src/components/hiTeachSideMenu/syllabus/index.vue

@@ -2577,9 +2577,14 @@ export default {
                   break;
 
               default:
-                  callDesktopAppMethods.downloadResource(item.code, item.link)
-                  break;
-
+                const sasInfo = item.scope === 'school' ?
+                  await this.$tools.getSchoolSas() : 
+                  await this.$tools.getPrivateSas()
+                const url = `${sasInfo.url}/${item.code}${item.link}`;
+                const sas = sasInfo.sas
+                callDesktopAppMethods.downloadResource(url, sas);
+
+                break;
           }
       },
 

+ 10 - 10
TEAMModelOS/ClientApp/src/utils/callDesktopAppMethods.js

@@ -1,13 +1,13 @@
 export const callDesktopAppMethods = {
-    openLink(url) {
-         window.chrome.webview.hostObjects.bridge.OpenLink(url);
-    },
+  openLink(url) {
+    window.chrome.webview.hostObjects.bridge.OpenLink(url);
+  },
 
-    downloadResource(containerName, blobFileName) {
-         window.chrome.webview.hostObjects.bridge.DownloadResource(containerName, blobFileName);
-    },
+  downloadResource(url, sas) {
+    window.chrome.webview.hostObjects.bridge.DownloadResource(url, sas);
+  },
 
-    openExternal(url) {
-         window.chrome.webview.hostObjects.bridge.OpenExternal(url);
-    },
-}
+  openExternal(url) {
+    window.chrome.webview.hostObjects.bridge.OpenExternal(url);
+  }
+};