v2.0.0
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
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 { 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 = null
|
||||
let locale = window.navigator.language.toLocaleLowerCase()
|
||||
if (window.i18n.availableLocales.includes(locale)) {
|
||||
langId = locale
|
||||
} else {
|
||||
for (const lang of langList) {
|
||||
if (lang.alternate == locale) {
|
||||
langId = lang.locale
|
||||
break
|
||||
}
|
||||
}
|
||||
if (langId == null) 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'])
|
||||
// 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()
|
||||
Reference in New Issue
Block a user