feat: 重构 PrimeVue 相关插件,优化对话框和通知服务的使用,更新样式和组件结构
This commit is contained in:
61
src/main.ts
61
src/main.ts
@ -4,63 +4,28 @@ import 'virtual:uno.css';
|
||||
|
||||
import { createHead } from '@unhead/vue';
|
||||
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
|
||||
import { setupEruda } from './plugins/eruda';
|
||||
import { setupPrimeVue } from './plugins/primevue';
|
||||
import { setupRouter } from './plugins/router';
|
||||
import { setupVueI18n } from './plugins/vue-i18n';
|
||||
|
||||
import { DataLoaderPlugin } from 'unplugin-vue-router/data-loaders';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import App from './App.vue';
|
||||
import { router } from './router';
|
||||
|
||||
import Aura from '@primevue/themes/aura';
|
||||
import zhCN from 'primelocale/zh-CN.json';
|
||||
import PrimeVue from 'primevue/config';
|
||||
import 'primeicons/primeicons.css';
|
||||
|
||||
/* https://github.com/intlify/bundle-tools/tree/main/packages/unplugin-vue-i18n#static-bundle-importing
|
||||
* All i18n resources specified in the plugin `include` option can be loaded
|
||||
* at once using the import syntax
|
||||
*/
|
||||
import messages from '@intlify/unplugin-vue-i18n/messages';
|
||||
|
||||
async function init() {
|
||||
if ((import.meta.env.MODE === 'development' || 1 === 1) && 0) {
|
||||
// TODO: https://github.com/hu3dao/vite-plugin-debug/
|
||||
// https://eruda.liriliri.io/zh/docs/#快速上手
|
||||
await import('eruda').then(({ default: eruda }) => {
|
||||
eruda.init({
|
||||
defaults: {
|
||||
transparency: 0.9,
|
||||
},
|
||||
});
|
||||
// eruda.show();
|
||||
});
|
||||
await setupEruda();
|
||||
}
|
||||
|
||||
console.debug(`messages :>> `, messages);
|
||||
const app = createApp(App)
|
||||
const app = createApp(App) //
|
||||
.use(createHead())
|
||||
.use(createPinia().use(piniaPluginPersistedstate))
|
||||
// Register the plugin before the router
|
||||
.use(DataLoaderPlugin, { router })
|
||||
// adding the router will trigger the initial navigation
|
||||
.use(router)
|
||||
.use(
|
||||
// https://vue-i18n.intlify.dev/guide/essentials/started.html#registering-the-i18n-plugin
|
||||
createI18n({
|
||||
legacy: false, // you must set `false`, to use Composition API
|
||||
locale: navigator.language,
|
||||
messages,
|
||||
}),
|
||||
)
|
||||
.use(PrimeVue, {
|
||||
locale: zhCN['zh-CN'], // usePrimeVue().config.locale
|
||||
theme: { preset: Aura },
|
||||
options: {
|
||||
prefix: 'p',
|
||||
darkModeSelector: 'system',
|
||||
cssLayer: false,
|
||||
},
|
||||
});
|
||||
.use(createPinia().use(piniaPluginPersistedstate));
|
||||
|
||||
setupVueI18n(app);
|
||||
setupPrimeVue(app);
|
||||
setupRouter(app);
|
||||
|
||||
app.config.globalProperties.$__DEV__ = $__DEV__;
|
||||
|
||||
app.mount('#app');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user