Bladeren bron

Merge remote-tracking branch 'origin/master'

lizhenhao 2 jaren geleden
bovenliggende
commit
a335bb7340
3 gewijzigde bestanden met toevoegingen van 19470 en 26 verwijderingen
  1. 19386 22
      package-lock.json
  2. 82 2
      src/api/sys/OSSService.js
  3. 2 2
      src/views/modules/sys/login/login.vue

File diff suppressed because it is too large
+ 19386 - 22
package-lock.json


+ 82 - 2
src/api/sys/OSSService.js

@@ -109,9 +109,9 @@ export function fileName (file) {
 
 export function beforeAvatarUpload (file) {
   // 文件大小校验
-  const isLt2M = file.size / 1024 / 1024 < 1024
+  const isLt2M = file.size / 1024 / 1024 < 300
   if (!isLt2M) {
-    this.$message.error('文件大小不能超过 1G !')
+    this.$message.error('文件大小不能超过 300M !')
   }
   return isLt2M
 }
@@ -160,3 +160,83 @@ export async function httpRequest (file, name, type) { // 阿里云OSS上传
     file.onError('上传失败') // 触发el-upload组件的onError方法,此方法会移除文件列表
   })
 }
+
+// eslint-disable-next-line no-unused-vars
+function getTemporaryByUrl (url) {
+  return request({
+    url: '/oss/file/getTemporaryUrl',
+    method: 'get',
+    params: {url: url}
+  })
+}
+
+export async function openWindowOnUrl (row) {
+  var rowurl = ''
+  let suffix = row.name.substring(row.name.lastIndexOf('.') + 1)
+  if (suffix === 'jpg' || suffix === 'png' || suffix === 'gif' || suffix === 'bmp' || suffix === 'jpeg') {
+    if (row.url !== null && row.url !== undefined && row.url !== '') {
+      // eslint-disable-next-line no-undef
+      onPreview(row.temporaryUrl)
+      return
+    } else {
+      await getTemporaryByUrl(row.raw.url).then((data) => {
+        // eslint-disable-next-line no-undef
+        onPreview(data.data)
+      })
+      return
+    }
+  }
+  if (row.url !== null && row.url !== undefined && row.url !== '') {
+    if (suffix === 'pdf') {
+      window.open('https://view.xdocin.com/xdoc?_xdoc=' + encodeURIComponent(row.temporaryUrl), '_blank')
+    } else if (suffix === 'rar' || suffix === 'zip' || suffix === 'jar' || suffix === '7z') {
+      window.open('http://ow365.cn/?i=30045&furl=' + encodeURIComponent(row.temporaryUrl), '_blank')
+    } else {
+      window.open('https://view.officeapps.live.com/op/view.aspx?src=' + encodeURIComponent(row.temporaryUrl), '_blank')
+    }
+  } else if (row.raw.url !== null && row.raw.url !== undefined && row.raw.url !== '') {
+    await getTemporaryByUrl(row.raw.url).then((data) => {
+      rowurl = data.data
+    })
+    if (suffix === 'pdf') {
+      window.open('https://view.xdocin.com/xdoc?_xdoc=' + encodeURIComponent(rowurl), '_blank')
+    } else if (suffix === 'rar' || suffix === 'zip' || suffix === 'jar' || suffix === '7z') {
+      window.open('http://ow365.cn/?i=30045&furl=' + encodeURIComponent(rowurl), '_blank')
+    } else {
+      window.open('https://view.officeapps.live.com/op/view.aspx?src=' + encodeURIComponent(rowurl), '_blank')
+    }
+  }
+}
+
+export async function toHref (row) {
+  const link = document.createElement('a')
+  if (row.id === null || row.id === undefined || row.id === '') {
+    await getTemporaryByUrl(row.raw.url).then((data) => {
+      const url = data.data // 完整的url则直接使用
+      // 这里是将url转成blob地址,
+      fetch(url).then(res => res.blob()).then(blob => { // 将链接地址字符内容转变成blob地址
+        link.href = URL.createObjectURL(blob)
+        link.download = row.name || '' // 下载文件的名字
+        // a.download = url.split('/')[url.split('/').length -1] //  // 下载文件的名字
+        document.body.appendChild(link)
+        link.click()
+        // 在资源下载完成后 清除 占用的缓存资源
+        window.URL.revokeObjectURL(link.href)
+        document.body.removeChild(link)
+      })
+    })
+  } else {
+    const url = row.temporaryUrl // 完整的url则直接使用
+    // 这里是将url转成blob地址,
+    fetch(url).then(res => res.blob()).then(blob => { // 将链接地址字符内容转变成blob地址
+      link.href = URL.createObjectURL(blob)
+      link.download = row.name || '' // 下载文件的名字
+      // a.download = url.split('/')[url.split('/').length -1] //  // 下载文件的名字
+      document.body.appendChild(link)
+      link.click()
+      // 在资源下载完成后 清除 占用的缓存资源
+      window.URL.revokeObjectURL(link.href)
+      document.body.removeChild(link)
+    })
+  }
+}

+ 2 - 2
src/views/modules/sys/login/login.vue

@@ -161,7 +161,7 @@
               if (checked) {
                 // eslint-disable-next-line no-undef
                 // let password = Base64.encode(passwordLogin) // base64加密
-                this.setCookie(username, Base64.encode(password), 7)
+                this.setCookie(Base64.encode(username), Base64.encode(password), 7)
               } else {
                 this.setCookie('', '', -1) // 修改2值都为空,天数为负1天就好了
               }
@@ -219,7 +219,7 @@
           for (let i = 0; i < arr.length; i++) {
             let arr2 = arr[i].split('=') // 再次切割,arr2[0]为key值,arr2[1]为对应的value
             if (arr2[0] === 'username') {
-              this.inputForm.username = arr2[1]
+              this.inputForm.username = Base64.decode(arr2[1])// base64解密
             } else if (arr2[0] === 'password') {
               // eslint-disable-next-line no-undef
               this.inputForm.password = Base64.decode(arr2[1])// base64解密