听海 43496ef307
feat(plugin-layout): custom插槽支持 menus 参数 & 重构403、404逻辑 (#181)
* feat(plugin-layout): custom插槽添加menus参数

* refactor: 403/404默认显示layout,在pages目录下创建404.vue/403.vue可覆盖默认

* refactor(plugin-layout): 优化index.jsx

n

* fix: 403/404添加title
2023-04-06 10:07:29 +08:00

43 lines
1.1 KiB
JavaScript

import { access as accessApi, createWatermark } from '@fesjs/fes';
import { ref, watch } from 'vue';
import PageLoading from '@/components/pageLoading.vue';
import UserCenter from '@/components/userCenter.vue';
export const beforeRender = {
loading: <PageLoading />,
action() {
const { setRole } = accessApi;
return new Promise((resolve) => {
setTimeout(() => {
setRole('admin');
resolve({
userName: '李雷',
});
createWatermark({ content: '万纯(harrywan)' });
}, 1000);
});
},
};
export const layout = (layoutConfig, { initialState }) => ({
...layoutConfig,
renderCustom: (props) => {
console.log(props);
return <UserCenter />;
},
menus: () => {
const menusRef = ref(layoutConfig.menus);
watch(
() => initialState.userName,
() => {
menusRef.value = [
{
name: 'store',
},
];
},
);
return menusRef;
},
});