mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-07 22:49:26 +08:00
fix(mobile): resovle redirect issue (#5145)
* fix(mobile): resovle redirect issue * test: add e2e tests
This commit is contained in:
parent
3809108afa
commit
fae2205ce1
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* This file is part of the NocoBase (R) project.
|
||||
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
||||
* Authors: NocoBase Team.
|
||||
*
|
||||
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { devices, expect, test } from '@nocobase/test/e2e';
|
||||
|
||||
test.use({
|
||||
...devices['Galaxy S9+'],
|
||||
});
|
||||
|
||||
test.describe('redirect to other page from mobile', () => {
|
||||
test('redirect to signin page', async ({ page }) => {
|
||||
const baseURL = process.env.APP_BASE_URL || `http://localhost:${process.env.APP_PORT || 20000}`;
|
||||
|
||||
await page.goto('/m/signin');
|
||||
await page.waitForURL(`${baseURL}/signin`);
|
||||
expect(page.url()).toBe(`${baseURL}/signin`);
|
||||
|
||||
// do not redirect to mobile page
|
||||
await page.waitForTimeout(5000);
|
||||
expect(page.url()).toBe(`${baseURL}/signin`);
|
||||
});
|
||||
|
||||
test('redirect to admin page', async ({ page }) => {
|
||||
const baseURL = process.env.APP_BASE_URL || `http://localhost:${process.env.APP_PORT || 20000}`;
|
||||
|
||||
await page.goto('/m/admin/settings/@nocobase/plugin-api-keys');
|
||||
await page.waitForURL(`${baseURL}/admin/settings/@nocobase/plugin-api-keys`);
|
||||
expect(page.url()).toBe(`${baseURL}/admin/settings/@nocobase/plugin-api-keys`);
|
||||
});
|
||||
});
|
@ -179,22 +179,26 @@ export class PluginMobileClient extends Plugin {
|
||||
Component: 'MobileHomePage',
|
||||
});
|
||||
|
||||
// 跳转到主应用的登录页
|
||||
// redirect to main app signin page
|
||||
// e.g. /m/signin => /signin
|
||||
this.mobileRouter.add('signin', {
|
||||
path: '/signin',
|
||||
Component: () => {
|
||||
window.location.href = window.location.href
|
||||
.replace(this.mobilePath, '')
|
||||
.replace(this.mobilePath + '/', '/')
|
||||
.replace('redirect=', `redirect=${this.mobilePath}`);
|
||||
return null;
|
||||
},
|
||||
});
|
||||
|
||||
// 跳转到主应用的页面
|
||||
// redirect to main app admin page
|
||||
// e.g. /m/admin/xxx => /admin/xxx
|
||||
this.mobileRouter.add('admin', {
|
||||
path: `/admin/*`,
|
||||
Component: () => {
|
||||
window.location.replace(window.location.href.replace(this.mobilePath, ''));
|
||||
if (window.location.pathname.startsWith(this.mobilePath + '/')) {
|
||||
window.location.replace(window.location.href.replace(this.mobilePath + '/', '/'));
|
||||
}
|
||||
return null;
|
||||
},
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user