Skip to content

Commit

Permalink
feat: add tabBar item to reload system
Browse files Browse the repository at this point in the history
  • Loading branch information
flingyp committed Sep 24, 2023
1 parent 5954aec commit ab580c9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/components/common/SingleApp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ const { isLoading, loadingText } = inject('loading') as { isLoading: boolean, lo
<NNotificationProvider placement="bottom-right">
<NDialogProvider>
<NMessageProvider>
<slot v-if="!isLoading" />

<BaseSpin
v-else
class="w-screen h-screen overflow-hidden"
size="medium"
:is-loading="isLoading"
:loading-text="loadingText"
>
<slot />
</BaseSpin>
/>
</NMessageProvider>
</NDialogProvider>
</NNotificationProvider>
Expand Down
12 changes: 11 additions & 1 deletion src/layout/components/layout/BaseTabBarIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { IS_RELOAD_CONTENT } from '~/vadmire.config'
const isReloadContent = inject<Ref<boolean>>(IS_RELOAD_CONTENT)
const { setLoading: setGlobalLoading } = inject('loading') as { setLoading: (value: boolean) => void }
const route = useRoute()
const router = useRouter()
Expand All @@ -17,6 +18,10 @@ const tabBarSettingOption = computed(() => [
label: '重新加载页面',
key: 'RELOAD',
},
{
label: '重新加载系统',
key: 'RELOAD_SYSTEM',
},
{
label: '关闭当前标签',
key: 'CLOSE_CURRENT_TABMENU',
Expand All @@ -29,14 +34,19 @@ const tabBarSettingOption = computed(() => [
},
])
type TabBarSettingKey = 'RELOAD' | 'CLOSE_CURRENT_TABMENU' | 'CLOSE_OTHER_TABMENU'
type TabBarSettingKey = 'RELOAD' | 'RELOAD_SYSTEM'| 'CLOSE_CURRENT_TABMENU' | 'CLOSE_OTHER_TABMENU'
const clickTabBarSetting = (key: TabBarSettingKey) => {
const routerName = route.name as string
if (key === 'RELOAD') {
isReloadContent!.value = true
setTimeout(() => {
isReloadContent!.value = false
}, 1000)
} else if (key === 'RELOAD_SYSTEM') {
setGlobalLoading(true)
setTimeout(() => {
setGlobalLoading(false)
}, 1000)
} else if (key === 'CLOSE_CURRENT_TABMENU') {
// click to delete tab menu
// don't remove tab menu if tab menus have only one
Expand Down
3 changes: 2 additions & 1 deletion src/modules/provide.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { App } from 'vue'

const { isLoading, setLoading } = useLoading(false)

/**
* Config app provide global property
* @param app
*/
export const useAppProvide = (app: App) => {
const { isLoading, setLoading } = useLoading(false)
app.provide('loading', {
isLoading,
setLoading,
Expand Down

0 comments on commit ab580c9

Please sign in to comment.