feat(log): ✨ add versioning details for console output
This commit is contained in:
7
.env
7
.env
@@ -1,2 +1,9 @@
|
||||
# 项目名称
|
||||
VITE_APP_NAME="HuLa"
|
||||
# 客户端项目地址
|
||||
VITE_PC_URL="https://github.com/HuLaSpark/HuLa"
|
||||
# 后端项目地址
|
||||
VITE_SERVICE_URL="https://github.com/HuLaSpark/HuLa-Server"
|
||||
|
||||
# gitee token
|
||||
VITE_GITEE_TOKEN="a9029798336825cea39ac9e4413b8579"
|
||||
|
||||
88
build/config/console.ts
vendored
Normal file
88
build/config/console.ts
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
import pkg from '../../package.json'
|
||||
import { execSync } from 'node:child_process'
|
||||
|
||||
let rustVersion = 'unknown'
|
||||
try {
|
||||
rustVersion = execSync('rustc --version', { encoding: 'utf8' }).trim()
|
||||
} catch {}
|
||||
|
||||
const tauriCliVersion = pkg.devDependencies?.['@tauri-apps/cli'] ?? 'unknown'
|
||||
|
||||
const detectIsChineseLocale = () => {
|
||||
const locale = process.env.LANG || process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANGUAGE || ''
|
||||
return /zh/i.test(locale)
|
||||
}
|
||||
|
||||
const isChineseLocale = detectIsChineseLocale()
|
||||
|
||||
const ENV_LABEL = isChineseLocale ? '当前环境: ' : 'Environment: '
|
||||
const HOST_LABEL = isChineseLocale ? '主机: ' : 'Host: '
|
||||
const VERSION_LABEL = isChineseLocale ? '版本: ' : 'version: '
|
||||
const NODE_PREFIX = isChineseLocale ? '当前 ' : 'Current '
|
||||
const NODE_SUFFIX = isChineseLocale ? ' 版本: ' : ' version: '
|
||||
const PKG_MANAGER_LABEL = isChineseLocale ? '包管理器: ' : 'Package manager: '
|
||||
const SERVER_URL_LABEL = isChineseLocale ? '服务端项目地址: ' : 'Server project URL: '
|
||||
const CLIENT_URL_LABEL = isChineseLocale ? '客户端项目地址: ' : 'Client project URL: '
|
||||
|
||||
const getRuntimePackageManager = () => {
|
||||
const ua = process.env.npm_config_user_agent ?? ''
|
||||
if (!ua) return 'unknown'
|
||||
const firstPart = ua.split(' ')[0]
|
||||
return firstPart || 'unknown'
|
||||
}
|
||||
|
||||
const runtimePackageManager = getRuntimePackageManager()
|
||||
|
||||
/**
|
||||
* 启动时打印信息
|
||||
* @param env 环境变量
|
||||
* @param mode 运行模式
|
||||
* @param host 当前 Vite 服务器 Host
|
||||
*/
|
||||
export const atStartup = (env: { [key: string]: string }, mode: string, host: string) => {
|
||||
return () => {
|
||||
if (mode !== 'production') {
|
||||
console.log(
|
||||
` 🍀 ${'\x1b[32m'}${'\x1b[1m'}${env.VITE_APP_NAME} ${'\x1b[0m'}${'\x1b[90m'}${pkg.version}${'\x1b[0m'}`
|
||||
)
|
||||
console.log(
|
||||
` ${'\u001b[32m'}${'\x1b[1m'}${'➜'}${'\x1b[0m'} ` +
|
||||
`${ENV_LABEL}` +
|
||||
`${'\x1b[31m'}${mode}${'\x1b[0m'}` +
|
||||
` ${HOST_LABEL}` +
|
||||
`${'\x1b[36m'}${host}${'\x1b[0m'}`
|
||||
)
|
||||
console.log(
|
||||
` ${'\u001b[32m'}${'\x1b[1m'}${'➜'}${'\x1b[0m'} ${'\x1b[32m'}${'\x1b[1m'}${'Vue '}${'\x1b[0m'}${VERSION_LABEL} ` +
|
||||
`${'\x1b[90m'}${pkg.dependencies.vue}${'\x1b[0m'}` +
|
||||
` ${'\x1b[36m'}${'\x1b[1m'}${'Vite '}${'\x1b[0m'}${VERSION_LABEL} ` +
|
||||
`${'\x1b[90m'}${pkg.devDependencies.vite}${'\x1b[0m'}` +
|
||||
` ${'\u001b[34m'}${'\x1b[1m'}${'TypeScript '}${'\x1b[0m'}${VERSION_LABEL} ` +
|
||||
`${'\x1b[90m'}${pkg.devDependencies.typescript}${'\x1b[0m'}`
|
||||
)
|
||||
console.log(
|
||||
` ${'\u001b[32m'}${'\x1b[1m'}${'➜'}${'\x1b[0m'} ` +
|
||||
` ${'\x1b[33m'}${'\x1b[1m'}${'Tauri '}${'\x1b[0m'}${VERSION_LABEL} ` +
|
||||
`${'\x1b[90m'}${tauriCliVersion}${'\x1b[0m'}` +
|
||||
` ${'\x1b[38;5;208m'}${'\x1b[1m'}${'Rust '}${'\x1b[0m'}${VERSION_LABEL} ` +
|
||||
`${'\x1b[90m'}${rustVersion}${'\x1b[0m'}`
|
||||
)
|
||||
console.log(
|
||||
` ${'\u001b[32m'}${'\x1b[1m'}${'➜'}${'\x1b[0m'} ` +
|
||||
`${NODE_PREFIX}${'\x1b[32m'}${'\x1b[1m'}Node.js${'\x1b[0m'}${NODE_SUFFIX}`,
|
||||
`${'\x1b[90m'}${process.version}${'\x1b[0m'}`,
|
||||
` ${PKG_MANAGER_LABEL}${'\x1b[33m'}${'\x1b[90m'}${runtimePackageManager}${'\x1b[0m'}`
|
||||
)
|
||||
console.log(
|
||||
` ${'\u001b[32m'}${'\x1b[1m'}${'\u001b[2m'}${'➜'}${'\x1b[0m'} ` +
|
||||
SERVER_URL_LABEL +
|
||||
`${'\x1b[35m'}${env.VITE_SERVICE_URL}${'\x1b[0m'}`
|
||||
)
|
||||
console.log(
|
||||
` ${'\u001b[32m'}${'\x1b[1m'}${'\u001b[2m'}${'➜'}${'\x1b[0m'} ` +
|
||||
CLIENT_URL_LABEL +
|
||||
`${'\x1b[35m'}${env.VITE_PC_URL}${'\x1b[0m'}`
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
4
package.json
vendored
4
package.json
vendored
@@ -127,7 +127,7 @@
|
||||
"three": "^0.181.0",
|
||||
"tlbs-map-vue": "^1.3.1",
|
||||
"vant": "^4.9.21",
|
||||
"vue": "^3.5.24",
|
||||
"vue": "^3.5.25",
|
||||
"vue-cropper": "1.1.4",
|
||||
"vue-demi": "0.14.10",
|
||||
"vue-i18n": "^11.1.12",
|
||||
@@ -171,7 +171,7 @@
|
||||
"typescript": "^5.9.3",
|
||||
"unplugin-auto-import": "^20.2.0",
|
||||
"unplugin-vue-components": "^30.0.0",
|
||||
"vite": "7.2.2",
|
||||
"vite": "7.2.4",
|
||||
"vite-plugin-vue-setup-extend": "^0.4.0",
|
||||
"vitest": "^4.0.8",
|
||||
"vue-tsc": "^3.1.3",
|
||||
|
||||
538
pnpm-lock.yaml
generated
vendored
538
pnpm-lock.yaml
generated
vendored
File diff suppressed because it is too large
Load Diff
@@ -170,7 +170,7 @@ export const useLogin = () => {
|
||||
|
||||
// 后台同步消息:登录命令已触发一次全量/离线同步,这里避免重复拉取;仅在需要时再显式调用
|
||||
// 将消息预取和其他预热放后台,避免阻塞 UI
|
||||
Promise.allSettled([
|
||||
await Promise.allSettled([
|
||||
chatStore.setAllSessionMsgList(20),
|
||||
groupStore.setGroupDetails(),
|
||||
cachedStore.getAllBadgeList()
|
||||
|
||||
14
src/typings/env.d.ts
vendored
14
src/typings/env.d.ts
vendored
@@ -2,20 +2,10 @@
|
||||
interface ImportMetaEnv {
|
||||
/** 后端项目地址 */
|
||||
readonly VITE_SERVICE_URL: string
|
||||
/** websocket 地址 */
|
||||
readonly VITE_WEBSOCKET_URL: string
|
||||
/** 客户端项目地址 */
|
||||
readonly VITE_PC_URL: string
|
||||
/** 项目名称 */
|
||||
readonly VITE_APP_NAME: string
|
||||
/** 项目标题 */
|
||||
readonly VITE_APP_TITLE: string
|
||||
/** 开启请求代理 */
|
||||
readonly VITE_HTTP_PROXY?: 'Y' | 'N'
|
||||
/** 是否开启打包文件大小结果分析 */
|
||||
readonly VITE_VISUALIZER?: 'Y' | 'N'
|
||||
/** 是否开启打包压缩 */
|
||||
readonly VITE_COMPRESS?: 'Y' | 'N'
|
||||
/** 压缩算法类型 */
|
||||
readonly VITE_COMPRESS_TYPE?: 'gzip' | 'brotliCompress' | 'deflate' | 'deflateRaw'
|
||||
/** giteeToken */
|
||||
readonly VITE_GITEE_TOKEN: string
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import { type ConfigEnv, defineConfig, loadEnv } from 'vite'
|
||||
import VueSetupExtend from 'vite-plugin-vue-setup-extend'
|
||||
import { getComponentsDirs, getComponentsDtsPath } from './build/config/components'
|
||||
import { createManualChunks } from './build/config/chunks'
|
||||
import { atStartup } from './build/config/console'
|
||||
import { getRootPath, getSrcPath } from './build/config/getPath'
|
||||
|
||||
function getLocalIP() {
|
||||
@@ -66,7 +67,8 @@ export default defineConfig(({ mode }: ConfigEnv) => {
|
||||
: '127.0.0.1'
|
||||
})()
|
||||
|
||||
console.log('Host:', host)
|
||||
// 是否开启启动时打印信息
|
||||
atStartup(config, mode, host)()
|
||||
|
||||
return {
|
||||
resolve: {
|
||||
|
||||
Reference in New Issue
Block a user