perf: 优化私密分享链接中m3u8文件的播放
This commit is contained in:
parent
1770bc8005
commit
571b7a8a32
@ -132,7 +132,7 @@ export default {
|
|||||||
if (this.file.m3u8) {
|
if (this.file.m3u8) {
|
||||||
videoUrl = `${fileConfig.baseUrl}/video/hls/${this.file.m3u8}`
|
videoUrl = `${fileConfig.baseUrl}/video/hls/${this.file.m3u8}`
|
||||||
if (this.shareId) {
|
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
|
this.option.url = videoUrl
|
||||||
|
|||||||
@ -121,7 +121,7 @@ const actions = {
|
|||||||
fileApi.validShareCode({ shareId: shareId, shareCode: shareCode }).then(response => {
|
fileApi.validShareCode({ shareId: shareId, shareCode: shareCode }).then(response => {
|
||||||
const { data } = response
|
const { data } = response
|
||||||
commit('SET_SHARE_TOKEN', data)
|
commit('SET_SHARE_TOKEN', data)
|
||||||
setShareToken(data)
|
setShareToken(data, shareId)
|
||||||
resolve()
|
resolve()
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
reject(error)
|
reject(error)
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import Cookies from 'js-cookie'
|
|||||||
const tokenKey = 'jmal-token'
|
const tokenKey = 'jmal-token'
|
||||||
const usernameKey = 'username'
|
const usernameKey = 'username'
|
||||||
const shareTokenKey = 'share-token'
|
const shareTokenKey = 'share-token'
|
||||||
|
const shareIdKey = 'shareId'
|
||||||
const consumerId = 'consumerId'
|
const consumerId = 'consumerId'
|
||||||
const rememberName = 'rememberName'
|
const rememberName = 'rememberName'
|
||||||
|
|
||||||
@ -34,8 +35,13 @@ export function getShareToken() {
|
|||||||
return Cookies.get(shareTokenKey)
|
return Cookies.get(shareTokenKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setShareToken(token) {
|
export function getShareId() {
|
||||||
return Cookies.set(shareTokenKey, token)
|
return Cookies.get(shareIdKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setShareToken(token, shareId) {
|
||||||
|
Cookies.set(shareTokenKey, token)
|
||||||
|
Cookies.set(shareIdKey, shareId)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setToken(token) {
|
export function setToken(token) {
|
||||||
@ -48,7 +54,8 @@ export function removeToken() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function removeShareToken() {
|
export function removeShareToken() {
|
||||||
return Cookies.remove(shareTokenKey)
|
Cookies.remove(shareTokenKey)
|
||||||
|
Cookies.remove(shareIdKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getConsumerId() {
|
export function getConsumerId() {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
// import { MessageBox, Message } from 'element-ui'
|
// import { MessageBox, Message } from 'element-ui'
|
||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
import {getShareToken, getToken, getUsername} from '@/utils/auth'
|
import {getShareId, getShareToken, getToken, getUsername} from '@/utils/auth'
|
||||||
|
|
||||||
// create an axios instance
|
// create an axios instance
|
||||||
const service = axios.create({
|
const service = axios.create({
|
||||||
@ -21,6 +21,7 @@ service.interceptors.request.use(
|
|||||||
}
|
}
|
||||||
if (store.getters.shareToken) {
|
if (store.getters.shareToken) {
|
||||||
config.headers['share-token'] = getShareToken()
|
config.headers['share-token'] = getShareToken()
|
||||||
|
config.headers['shareId'] = getShareId()
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
},
|
},
|
||||||
|
|||||||
@ -295,7 +295,6 @@ export default {
|
|||||||
return {
|
return {
|
||||||
prompt: '文件分享已被撤销',// 文件分享已被撤销
|
prompt: '文件分享已被撤销',// 文件分享已被撤销
|
||||||
isLoading: true,
|
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: '',
|
fileMenuActive: '',
|
||||||
path: this.$route.query.path,
|
path: this.$route.query.path,
|
||||||
showNewFolder: false,
|
showNewFolder: false,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user