提交 57ef5b4d 编写于 作者: fxy060608's avatar fxy060608

wip(mp): shadow

上级 3e3bacbd
......@@ -21,6 +21,7 @@ import {
import type { ParserPlugin } from '@babel/parser'
import { getPlatformDir } from './platform'
import { isInHBuilderX } from './hbx'
import { parseManifestJsonOnce } from './json'
// 专为 uts.ts 服务
export { camelize, capitalize, isArray } from '@vue/shared'
......@@ -241,3 +242,14 @@ export function normalizeEmitAssetFileName(fileName: string) {
}
return fileName
}
export function createIdent() {
if (process.env.UNI_INPUT_DIR) {
const manifestJson = parseManifestJsonOnce(process.env.UNI_INPUT_DIR)
const id = (manifestJson.appid || '').replace('__UNI__', '')
if (id) {
return Buffer.from(Buffer.from(id).toString('base64')).toString('hex')
}
}
return ''
}
......@@ -4,6 +4,7 @@ import type { Plugin, ResolvedConfig } from 'vite'
import type { EmittedAsset } from 'rollup'
import {
createEncryptCssUrlReplacer,
createIdent,
cssPostPlugin,
injectAssetPlugin,
injectCssPlugin,
......@@ -28,8 +29,11 @@ const debugNVueCss = debug('uni:nvue-css')
const cssVars = `page{--status-bar-height:25px;--top-window-height:0px;--window-top:0px;--window-bottom:0px;--window-left:0px;--window-right:0px;--window-magin:0px}`
const genShadowCss = (cdn: string) => {
return `page::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 ident = createIdent()
const identStr = ident ? `${ident}/` : ''
return `page::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}/${identStr}img/shadow-grey.png)}100%{background-image:url(${cdn}/${identStr}img/shadow-grey.png)}}@keyframes shadow-preload{0%{background-image:url(${cdn}/${identStr}img/shadow-grey.png)}100%{background-image:url(${cdn}/${identStr}img/shadow-grey.png)}}`
}
const genComponentCustomHiddenCss = (name: string) =>
`[${name.replace(':', '')}="true"]{display: none !important;}`
......@@ -99,7 +103,12 @@ export function createConfigResolved({
if (config.isProduction) {
return (
cssCode +
genShadowCss(`https://cdn${cdn || ''}.dcloud.net.cn`) +
genShadowCss(
`https://cdn${
(cdn || 0) +
(process.env.UNI_APP_X === 'true' ? 1000 : 0) || ''
}.dcloud.net.cn`
) +
cssVars +
componentCustomHiddenCss
)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册