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

chore: print startup duration

上级 f4f0c2a4
......@@ -22,4 +22,4 @@ export const M = {
'mp.component.args[1]': '{0}需要两个参数',
'mp.360.unsupported': 'vue3暂不支持360小程序',
'file.notfound': '{file} 文件不存在',
}
} as const
......@@ -5246,11 +5246,13 @@ function vFor(source, renderItem) {
function renderSlot(name, props = {}, key) {
const instance = getCurrentInstance();
const vueIds = instance.attrs.uI;
const { parent, isMounted, ctx: { $scope }, } = instance;
// mp-alipay 为 props
const vueIds = ($scope.properties || $scope.props).uI;
if (!vueIds) {
return;
}
if (!instance.parent && !instance.isMounted) {
if (!parent && !isMounted) {
// 头条小程序首次 render 时,还没有 parent
onMounted(() => {
renderSlot(name, props, key);
......
import { extend } from '@vue/shared'
import { RollupWatcher } from 'rollup'
import type { BuildOptions, ServerOptions } from 'vite'
import { BuildOptions, createLogger, ServerOptions } from 'vite'
import { M } from '@dcloudio/uni-cli-shared'
import { CliOptions } from '.'
import { build, buildSSR } from './build'
import { createServer, createSSRServer } from './server'
import { initEnv } from './utils'
import { initEnv, printStartupDuration } from './utils'
import { initEasycom } from '../utils/easycom'
export async function runDev(options: CliOptions & ServerOptions) {
......@@ -30,13 +30,13 @@ export async function runDev(options: CliOptions & ServerOptions) {
console.log(M['dev.watching.start'])
} else if (event.code === 'BUNDLE_END') {
event.result.close()
if (options.platform !== 'app') {
// 非App平台无需处理增量同步
return console.log(M['dev.watching.end'])
}
if (isFirstEnd) {
// 首次全量同步
return (isFirstEnd = false), console.log(M['dev.watching.end'])
return (
(isFirstEnd = false),
console.log(M['dev.watching.end']),
printStartupDuration(createLogger(options.logLevel), false)
)
}
if (process.env.UNI_APP_CHANGED_FILES) {
return console.log(
......
......@@ -191,13 +191,18 @@ export function cleanOptions(options: CliOptions) {
return ret
}
export function printStartupDuration(logger: Logger) {
export function printStartupDuration(
logger: Logger,
whitespace: boolean = true
) {
// @ts-ignore
if (global.__vite_start_time) {
// @ts-ignore
const startupDuration = performance.now() - global.__vite_start_time
logger.info(
`\n ${chalk.cyan(`ready in ${Math.ceil(startupDuration)}ms.`)}\n`
`${whitespace ? `\n ` : ''}${chalk.cyan(
`ready in ${Math.ceil(startupDuration)}ms.`
)}\n`
)
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册