mirror of
https://github.com/nocobase/nocobase
synced 2024-11-16 03:35:10 +00:00
6c39ac3538
* refactor: fields/views/pages... * update * update * update * updates * updates * add yarn.lock * updates * updates * updates * updates * updates * updates * updates * updates * updates * developerMode * 一大波更新 * bugfix * fix: hide the sorting settings * fix: reload menu when menu is updated * 页面重构 * modify text * 补充细节 * system settings * 继续更新补充 * fix: 多级菜单支持 * 无限嵌套 * fix: icon * 省市区参数调整 * 表单描述、文案调整 * 支持草稿 * 邮箱登录 * 细节补充 * 菜单页面权限初步 * 详情页打开方式 * 菜单父级、草稿问题 * 描述文字 * 详情分组显示 * 状态改为 radio * 菜单权限 * 跳过省市区 api * 修复权限数据范围 * onDraft * 页面跳转 * 修改文案 * 注册、登录 * fix: 权限过滤问题 * 微调上传组件样式 * 0.4.0-alpha.0 * father-build * remove father-build * 细节调整
74 lines
1.6 KiB
TypeScript
74 lines
1.6 KiB
TypeScript
import './css_browser_selector';
|
|
import { RequestConfig, request as umiRequest, history } from 'umi';
|
|
|
|
import { configResponsive } from 'ahooks';
|
|
|
|
configResponsive({
|
|
small: 0,
|
|
middle: 800,
|
|
large: 1200,
|
|
});
|
|
|
|
export const request: RequestConfig = {
|
|
prefix: process.env.API,
|
|
errorConfig: {
|
|
adaptor: (resData) => {
|
|
return {
|
|
...resData,
|
|
success: true,
|
|
showType: 0,
|
|
};
|
|
},
|
|
},
|
|
middlewares: [
|
|
async (ctx, next) => {
|
|
const { headers } = ctx.req.options as any;
|
|
const token = localStorage.getItem('NOCOBASE_TOKEN');
|
|
if (token) {
|
|
headers['Authorization'] = `Bearer ${token}`;
|
|
}
|
|
await next();
|
|
}
|
|
],
|
|
};
|
|
|
|
export async function getInitialState() {
|
|
const { pathname, search } = location;
|
|
console.log(location);
|
|
const { data: systemSettings = {} } = await umiRequest('/system_settings:get?fields[appends]=logo,logo.storage', {
|
|
method: 'get',
|
|
});
|
|
let redirect = '';
|
|
// if (href.includes('?')) {
|
|
redirect = `?redirect=${pathname}${search}`;
|
|
// }
|
|
|
|
if (pathname !== '/login' && pathname !== '/register') {
|
|
try {
|
|
const { data = {} } = await umiRequest('/users:check', {
|
|
method: 'post',
|
|
});
|
|
|
|
if (!data.id) {
|
|
history.push('/login' + redirect);
|
|
return {
|
|
systemSettings,
|
|
currentUser: {},
|
|
};
|
|
}
|
|
|
|
return {
|
|
systemSettings,
|
|
currentUser: data,
|
|
};
|
|
} catch (error) {
|
|
console.log(error)
|
|
history.push('/login' + redirect);
|
|
}
|
|
}
|
|
|
|
return {
|
|
systemSettings,
|
|
currentUser: {},
|
|
};
|
|
} |