Commit 922d4b30 authored by 赵炳峰's avatar 赵炳峰

master

parent 7b2a9c12
......@@ -2,6 +2,8 @@
import ossConfig from '@/assets/ossConfig.js'
const isProd = process.env.NODE_ENV === 'production'
const onlinePreviewHost = 'http://onlinepreview.vschool100.cn/onlinePreview'
const wxQrcodeHost = 'https://mp.weixin.qq.com/cgi-bin/showqrcode'
// 文件域名 - type [默认为 0]: 0 - OSS 业务文件域名,1 - OSS 静态文件域名,2 - 老平台图片域名,3 - 老平台文件域名
// 说明:传入域名和类型,根据类型返回拼接完整的域名,默认不传类型为 OSS 业务文件域名
......@@ -20,7 +22,7 @@ export const getFileHost = (url, type = 0) => {
return ossConfig.staticResourcesFileBucket.domain + url
} else if (type === 2) {
return isProd
? 'http://image.vschool100.cn' + url
? 'https://image.vschool100.cn' + url
: 'http://test.vschool100.com:8888' + url
} else {
return isProd
......@@ -69,18 +71,23 @@ export const getObjectKey = (url, key = 'objectKey') => {
}
}
// 获取老平台头像
export const getHeadImgDomain = url => {
if (url) {
const imgReg = /^https?:\/\/|^blob:|^data:/
if (imgReg.test(url)) {
return url
} else {
// return `${ossConfig.bussinessFileBucket.domain}${url}`
return isProd
? `http://image.vschool100.cn${url}`
: `http://test.vschool100.com:8888${url}`
return url ? getFileHost(url, 2) : getFileHost('/Common/head.png', 1)
}
// 获取文件预览地址
export const getFileOnlinePreview = (url, type = 0) => {
if (!url) {
return new Error('Invalid url')
}
} else {
return `${ossConfig.staticResourcesFileBucket.domain}/Common/head.png`
return `${onlinePreviewHost}?url=${getFileHost(url, type)}`
}
// 获取微信二维码 传入tik
export const getWxQrcode = ticket => {
if (!ticket) {
return new Error('Invalid ticket')
}
return `${wxQrcodeHost}?ticket=${ticket}`
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment