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

chore(ssr): update log

上级 eee74a4a
...@@ -106,24 +106,34 @@ export async function createSSRServer(options: CliOptions & ServerOptions) { ...@@ -106,24 +106,34 @@ export async function createSSRServer(options: CliOptions & ServerOptions) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const onSuccess = () => { const onSuccess = () => {
const interfaces = os.networkInterfaces() const interfaces = os.networkInterfaces()
const locals: string[] = []
const networks: string[] = []
Object.keys(interfaces).forEach((key) => Object.keys(interfaces).forEach((key) =>
(interfaces[key] || []) (interfaces[key] || [])
.filter((details) => details.family === 'IPv4') .filter((details) => details.family === 'IPv4')
.map((detail) => { .forEach((detail) => {
return { if (detail.address.includes('127.0.0.1')) {
type: detail.address.includes('127.0.0.1') locals.push(detail.address)
? 'Local: ' } else {
: 'Network: ', networks.push(detail.address)
host: detail.address,
} }
}) })
.forEach(({ type, host }) => {
const url = `${protocol}://${host}:${chalk.bold(port)}${
vite.config.base
}`
logger.info(` - ${type} ${chalk.cyan(url)}`)
})
) )
locals.forEach((host) => {
const url = `${protocol}://${host}:${chalk.bold(port)}${
vite.config.base
}`
logger.info(` - Local: ${chalk.cyan(url)}`)
})
const networksLen = networks.length - 1
networks.forEach((host, index) => {
const url = `${protocol}://${host}:${chalk.bold(port)}${
vite.config.base
}`
logger.info(
` ${index === networksLen ? '-' : '>'} Network: ${chalk.cyan(url)}`
)
})
resolve(server) resolve(server)
} }
const onError = (e: Error & { code?: string }) => { const onError = (e: Error & { code?: string }) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册