智能照明系统APP-本地串口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
LightingSystemApp-serial/.svn/pristine/2b/2b58757947c7689e2749e661d8c...

39 lines
1004 B

import getRealRoute from 'uni-helpers/get-real-route'
const SCHEME_RE = /^([a-z-]+:)?\/\//i
const DATA_RE = /^data:.*,.*/
function addBase (filePath) {
const base = __uniConfig.router.base
if (!base) {
return filePath
}
if (base !== '/') {
// 部分地址已经带了base(如被webpack处理过的资源自动带了publicPath)
if (('/' + filePath).indexOf(base) === 0) {
return '/' + filePath
}
}
return base + filePath
}
export default function getRealPath (filePath) {
if (filePath.indexOf('/') === 0) {
if (filePath.indexOf('//') === 0) {
filePath = 'https:' + filePath
} else {
return addBase(filePath.substr(1))
}
}
// 网络资源或base64
if (SCHEME_RE.test(filePath) || DATA_RE.test(filePath) || filePath.indexOf('blob:') === 0) {
return filePath
}
const pages = getCurrentPages()
if (pages.length) {
return addBase(getRealRoute(pages[pages.length - 1].$page.route, filePath).substr(1))
}
return filePath
}