82 lines
2.1 KiB
TypeScript
82 lines
2.1 KiB
TypeScript
import '@common/error'
|
|
import { createApp } from 'vue'
|
|
|
|
import './core/globalData'
|
|
|
|
import '@renderer/event'
|
|
|
|
// Components
|
|
import mountComponents from './components'
|
|
|
|
// Plugins
|
|
import initPlugins from './plugins'
|
|
import { i18nPlugin } from './plugins/i18n'
|
|
|
|
import App from './App.vue'
|
|
import router from './router'
|
|
// import store from './store'
|
|
|
|
|
|
import { getSetting, updateSetting } from './utils/ipc'
|
|
import { langList } from '@/lang'
|
|
import type { I18n } from '@/lang/i18n'
|
|
|
|
import { initSetting } from './store/setting'
|
|
// import { bubbleCursor } from './utils/cursor-effects/bubbleCursor'
|
|
|
|
import './worker'
|
|
import { saveViewPrevState } from './utils/data'
|
|
|
|
// sync(store, router)
|
|
|
|
router.afterEach((to) => {
|
|
if (to.path != '/songList/detail') {
|
|
saveViewPrevState({
|
|
url: to.path,
|
|
query: { ...to.query },
|
|
})
|
|
}
|
|
})
|
|
|
|
void getSetting().then(setting => {
|
|
// window.lx.appSetting = setting
|
|
// Set language automatically
|
|
if (!setting['common.langId'] || !window.i18n.availableLocales.includes(setting['common.langId'])) {
|
|
let langId: I18n['locale'] | null = null
|
|
let locale = window.navigator.language.toLocaleLowerCase() as I18n['locale']
|
|
if (window.i18n.availableLocales.includes(locale)) {
|
|
langId = locale
|
|
} else {
|
|
for (const lang of langList) {
|
|
if (lang.alternate == locale) {
|
|
langId = lang.locale
|
|
break
|
|
}
|
|
}
|
|
langId ??= 'en-us'
|
|
}
|
|
setting['common.langId'] = langId
|
|
void updateSetting({ 'common.langId': langId })
|
|
console.log('Set lang', setting['common.langId'])
|
|
}
|
|
window.i18n.setLanguage(setting['common.langId'])
|
|
|
|
if (!setting['common.startInFullscreen'] && (document.body.clientHeight > window.screen.availHeight || document.body.clientWidth > window.screen.availWidth) && setting['common.windowSizeId'] > 1) {
|
|
void updateSetting({ 'common.windowSizeId': 1 })
|
|
}
|
|
|
|
// store.commit('setSetting', setting)
|
|
initSetting(setting)
|
|
|
|
const app = createApp(App)
|
|
app
|
|
.use(router)
|
|
// .use(store)
|
|
.use(i18nPlugin)
|
|
initPlugins(app)
|
|
mountComponents(app)
|
|
app.mount('#root')
|
|
})
|
|
|
|
// bubbleCursor()
|