Skip to content

Commit

Permalink
feat: move plugin router
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohuoni committed Aug 24, 2021
1 parent e37e937 commit e889ec1
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 69 deletions.
1 change: 0 additions & 1 deletion packages/router/README.md

This file was deleted.

28 changes: 0 additions & 28 deletions packages/router/package.json

This file was deleted.

24 changes: 0 additions & 24 deletions packages/router/src/index.ts

This file was deleted.

13 changes: 0 additions & 13 deletions packages/router/src/utils/getContent.tsx

This file was deleted.

1 change: 0 additions & 1 deletion packages/umi-presets-alita/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"@alitajs/plugin-dva": "2.8.15-alpha.2",
"@alitajs/plugin-layout": "2.8.15-alpha.2",
"@alitajs/retain-log": "2.8.15-alpha.2",
"@alitajs/router": "2.8.15-alpha.2",
"@alitajs/routes": "2.8.15-alpha.2",
"@umijs/plugin-antd": "0.9.1",
"@umijs/plugin-esbuild": "1.3.1",
Expand Down
6 changes: 4 additions & 2 deletions packages/umi-presets-alita/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export default function (api: IApi) {
require.resolve('@umijs/plugin-antd'),
require.resolve('./plugins/features/appType'),
require.resolve('@alitajs/routes'),
require.resolve('@alitajs/router'),
// 换成 内置 plugin 了
// require.resolve('@alitajs/router'),
require.resolve('./plugins/router/router'),
require.resolve('@alitajs/keep-alive'),
require.resolve('@alitajs/main-path'),
require.resolve('@alitajs/retain-log'),
Expand All @@ -33,7 +35,7 @@ export default function (api: IApi) {
plugins.push(require.resolve('@alitajs/cordova'));
}
// debug and console
if(api.userConfig.aconsole){
if (api.userConfig.aconsole) {
plugins.push(require.resolve('@alitajs/aconsole'));
}
return {
Expand Down
32 changes: 32 additions & 0 deletions packages/umi-presets-alita/src/plugins/router/historyAdapater.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// @ts-ignore
import { history } from '@@/core/history';

export function push(...args) {
history.push(...args);
}

export function replace(...args) {
history.replace(...args);
}

export function go(...args) {
history.go(...args);
}

export function goBack(...args) {
history.goBack(...args);
}

export function goForward(...args) {
history.goForward(...args);
}

const router = {
push,
replace,
go,
goBack,
goForward,
};

export { router };
14 changes: 14 additions & 0 deletions packages/umi-presets-alita/src/plugins/router/router.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { IApi } from 'umi';

export default (api: IApi) => {
api.addUmiExports(() => {
return [
{
source: require.resolve(
'../../../src/plugins/router/historyAdapater.ts',
),
exportAll: true
},
];
});
};

0 comments on commit e889ec1

Please sign in to comment.