main.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { createApp } from 'vue'
  2. import { createPinia } from 'pinia'
  3. import App from './App.vue'
  4. import en from './views/lang/en.json'
  5. import cn from './views/lang/cn.json'
  6. import hk from './views/lang/hk.json'
  7. export let lang = cn
  8. if (window.location.href.includes('cocorobo.cn')) {
  9. lang = cn
  10. }
  11. else if (window.location.href.includes('cocorobo.hk')) {
  12. lang = hk
  13. }
  14. else if (window.location.href.includes('cocorobo.com')) {
  15. lang = en
  16. }
  17. else {
  18. lang = cn
  19. }
  20. // TypeScript declarations for global properties
  21. declare module '@vue/runtime-core' {
  22. interface ComponentCustomProperties {
  23. $version: 'cn' | 'hk' | 'com'
  24. }
  25. }
  26. import '@icon-park/vue-next/styles/index.css'
  27. import 'prosemirror-view/style/prosemirror.css'
  28. import 'animate.css'
  29. import '@/assets/styles/prosemirror.scss'
  30. import '@/assets/styles/global.scss'
  31. import '@/assets/styles/font.scss'
  32. import Icon from '@/plugins/icon'
  33. import Directive from '@/plugins/directive'
  34. // 全局变量:判断当前版本 (cn/hk/com)
  35. export const getCurrentVersion = () => {
  36. const href = window.location.href.toLowerCase()
  37. if (href.includes('cn')) return 'cn'
  38. if (href.includes('hk')) return 'hk'
  39. if (href.includes('com')) return 'com'
  40. return 'cn' // 默认cn版本
  41. }
  42. // 当前版本
  43. export const currentVersion = getCurrentVersion()
  44. export default {currentVersion, lang}
  45. const app = createApp(App)
  46. // 注册全局变量
  47. app.config.globalProperties.$version = currentVersion
  48. app.use(Icon)
  49. app.use(Directive)
  50. app.use(createPinia())
  51. app.mount('#app')