main.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import './utils/patch-el-select-filterable'
  2. import App from './App.vue'
  3. import { createApp } from 'vue'
  4. import { ElTable } from 'element-plus'
  5. import EmptyAwareElTag from './utils/patch-el-tag-empty'
  6. ElTable.props.border = { type: Boolean, default: true }
  7. import { initStore } from './store' // Store
  8. import { initRouter } from './router' // Router
  9. import language from './locales' // 国际化
  10. import '@styles/core/tailwind.css' // tailwind
  11. import '@styles/index.scss' // 样式
  12. import '@utils/sys/console.ts' // 控制台输出内容
  13. import { setupGlobDirectives } from './directives'
  14. import { setupErrorHandle } from './utils/sys/error-handle'
  15. function maskSecret(value?: string) {
  16. if (!value) return '(empty)'
  17. if (value.length <= 6) return '*'.repeat(value.length)
  18. return `${value.slice(0, 3)}***${value.slice(-3)}`
  19. }
  20. function logApiCryptoBootInfo() {
  21. const {
  22. VITE_API_ENCRYPT_ENABLED,
  23. VITE_API_ENCRYPT_FAIL_OPEN,
  24. VITE_API_ENCRYPT_FIXED_SECRET,
  25. VITE_API_ENCRYPT_EXCLUDE_PATHS
  26. } = import.meta.env
  27. const excludeCount = String(VITE_API_ENCRYPT_EXCLUDE_PATHS || '')
  28. .split(',')
  29. .map((item) => item.trim())
  30. .filter(Boolean).length
  31. console.info(
  32. '[API_CRYPTO_BOOT] enabled=%s failOpen=%s fixedSecret=%s excludeCount=%s mode=%s',
  33. String(VITE_API_ENCRYPT_ENABLED || 'false'),
  34. String(VITE_API_ENCRYPT_FAIL_OPEN || 'true'),
  35. maskSecret(String(VITE_API_ENCRYPT_FIXED_SECRET || '')),
  36. excludeCount,
  37. import.meta.env.MODE
  38. )
  39. }
  40. document.addEventListener(
  41. 'touchstart',
  42. function () {},
  43. { passive: false }
  44. )
  45. logApiCryptoBootInfo()
  46. const app = createApp(App)
  47. app.component('ElTag', EmptyAwareElTag)
  48. initStore(app)
  49. initRouter(app)
  50. setupGlobDirectives(app)
  51. setupErrorHandle(app)
  52. app.use(language)
  53. app.mount('#app')