feat: 重构插件安装方式,统一使用 install 方法并移除不必要的 setup 函数
This commit is contained in:
14
src/plugins/_/_.ts
Normal file
14
src/plugins/_/_.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { createHead } from '@unhead/vue';
|
||||
|
||||
export function install({ app }: { app: import('vue').App<Element> }) {
|
||||
app.use(createHead());
|
||||
app.config.errorHandler = (error, instance, info) => {
|
||||
console.error('Global error:', error);
|
||||
console.error('Component:', instance);
|
||||
console.error('Error Info:', info);
|
||||
// 这里你可以:
|
||||
// 1. 发送错误到日志服务
|
||||
// 2. 显示全局错误提示
|
||||
// 3. 进行错误分析和处理
|
||||
};
|
||||
}
|
@ -1,12 +1,14 @@
|
||||
export async function setupEruda() {
|
||||
// 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,
|
||||
},
|
||||
export function install() {
|
||||
if ((import.meta.env.MODE === 'development' || 1 === 1) && 0) {
|
||||
// TODO: https://github.com/hu3dao/vite-plugin-debug/
|
||||
// https://eruda.liriliri.io/zh/docs/#快速上手
|
||||
import('eruda').then(({ default: eruda }) => {
|
||||
eruda.init({
|
||||
defaults: {
|
||||
transparency: 0.9,
|
||||
},
|
||||
});
|
||||
/* eruda.show(); */
|
||||
});
|
||||
// eruda.show();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { PiniaColada } from '@pinia/colada';
|
||||
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
|
||||
|
||||
export function setupPinia(app: import('vue').App) {
|
||||
export function install({ app }: { app: import('vue').App<Element> }) {
|
||||
app.use(createPinia().use(piniaPluginPersistedstate));
|
||||
app.use(PiniaColada, {});
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import Aura from '@primevue/themes/aura';
|
||||
import zhCN from 'primelocale/zh-CN.json';
|
||||
import PrimeVue from 'primevue/config';
|
||||
|
||||
export function setupPrimeVue(app: import('vue').App) {
|
||||
export function install({ app }: { app: import('vue').App<Element> }) {
|
||||
app.use(PrimeVue, {
|
||||
locale: {
|
||||
...zhCN['zh-CN'],
|
||||
|
@ -14,14 +14,14 @@ router.onError((error) => {
|
||||
console.debug('🚨 [router error]: ', error);
|
||||
});
|
||||
|
||||
function setupRouter(app: import('vue').App) {
|
||||
export { router };
|
||||
export function install({ app }: { app: import('vue').App<Element> }) {
|
||||
app
|
||||
// Register the plugin before the router
|
||||
.use(DataLoaderPlugin, { router })
|
||||
// adding the router will trigger the initial navigation
|
||||
.use(router);
|
||||
}
|
||||
export { router, setupRouter };
|
||||
// ========================================================================
|
||||
// =========================== Router Guards ==============================
|
||||
// ========================================================================
|
||||
|
@ -7,7 +7,7 @@ import { createI18n } from 'vue-i18n';
|
||||
import messages from '@intlify/unplugin-vue-i18n/messages';
|
||||
console.debug(`messages :>> `, messages);
|
||||
|
||||
export function setupVueI18n(app: import('vue').App) {
|
||||
export function install({ app }: { app: import('vue').App<Element> }) {
|
||||
app.use(
|
||||
// https://vue-i18n.intlify.dev/guide/essentials/started.html#registering-the-i18n-plugin
|
||||
createI18n({
|
||||
|
Reference in New Issue
Block a user