refactor: refactored multi-language modules to support lazy loading and remote loading

This commit is contained in:
Vben
2021-02-27 23:08:12 +08:00
parent f57eb944ed
commit f6cef1088d
47 changed files with 353 additions and 284 deletions

View File

@@ -1,13 +1,13 @@
import type { Router } from 'vue-router';
import { useProjectSetting } from '/@/hooks/setting';
import { AxiosCanceler } from '/@/utils/http/axios/axiosCancel';
import projectSetting from '/@/settings/projectSetting';
/**
* The interface used to close the current page to complete the request when the route is switched
* @param router
*/
export function createHttpGuard(router: Router) {
const { removeAllHttpPending } = useProjectSetting();
const { removeAllHttpPending } = projectSetting;
let axiosCanceler: Nullable<AxiosCanceler>;
if (removeAllHttpPending) {
axiosCanceler = new AxiosCanceler();

View File

@@ -1,7 +1,6 @@
import type { Router } from 'vue-router';
import { useProjectSetting } from '/@/hooks/setting';
import { Modal, notification } from 'ant-design-vue';
import projectSetting from '/@/settings/projectSetting';
import { warn } from '/@/utils/log';
/**
@@ -9,7 +8,7 @@ import { warn } from '/@/utils/log';
* @param router
*/
export function createMessageGuard(router: Router) {
const { closeMessageOnSwitch } = useProjectSetting();
const { closeMessageOnSwitch } = projectSetting;
router.beforeEach(async () => {
try {

View File

@@ -4,9 +4,11 @@ import type { App } from 'vue';
import { createRouter, createWebHashHistory } from 'vue-router';
import { createGuard } from './guard';
import { basicRoutes } from './routes';
import { basicRoutes, LoginRoute } from './routes';
import { REDIRECT_NAME } from './constant';
const WHITE_NAME_LIST = [LoginRoute.name, REDIRECT_NAME];
// app router
const router = createRouter({
history: createWebHashHistory(),
@@ -17,10 +19,9 @@ const router = createRouter({
// reset router
export function resetRouter() {
const resetWhiteNameList = ['Login', REDIRECT_NAME];
router.getRoutes().forEach((route) => {
const { name } = route;
if (name && !resetWhiteNameList.includes(name as string)) {
if (name && !WHITE_NAME_LIST.includes(name as string)) {
router.hasRoute(name) && router.removeRoute(name);
}
});

View File

@@ -1,3 +1,8 @@
/**
The routing of this file will not show the layout.
It is an independent new page.
the contents of the file still need to log in to access
*/
import type { AppRouteModule } from '/@/router/types';
// test