Skip to content

Commit

Permalink
feat(projects): add app loading
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Jan 17, 2024
1 parent 2372dc9 commit c65451b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
28 changes: 17 additions & 11 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { NConfigProvider, darkTheme } from 'naive-ui';
import { useAppStore } from './store/modules/app';
import { useThemeStore } from './store/modules/theme';
import { naiveDateLocales, naiveLocales } from './locales/naive';
import AppLoading from './components/common/app-loading.vue';
defineOptions({
name: 'App'
Expand All @@ -24,17 +25,22 @@ const naiveDateLocale = computed(() => {
</script>

<template>
<NConfigProvider
:theme="naiveDarkTheme"
:theme-overrides="themeStore.naiveTheme"
:locale="naiveLocale"
:date-locale="naiveDateLocale"
class="h-full"
>
<AppProvider>
<RouterView class="bg-layout" />
</AppProvider>
</NConfigProvider>
<Suspense>
<NConfigProvider
:theme="naiveDarkTheme"
:theme-overrides="themeStore.naiveTheme"
:locale="naiveLocale"
:date-locale="naiveDateLocale"
class="h-full"
>
<AppProvider>
<RouterView class="bg-layout" />
</AppProvider>
</NConfigProvider>
<template #fallback>
<AppLoading />
</template>
</Suspense>
</template>

<style scoped></style>
7 changes: 7 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ import { setupDayjs, setupIconifyOffline, setupNProgress } from './plugins';
import { setupStore } from './store';
import { setupRouter } from './router';
import { setupI18n } from './locales';
import AppLoading from './components/common/app-loading.vue';
import App from './App.vue';

async function setupApp() {
const appLoading = createApp(AppLoading);

appLoading.mount('#appLoading');

setupNProgress();

setupIconifyOffline();
Expand All @@ -22,6 +27,8 @@ async function setupApp() {
setupI18n(app);

app.mount('#app');

appLoading.unmount();
}

setupApp();
1 change: 0 additions & 1 deletion src/typings/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ declare module 'vue' {
NFormItem: typeof import('naive-ui')['NFormItem']
NInput: typeof import('naive-ui')['NInput']
NInputNumber: typeof import('naive-ui')['NInputNumber']
NInputPassword: typeof import('naive-ui')['NInputPassword']
NLoadingBarProvider: typeof import('naive-ui')['NLoadingBarProvider']
NMenu: typeof import('naive-ui')['NMenu']
NMessageProvider: typeof import('naive-ui')['NMessageProvider']
Expand Down

1 comment on commit c65451b

@vercel
Copy link

@vercel vercel bot commented on c65451b Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

soybean-admin – ./

soybean-admin-soybeanjs.vercel.app
soybean-admin-eta.vercel.app
soybean-admin-git-main-soybeanjs.vercel.app

Please sign in to comment.