diff --git a/src/components/preview/VideoPreview.vue b/src/components/preview/VideoPreview.vue index 39f665b..11f377c 100644 --- a/src/components/preview/VideoPreview.vue +++ b/src/components/preview/VideoPreview.vue @@ -132,7 +132,7 @@ export default { if (this.file.m3u8) { videoUrl = `${fileConfig.baseUrl}/video/hls/${this.file.m3u8}` if (this.shareId) { - videoUrl = `${fileConfig.baseUrl}/public/video/hls/${this.file.m3u8}?share-token=${this.$store.getters.shareToken}` + videoUrl = `${fileConfig.baseUrl}/public/video/hls/${this.file.m3u8}` } } this.option.url = videoUrl diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 876ab4c..8529d29 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -121,7 +121,7 @@ const actions = { fileApi.validShareCode({ shareId: shareId, shareCode: shareCode }).then(response => { const { data } = response commit('SET_SHARE_TOKEN', data) - setShareToken(data) + setShareToken(data, shareId) resolve() }).catch(error => { reject(error) diff --git a/src/utils/auth.js b/src/utils/auth.js index a91fa9e..15fc083 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -3,6 +3,7 @@ import Cookies from 'js-cookie' const tokenKey = 'jmal-token' const usernameKey = 'username' const shareTokenKey = 'share-token' +const shareIdKey = 'shareId' const consumerId = 'consumerId' const rememberName = 'rememberName' @@ -34,8 +35,13 @@ export function getShareToken() { return Cookies.get(shareTokenKey) } -export function setShareToken(token) { - return Cookies.set(shareTokenKey, token) +export function getShareId() { + return Cookies.get(shareIdKey) +} + +export function setShareToken(token, shareId) { + Cookies.set(shareTokenKey, token) + Cookies.set(shareIdKey, shareId) } export function setToken(token) { @@ -48,7 +54,8 @@ export function removeToken() { } export function removeShareToken() { - return Cookies.remove(shareTokenKey) + Cookies.remove(shareTokenKey) + Cookies.remove(shareIdKey) } export function getConsumerId() { diff --git a/src/utils/request.js b/src/utils/request.js index 92266c7..586de09 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,6 +1,6 @@ // import { MessageBox, Message } from 'element-ui' import store from '@/store' -import {getShareToken, getToken, getUsername} from '@/utils/auth' +import {getShareId, getShareToken, getToken, getUsername} from '@/utils/auth' // create an axios instance const service = axios.create({ @@ -21,6 +21,7 @@ service.interceptors.request.use( } if (store.getters.shareToken) { config.headers['share-token'] = getShareToken() + config.headers['shareId'] = getShareId() } return config }, diff --git a/src/views/public/share/shareList.vue b/src/views/public/share/shareList.vue index 87cf853..7a2ad86 100644 --- a/src/views/public/share/shareList.vue +++ b/src/views/public/share/shareList.vue @@ -295,7 +295,6 @@ export default { return { prompt: '文件分享已被撤销',// 文件分享已被撤销 isLoading: true, - //imageUrl: this.$store.getters.shareToken ? `${process.env.VUE_APP_BASE_API}/public/s/view/thumbnail?id=` : `${process.env.VUE_APP_BASE_API}/public/s/view/thumbnail?share-token=${this.$store.getters.shareToken}&id=`, fileMenuActive: '', path: this.$route.query.path, showNewFolder: false,