App.tsx 749 B

1234567891011121314151617181920212223242526272829
  1. import { queenApi } from "queenjs";
  2. import { Provider } from "queenjs/adapter/vue";
  3. import { createApp, defineComponent } from "vue";
  4. import { Router } from "vue-router";
  5. import "./styles";
  6. import zh_cn from "ant-design-vue/es/locale/zh_CN";
  7. let setModuleHooks: any[] = [];
  8. const App = defineComponent(() => {
  9. setModuleHooks.forEach((hook) => hook());
  10. setModuleHooks = [];
  11. return () => (
  12. <Provider locale={zh_cn}>
  13. <router-view></router-view>
  14. </Provider>
  15. );
  16. });
  17. export function startApp(
  18. router: Router,
  19. hooks: any[] = [],
  20. callback?: (app: ReturnType<typeof createApp>) => void
  21. ) {
  22. setModuleHooks = hooks;
  23. queenApi.router = router;
  24. const app = createApp(App);
  25. callback?.(app);
  26. app.use(router).mount("#app");
  27. }