mirror of
https://github.com/ccmjga/zhilu-admin
synced 2026-03-26 05:13:45 +08:00
init
This commit is contained in:
33
frontend/src/main.ts
Normal file
33
frontend/src/main.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import "./assets/main.css";
|
||||
|
||||
import { createPinia } from "pinia";
|
||||
import { createApp } from "vue";
|
||||
|
||||
import App from "./App.vue";
|
||||
import useUserAuth from "./composables/auth/useUserAuth";
|
||||
import useAlertStore from "./composables/store/useAlertStore";
|
||||
import router from "./router";
|
||||
import makeErrorHandler from "./utils/errorHandler";
|
||||
|
||||
async function enableMocking() {
|
||||
if (import.meta.env.VITE_ENABLE_MOCK === "false") {
|
||||
return;
|
||||
}
|
||||
|
||||
const { worker } = await import("./api/mocks/setup");
|
||||
|
||||
// `worker.start()` returns a Promise that resolves
|
||||
// once the Service Worker is up and ready to intercept requests.
|
||||
return worker.start();
|
||||
}
|
||||
|
||||
enableMocking().then(() => {
|
||||
const app = createApp(App);
|
||||
app.use(createPinia());
|
||||
const { signOut } = useUserAuth();
|
||||
const { showAlert } = useAlertStore();
|
||||
app.use(router);
|
||||
const errorHandler = makeErrorHandler(router, signOut, showAlert);
|
||||
app.config.errorHandler = errorHandler;
|
||||
app.mount("#app");
|
||||
});
|
||||
Reference in New Issue
Block a user