New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
umi4 子目录部署 -缺少相关文档 [Bug] #10189
Comments
由于缺乏足够的信息,我们暂时关闭了该 Issue。请修改(不要回复) Issue 提供最小重现以重新开启。谢谢。 |
更新配置 {
base: '/sea/',
outputPath: 'dist/sea',
- publicPath: `${currentConfg.publicPathPrefix}/`,
- manifest: {
- basePath: currentConfg.publicPathPrefix,
- }
define: {
API_BASE_URL: 'http://localhost:2919/SalesPortal',
CLIENT_ROOT: 'http://localhost:1688/sea',
CLIENT_ID: 'sea_client',
SKIP_LOGIN_PAGE: false,
LOGIN_PAGE: '/sea/user/login',
DISABLE_LANGSELECT: true,
PUBLIC_PATH: '/sea/'
},
locale: { default: 'en-US' },
layout: { title: 'sea (Testing)' },
headScripts: [ { src: '/scripts/loading.js', async: true } ],
+ writeToDisk: true,
+ runtimePublicPath: {}
} 变成了 |
{
base: '/sea/',
- outputPath: 'dist/sea',
- publicPath: `${currentConfg.publicPathPrefix}/`,
- manifest: {
- basePath: currentConfg.publicPathPrefix,
- }
define: {
API_BASE_URL: 'http://localhost:2919/SalesPortal',
CLIENT_ROOT: 'http://localhost:1688/sea',
CLIENT_ID: 'sea_client',
SKIP_LOGIN_PAGE: false,
LOGIN_PAGE: '/sea/user/login',
DISABLE_LANGSELECT: true,
PUBLIC_PATH: '/sea/'
},
locale: { default: 'en-US' },
layout: { title: 'sea (Testing)' },
headScripts: [ { src: '/scripts/loading.js', async: true } ],
+ reactRouter5Compat: {},
- writeToDisk: true,
+ runtimePublicPath: {}
} |
根据 2、3、4 的设定,以 |
感谢答复:
关于这点确实不清楚,因为文档上没有任何说明,我可以提交PR 完善下文档,但是这个描述怎么样写才更准确? 但是
|
useLocation().pathname 输出 正常 比如 在 使用 app.tsx .getInitialState() 或者其它非组件内调用时无法使用 useLocation |
// .umirc.ts
export default {
base: '/some/',
define: {
BASE_URL: '/some'
}
} // use
history.location.pathname.slice(BASE_URL.length) // typings.d.ts
declare global {
const BASE_URL: string;
} 文档不用修改,写的没问题,使用 |
好的,非常感谢,按照你的说明,重新尝试下 |
可以了, {
base: '/sea/',
outputPath: 'dist/sea',
publicPath: '/sea/',
manifest: { basePath: '/sea' },
define: {
API_BASE_URL: 'http://localhost:2919/SalesPortal',
CLIENT_ROOT: 'http://localhost:8000/sea',
CLIENT_ID: 'sea_client',
SKIP_LOGIN_PAGE: false,
LOGIN_PAGE: '/user/login',
DISABLE_LANGSELECT: true,
PUBLIC_PATH: '/sea/'
},
headScripts: [ { src: '/sea/scripts/loading.js', async: true } ],
} 主要是 history.location.pathname 的问题,自己封装了个函数 替换整个项目里面的 pathname 就好了 不过好在是后者,不然还要再处理下 history.push |
关联 pull |
请问qiankun-plugin 2+ 给主应用设置base和publicpath导致子应用的bootstrap多了一个/ 这是为啥, |
旧版本不维护了,如有需求,建议升级 umi4 |
继续请教下。。 Umi4 打包 的antd https://baidu.com/租户1 怎么配置呀?
反向代理已经做了重写, 浏览器会跳到 : |
history.push 是 SPA 内部的路由跳转,没法跳其他的应用,如果跳其他的应用你可以考虑把根域名做成微前端基座,下发或者全局给一个全局的 history ,然后不同子应用用这个全局 history 就可以跳其他应用了。 否则只能设定 |
感谢答复,
export function createHistory(opts: any) {
let h;
if (opts.type === 'hash') {
h = createHashHistory();
} else if (opts.type === 'memory') {
h = createMemoryHistory(opts);
} else {
h = createBrowserHistory();
}
if (opts.basename) {
basename = opts.basename;
}
history = {
...h,
push(to, state) {
h.push(patchTo(to, h), state);
},
replace(to, state) {
h.replace(patchTo(to, h), state);
},
get location() {
//return h.location;
return { ...h.location, pathname: h.location.pathname.replace(new RegExp(`^${basename}`), '/') };
},
get action() {
return h.action;
}
}
return h;
} |
缺少 basename 相关文档和 ts声明
|
呃。。。 这个basename 并不是来自于 config.ts 的 history 属性的。。 |
如有新问题,请再开 issue 。 |
What happens?
"@umijs/max": "^4.0.33"
ant-design-pro : 6.0.0.beta.1 (最新版本默认分支)
在使用子目录的情况下
umi 3 : history.location.pathname 显示为 "/login"
umi 4 :history.location.pathname 显示为 "/sea/login"
Mini Showcase Repository(REQUIRED)
ant-design/ant-design-pro#10471
How To Reproduce
Steps to reproduce the behavior: 1. 2.
Expected behavior 1. 2.
Context
我的配置如下
config.local.ts
且开启 runtimePublicPath:{} 后打不开页面,以上问题在 exportStatic 未开启的情况下测试
The text was updated successfully, but these errors were encountered: