-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 修复 getClientRootComponent 方法. 增加 ssr basename 案例
- Loading branch information
Showing
19 changed files
with
247 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default { | ||
exportStatic: {}, | ||
ssr: {}, | ||
base: '/base/', | ||
publicPath: '/base/', // 布署时需要布署在 base 文件夹下. | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "@example/ssg-basename", | ||
"private": true, | ||
"description": "该案例用于测试 ssg 预渲染. 当 umi 配置表中设置了 base 后, ssg 输出的预渲染页面中的 a 标签需要有正确的 base 前缀", | ||
"scripts": { | ||
"build": "umi build", | ||
"dev": "umi dev", | ||
"setup": "umi setup", | ||
"start": "npm run dev" | ||
}, | ||
"dependencies": { | ||
"umi": "workspace:*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
|
||
import { Outlet } from 'umi'; | ||
|
||
const Layout = () => { | ||
return ( | ||
<div> | ||
<div style={{ marginBottom: '10px' }}>HEADER</div> | ||
<Outlet /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Layout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React, { useState } from 'react'; | ||
import { Link } from 'umi'; | ||
|
||
const About = () => { | ||
const [num, setNum] = useState(0); | ||
|
||
return ( | ||
<div> | ||
<div> | ||
<strong>ABOUT</strong> page | ||
<button | ||
style={{ marginLeft: '5px' }} | ||
onClick={() => setNum((val) => val + 1)} | ||
> | ||
couts: {num} | ||
</button> | ||
</div> | ||
<br /> | ||
<Link to="/">to home</Link> | ||
</div> | ||
); | ||
}; | ||
|
||
export default About; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React, { useState } from 'react'; | ||
import { Link } from 'umi'; | ||
|
||
const Home = () => { | ||
const [num, setNum] = useState(0); | ||
return ( | ||
<div> | ||
<div> | ||
<strong>HOME</strong> page | ||
<button | ||
style={{ marginLeft: '5px' }} | ||
onClick={() => setNum((val) => val + 1)} | ||
> | ||
couts: {num} | ||
</button> | ||
</div> | ||
|
||
<br /> | ||
<Link to="/about">to about</Link> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Home; |
3 changes: 1 addition & 2 deletions
3
...ples/ssr-export-static-basename/.umirc.ts → examples/ssr-basename/.umirc.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
export default { | ||
ssr: {}, | ||
exportStatic: {}, | ||
hash: true, | ||
base: '/a/', | ||
base: '/base/', | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { writeFileSync } from 'fs'; | ||
import { IApi } from 'umi'; | ||
|
||
export default (api: IApi) => { | ||
api.describe({ | ||
key: 'mylogger', | ||
config: { | ||
schema(joi) { | ||
return joi.string(); | ||
}, | ||
}, | ||
enableBy: api.EnableBy.register, | ||
}); | ||
|
||
api.registerMethod({ | ||
name: 'mylogger', | ||
fn: (pathname, obj) => { | ||
let cache = []; | ||
const str = JSON.stringify(obj, function (key, value) { | ||
if (typeof value === 'object' && value !== null) { | ||
if (cache.indexOf(value) !== -1) { | ||
// 移除 | ||
return; | ||
} | ||
// 收集所有的值 | ||
cache.push(value); | ||
} | ||
return value; | ||
}); | ||
cache = null; | ||
|
||
writeFileSync(pathname, str, () => { | ||
console.log('write log finish'); | ||
}); | ||
}, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { IApi } from 'umi'; | ||
|
||
export default (api: IApi) => { | ||
api.describe({ | ||
key: 'routePicker', | ||
config: { | ||
schema({ zod }) { | ||
return zod.array(zod.string()); | ||
}, | ||
}, | ||
enableBy: () => { | ||
return api.name === 'dev'; | ||
}, | ||
}); | ||
|
||
console.log('插件 picker 注册'); | ||
|
||
api.onCheck(async () => { | ||
// console.log('插件', api.appData.routes); | ||
console.log('插件config', api.config); | ||
api.config.routes = [ | ||
{ | ||
path: '/', | ||
component: 'index', | ||
}, | ||
]; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
|
||
import { Outlet } from 'umi'; | ||
|
||
const Layout = () => { | ||
return ( | ||
<div> | ||
<div style={{ marginBottom: '10px' }}>HEADER</div> | ||
<Outlet /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Layout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function AboutForm() { | ||
return <div>About Form</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React, { useState } from 'react'; | ||
import { Link } from 'umi'; | ||
|
||
const About = () => { | ||
const [num, setNum] = useState(0); | ||
|
||
return ( | ||
<div> | ||
<div> | ||
<strong>ABOUT</strong> page | ||
<button | ||
style={{ marginLeft: '5px' }} | ||
onClick={() => setNum((val) => val + 1)} | ||
> | ||
couts: {num} | ||
</button> | ||
</div> | ||
<br /> | ||
<Link to="/">to home</Link> | ||
</div> | ||
); | ||
}; | ||
|
||
export default About; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React, { useState } from 'react'; | ||
import { Link } from 'umi'; | ||
|
||
const Home = () => { | ||
const [num, setNum] = useState(0); | ||
return ( | ||
<div> | ||
<div> | ||
<strong>HOME</strong> page | ||
<button | ||
style={{ marginLeft: '5px' }} | ||
onClick={() => setNum((val) => val + 1)} | ||
> | ||
couts: {num} | ||
</button> | ||
</div> | ||
|
||
<br /> | ||
<Link to="/about">to about</Link> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Home; |
15 changes: 0 additions & 15 deletions
15
examples/ssr-export-static-basename/src/pages/about/index.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.