@dcloudio/uni-cli-shared
Advanced tools
Comparing version 2.0.2-4020420240722003 to 2.0.2-4020420240722004
const fs = require('fs') | ||
const path = require('path') | ||
const { | ||
getManifestJson | ||
} = require('./manifest') | ||
@@ -20,6 +23,8 @@ const { | ||
} | ||
const cdn = getShadowCdn() | ||
return `${tagName}::after{position:fixed;content:'';left:-1000px;top:-1000px;-webkit-animation:shadow-preload .1s;-webkit-animation-delay:3s;animation:shadow-preload .1s;animation-delay:3s}@-webkit-keyframes shadow-preload{0%{background-image:url(${cdn}/img/shadow-grey.png)}100%{background-image:url(${cdn}/img/shadow-grey.png)}}@keyframes shadow-preload{0%{background-image:url(${cdn}/img/shadow-grey.png)}100%{background-image:url(${cdn}/img/shadow-grey.png)}}` | ||
const url = createShadowImageUrl(getShadowCdn(), 'grey') | ||
return `${tagName}::after{position:fixed;content:'';left:-1000px;top:-1000px;-webkit-animation:shadow-preload .1s;-webkit-animation-delay:3s;animation:shadow-preload .1s;animation-delay:3s}@-webkit-keyframes shadow-preload{0%{background-image:url(${url})}100%{background-image:url(${url})}}@keyframes shadow-preload{0%{background-image:url(${url})}100%{background-image:url(${url})}}` | ||
} | ||
const cdns = { | ||
h5: '', | ||
web: '', | ||
'mp-weixin': 1, | ||
@@ -41,6 +46,29 @@ 'mp-alipay': 2, | ||
function getShadowCdn () { | ||
const index = cdns[process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM] || '' | ||
return `https://cdn${index}.dcloud.net.cn` | ||
return cdns[process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM] || '' | ||
} | ||
let appid | ||
function createIdent () { | ||
if (process.env.UNI_INPUT_DIR) { | ||
if (typeof appid === 'undefined') { | ||
appid = getManifestJson().appid || '' | ||
} | ||
const id = appid.replace('__UNI__', '') | ||
if (id) { | ||
return Buffer.from(Buffer.from(id).toString('base64')).toString('hex') | ||
} | ||
} | ||
return '' | ||
} | ||
function createShadowImageUrl (cdn, type = 'grey') { | ||
let identStr = '' | ||
if (process.env.UNI_PLATFORM !== 'h5' && process.env.UNI_PLATFORM !== 'web') { | ||
const ident = createIdent() | ||
identStr = ident ? `${ident}/` : '' | ||
} | ||
return `https://cdn${cdn || ''}.dcloud.net.cn/${identStr}img/shadow-${type}.png` | ||
} | ||
// 解决 vue-cli-service lint 时 UNI_PLATFORM 不存在 | ||
@@ -150,2 +178,3 @@ process.env.UNI_PLATFORM = process.env.UNI_PLATFORM || 'h5' | ||
}, | ||
createShadowImageUrl, | ||
getShadowCss, | ||
@@ -158,3 +187,3 @@ getShadowTemplate (colorType = 'grey') { | ||
} | ||
return `<${tagName} src="${getShadowCdn()}/img/shadow-${colorType}.png" style="z-index:998;position:fixed;left:0;top:0;width:100%;height:3px;"/>` | ||
return `<${tagName} src="${createShadowImageUrl(getShadowCdn(), colorType)}" style="z-index:998;position:fixed;left:0;top:0;width:100%;height:3px;"/>` | ||
}, | ||
@@ -161,0 +190,0 @@ getPlatformScss () { |
{ | ||
"name": "@dcloudio/uni-cli-shared", | ||
"version": "2.0.2-4020420240722003", | ||
"version": "2.0.2-4020420240722004", | ||
"description": "uni-cli-shared", | ||
@@ -29,3 +29,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "7ab031552c02be8bb0c163fd2b81e6d811b23d29" | ||
"gitHead": "2d3e029c00dc153d1f9b01b3cf4e697470e01087" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
785482
5148
164