Unverified Commit 292bd1fe authored by 言肆's avatar 言肆 Committed by GitHub

Merge pull request #143 from YogaZong/next

feat: PageLoading Component
parents f834b2b3 a53c40ae
......@@ -4,6 +4,7 @@
v-model:selectedKeys="baseState.selectedKeys"
v-model:openKeys="baseState.openKeys"
v-bind="state"
:loading="loading"
:collapsed-button-render="false"
:breadcrumb="{ routes: breadcrumb }"
>
......@@ -42,6 +43,7 @@
un-checked-children="OFF"
/>
</span>
<a-button @click="handlePageLoadingClick">Page Loading</a-button>
<a-select v-model:value="state.navTheme" style="width: 100px">
<a-select-option value="light">Light</a-select-option>
<a-select-option value="dark">Dark</a-select-option>
......@@ -57,7 +59,7 @@
</template>
<script lang="ts">
import { computed, defineComponent, reactive, watchEffect } from 'vue';
import { computed, defineComponent, reactive, ref, watchEffect } from 'vue';
import { useRouter } from 'vue-router';
import { Button, Switch, Select, Space } from 'ant-design-vue';
import { getMenuData, clearMenuItem, FooterToolbar } from '@ant-design-vue/pro-layout';
......@@ -76,6 +78,8 @@ export default defineComponent({
[Space.name]: Space,
},
setup() {
const loading = ref(false);
const router = useRouter();
const { menuData } = getMenuData(clearMenuItem(router.getRoutes()));
......@@ -116,12 +120,22 @@ export default defineComponent({
.map(r => r.path);
}
});
function handlePageLoadingClick() {
loading.value = true;
setTimeout(() => {
loading.value = false;
}, 2000);
}
return {
i18n,
baseState,
state,
loading,
breadcrumb,
handlePageLoadingClick,
handleCollapsed,
};
},
......
......@@ -19,6 +19,7 @@ import { getPropsSlot, PropTypes } from './utils';
import type { CustomRender, FormatMessage, WithFalse } from './typings';
import './BasicLayout.less';
import PageLoading from '@/PageLoading';
export const basicLayoutProps = {
...defaultSettingProps,
......@@ -249,7 +250,7 @@ const ProLayout = defineComponent({
isChildrenLayout={props.isChildrenLayout}
style={props.disableContentMargin ? undefined : props.contentStyle}
>
{slots.default?.()}
{props.loading ? <PageLoading /> : slots.default?.()}
</WrapContent>
{footerRender && footerRender(props)}
</Layout>
......
import { defineComponent, h } from 'vue';
import { Spin, SpinProps } from 'ant-design-vue';
import { getSpinProps } from 'ant-design-vue/es/spin/Spin';
export type PageLoadingProps = SpinProps;
const PageLoading = defineComponent({
name: 'PageLoading',
props: {
...getSpinProps(),
},
render() {
return h(
'div',
{ style: { paddingTop: '100px', textAlign: 'center' } },
h(Spin, { ...this.$props }),
);
},
});
export default PageLoading;
......@@ -27,3 +27,5 @@ export type { WaterMarkProps } from './WaterMark';
export { default } from './BasicLayout';
// export { default as ProLayout } from './BasicLayout';
export type { BasicLayoutProps } from './BasicLayout';
export { default as PageLoading } from './Pageloading';
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment