package.json
"build": "cross-env PUBLIC_PATH=/cms/ umi build",
"start": "cross-env PORT=8002 PUBLIC_PATH=/cms/ umi dev",
config.js
const {
PUBLIC_PATH } = process.env;
export default defineConfig({
hash: true,
history: {
type: 'hash' },
base: PUBLIC_PATH,
publicPath: PUBLIC_PATH,
manifest: {
basePath: PUBLIC_PATH,
},
})
permission.js
export const isAuthorizedPage = () => {
const url = ['user'];
const {
hash } = window.location;
const target = url.filter((d) => d === hash.split('/')[2]);
return target.length === 0;
};
global.js
effects: {
*login({
payload }, {
call, put }) {
const response = yield call(api.login, payload);
if (response.success === true) {
const {
data } = response;
removeCookie();
setCookie('user', JSON.stringify(data));
yield put({
type: 'updateState',
payload: {
currentUser: data,
},
});
yield put({
type: 'addAuthority',
payload: {
roles: data.roles,
},
});
const params = getPageQuery();
const {
redirect } = params;
window.location.href = redirect || '/';
}
},