提交 749ddb6a 编写于 作者: fxy060608's avatar fxy060608

chore: cdn

上级 c511dee9
...@@ -16110,11 +16110,7 @@ var serviceContext = (function (vue) { ...@@ -16110,11 +16110,7 @@ var serviceContext = (function (vue) {
type: 'loading', type: 'loading',
icon: 'loading', icon: 'loading',
}), callbacks), ShowLoadingProtocol, ShowLoadingOptions); }), callbacks), ShowLoadingProtocol, ShowLoadingOptions);
const _showToast = ({ title = '', icon = 'success', image = '', duration = 1500, mask = false, position, const _showToast = ({ title = '', icon = 'success', image = '', duration = 1500, mask = false, position, type = 'toast', style, }, { resolve, reject }) => {
// @ts-ignore ToastType
type = 'toast',
// @ts-ignore PlusNativeUIWaitingStyles
style, }, { resolve, reject }) => {
hide(''); hide('');
toastType = type; toastType = type;
if (['top', 'center', 'bottom'].includes(String(position))) { if (['top', 'center', 'bottom'].includes(String(position))) {
...@@ -16171,9 +16167,10 @@ var serviceContext = (function (vue) { ...@@ -16171,9 +16167,10 @@ var serviceContext = (function (vue) {
reject(`${error}`); reject(`${error}`);
} }
} }
timeout = setTimeout(() => { if (toastType === 'toast')
hide(''); timeout = setTimeout(() => {
}, duration); hide('');
}, duration);
return resolve(); return resolve();
}; };
const showToast = defineAsyncApi(API_SHOW_TOAST, _showToast, ShowToastProtocol, ShowToastOptions); const showToast = defineAsyncApi(API_SHOW_TOAST, _showToast, ShowToastProtocol, ShowToastOptions);
......
...@@ -161,6 +161,7 @@ const customElements = [ ...@@ -161,6 +161,7 @@ const customElements = [
'mkt', 'mkt',
]; ];
const options = { const options = {
cdn: 2,
vite: { vite: {
inject: { inject: {
uni: [path__default["default"].resolve(__dirname, 'uni.api.esm.js'), 'default'], uni: [path__default["default"].resolve(__dirname, 'uni.api.esm.js'), 'default'],
......
...@@ -53,6 +53,7 @@ export const customElements = [ ...@@ -53,6 +53,7 @@ export const customElements = [
] ]
export const options: UniMiniProgramPluginOptions = { export const options: UniMiniProgramPluginOptions = {
cdn: 2,
vite: { vite: {
inject: { inject: {
uni: [path.resolve(__dirname, 'uni.api.esm.js'), 'default'], uni: [path.resolve(__dirname, 'uni.api.esm.js'), 'default'],
......
...@@ -87,6 +87,7 @@ const compilerOptions = { ...@@ -87,6 +87,7 @@ const compilerOptions = {
}; };
const projectConfigFilename = 'project.swan.json'; const projectConfigFilename = 'project.swan.json';
const options = { const options = {
cdn: 3,
vite: { vite: {
inject: { inject: {
uni: [path__default["default"].resolve(__dirname, 'uni.api.esm.js'), 'default'], uni: [path__default["default"].resolve(__dirname, 'uni.api.esm.js'), 'default'],
......
...@@ -38,6 +38,7 @@ export const compilerOptions: CompilerOptions = { ...@@ -38,6 +38,7 @@ export const compilerOptions: CompilerOptions = {
const projectConfigFilename = 'project.swan.json' const projectConfigFilename = 'project.swan.json'
export const options: UniMiniProgramPluginOptions = { export const options: UniMiniProgramPluginOptions = {
cdn: 3,
vite: { vite: {
inject: { inject: {
uni: [path.resolve(__dirname, 'uni.api.esm.js'), 'default'], uni: [path.resolve(__dirname, 'uni.api.esm.js'), 'default'],
......
...@@ -152,6 +152,7 @@ const miniProgram = { ...@@ -152,6 +152,7 @@ const miniProgram = {
}; };
const projectConfigFilename = 'project.config.json'; const projectConfigFilename = 'project.config.json';
const options = { const options = {
cdn: 9,
vite: { vite: {
inject: { inject: {
uni: [path__default["default"].resolve(__dirname, 'uni.api.esm.js'), 'default'], uni: [path__default["default"].resolve(__dirname, 'uni.api.esm.js'), 'default'],
......
...@@ -38,6 +38,7 @@ export const miniProgram: MiniProgramCompilerOptions = { ...@@ -38,6 +38,7 @@ export const miniProgram: MiniProgramCompilerOptions = {
const projectConfigFilename = 'project.config.json' const projectConfigFilename = 'project.config.json'
export const options: UniMiniProgramPluginOptions = { export const options: UniMiniProgramPluginOptions = {
cdn: 9,
vite: { vite: {
inject: { inject: {
uni: [path.resolve(__dirname, 'uni.api.esm.js'), 'default'], uni: [path.resolve(__dirname, 'uni.api.esm.js'), 'default'],
......
...@@ -86,6 +86,7 @@ const miniProgram = { ...@@ -86,6 +86,7 @@ const miniProgram = {
}, },
}; };
const options = { const options = {
cdn: 4,
vite: { vite: {
inject: { inject: {
uni: [path__default["default"].resolve(__dirname, 'uni.api.esm.js'), 'default'], uni: [path__default["default"].resolve(__dirname, 'uni.api.esm.js'), 'default'],
...@@ -137,6 +138,7 @@ const uniMiniProgramToutiaoPlugin = { ...@@ -137,6 +138,7 @@ const uniMiniProgramToutiaoPlugin = {
}; };
}, },
}; };
options.cdn = 10;
options.template.slot.fallbackContent = false; options.template.slot.fallbackContent = false;
// 飞书不支持: // 飞书不支持:
// <view tt:for="{{items}}" tt:for-item="item" tt:key="id" slot="{{item.slot}}">{{item.text}}</view> // <view tt:for="{{items}}" tt:for-item="item" tt:key="id" slot="{{item.slot}}">{{item.text}}</view>
......
...@@ -19,6 +19,8 @@ const uniMiniProgramToutiaoPlugin: Plugin = { ...@@ -19,6 +19,8 @@ const uniMiniProgramToutiaoPlugin: Plugin = {
}, },
} }
options.cdn = 10
options.template.slot.fallbackContent = false options.template.slot.fallbackContent = false
// 飞书不支持: // 飞书不支持:
// <view tt:for="{{items}}" tt:for-item="item" tt:key="id" slot="{{item.slot}}">{{item.text}}</view> // <view tt:for="{{items}}" tt:for-item="item" tt:key="id" slot="{{item.slot}}">{{item.text}}</view>
......
...@@ -104,6 +104,7 @@ const miniProgram = { ...@@ -104,6 +104,7 @@ const miniProgram = {
}, },
}; };
const options = { const options = {
cdn: 5,
vite: { vite: {
inject: { inject: {
uni: [path__default["default"].resolve(__dirname, 'uni.api.esm.js'), 'default'], uni: [path__default["default"].resolve(__dirname, 'uni.api.esm.js'), 'default'],
......
...@@ -36,6 +36,7 @@ export const miniProgram: MiniProgramCompilerOptions = { ...@@ -36,6 +36,7 @@ export const miniProgram: MiniProgramCompilerOptions = {
} }
export const options: UniMiniProgramPluginOptions = { export const options: UniMiniProgramPluginOptions = {
cdn: 5,
vite: { vite: {
inject: { inject: {
uni: [path.resolve(__dirname, 'uni.api.esm.js'), 'default'], uni: [path.resolve(__dirname, 'uni.api.esm.js'), 'default'],
......
...@@ -86,6 +86,7 @@ const miniProgram = { ...@@ -86,6 +86,7 @@ const miniProgram = {
}, },
}; };
const options = { const options = {
cdn: 4,
vite: { vite: {
inject: { inject: {
uni: [path__default["default"].resolve(__dirname, 'uni.api.esm.js'), 'default'], uni: [path__default["default"].resolve(__dirname, 'uni.api.esm.js'), 'default'],
......
...@@ -39,6 +39,7 @@ export const miniProgram: MiniProgramCompilerOptions = { ...@@ -39,6 +39,7 @@ export const miniProgram: MiniProgramCompilerOptions = {
} }
export const options: UniMiniProgramPluginOptions = { export const options: UniMiniProgramPluginOptions = {
cdn: 4,
vite: { vite: {
inject: { inject: {
uni: [path.resolve(__dirname, 'uni.api.esm.js'), 'default'], uni: [path.resolve(__dirname, 'uni.api.esm.js'), 'default'],
......
...@@ -23,11 +23,15 @@ import { ...@@ -23,11 +23,15 @@ import {
const debugNVueCss = debug('vite:uni:nvue-css') const debugNVueCss = debug('vite: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 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 shadowCss = `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(https://cdn.dcloud.net.cn/img/shadow-grey.png)}100%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}}@keyframes shadow-preload{0%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}100%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}}`
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 genComponentCustomHiddenCss = (name: string) => const genComponentCustomHiddenCss = (name: string) =>
`[${name.replace(':', '')}="true"]{display: none !important;}` `[${name.replace(':', '')}="true"]{display: none !important;}`
export function createConfigResolved({ export function createConfigResolved({
cdn,
style: { extname }, style: { extname },
template: { component }, template: { component },
}: UniMiniProgramPluginOptions): Plugin['configResolved'] { }: UniMiniProgramPluginOptions): Plugin['configResolved'] {
...@@ -63,7 +67,12 @@ export function createConfigResolved({ ...@@ -63,7 +67,12 @@ export function createConfigResolved({
genComponentCustomHiddenCss(component.vShow)) || genComponentCustomHiddenCss(component.vShow)) ||
'' ''
if (config.isProduction) { if (config.isProduction) {
return cssCode + shadowCss + cssVars + componentCustomHiddenCss return (
cssCode +
genShadowCss(`https://cdn${cdn || ''}.dcloud.net.cn`) +
cssVars +
componentCustomHiddenCss
)
} else { } else {
return cssCode + cssVars + componentCustomHiddenCss return cssCode + cssVars + componentCustomHiddenCss
} }
......
...@@ -24,6 +24,7 @@ import { ...@@ -24,6 +24,7 @@ import {
} from '@vue/compiler-sfc' } from '@vue/compiler-sfc'
export interface UniMiniProgramPluginOptions { export interface UniMiniProgramPluginOptions {
cdn?: number
vite: { vite: {
alias: AliasOptions alias: AliasOptions
copyOptions: CopyOptions copyOptions: CopyOptions
......
...@@ -81,6 +81,7 @@ const miniProgram = { ...@@ -81,6 +81,7 @@ const miniProgram = {
}; };
const projectConfigFilename = 'project.config.json'; const projectConfigFilename = 'project.config.json';
const options = { const options = {
cdn: 1,
vite: { vite: {
inject: { inject: {
uni: [path__default["default"].resolve(__dirname, 'uni.api.esm.js'), 'default'], uni: [path__default["default"].resolve(__dirname, 'uni.api.esm.js'), 'default'],
......
...@@ -37,6 +37,7 @@ export const miniProgram: MiniProgramCompilerOptions = { ...@@ -37,6 +37,7 @@ export const miniProgram: MiniProgramCompilerOptions = {
const projectConfigFilename = 'project.config.json' const projectConfigFilename = 'project.config.json'
export const options: UniMiniProgramPluginOptions = { export const options: UniMiniProgramPluginOptions = {
cdn: 1,
vite: { vite: {
inject: { inject: {
uni: [path.resolve(__dirname, 'uni.api.esm.js'), 'default'], uni: [path.resolve(__dirname, 'uni.api.esm.js'), 'default'],
......
...@@ -70,6 +70,7 @@ const miniProgram = { ...@@ -70,6 +70,7 @@ const miniProgram = {
}; };
const projectConfigFilename = 'jsconfig.json'; const projectConfigFilename = 'jsconfig.json';
const options = { const options = {
cdn: process.env.UNI_SUB_PLATFORM === 'quickapp-webview-huawei' ? 200 : 201,
vite: { vite: {
inject: { inject: {
uni: [path__default["default"].resolve(__dirname, 'uni.api.esm.js'), 'default'], uni: [path__default["default"].resolve(__dirname, 'uni.api.esm.js'), 'default'],
......
...@@ -28,6 +28,7 @@ export const miniProgram: MiniProgramCompilerOptions = { ...@@ -28,6 +28,7 @@ export const miniProgram: MiniProgramCompilerOptions = {
const projectConfigFilename = 'jsconfig.json' const projectConfigFilename = 'jsconfig.json'
export const options: UniMiniProgramPluginOptions = { export const options: UniMiniProgramPluginOptions = {
cdn: process.env.UNI_SUB_PLATFORM === 'quickapp-webview-huawei' ? 200 : 201,
vite: { vite: {
inject: { inject: {
uni: [path.resolve(__dirname, 'uni.api.esm.js'), 'default'], uni: [path.resolve(__dirname, 'uni.api.esm.js'), 'default'],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册