Skip to content

Commit 6c8420a

Browse files
committed
fix: 边界处理
1 parent 65d6e42 commit 6c8420a

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

.circleci/config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
command: mkdir ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
3737
- run: npm run docs:build
3838
- run: npm run build
39+
- run: npm run start
3940
- run: ls -al
4041
- run: # git push
4142
name: push-github

src/server/app/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import proxy from 'koa2-proxy-middleware'
44
import ssrMiddleware from '../middlewares/ssr'
55
import proConfig from '../../../config/pro-config'
66
import path from 'path'
7+
import getIp from '../utils/get-ip'
78

89
const port = proConfig.nodeServerPort || process.env.PORT
910

11+
const IP = getIp()
1012
const app = new Koa()
1113

1214
console.log('process.env.NODE_ENV==>', process.env.NODE_ENV)
@@ -35,5 +37,5 @@ app.use(ssrMiddleware)
3537

3638
// 启动服务
3739
app.listen(port, () => {
38-
console.log('server is start .', `http://localhost:${port}`)
40+
console.log('server is start .', `http://${IP}:${port}`)
3941
})

src/server/middlewares/ssr.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,18 @@ export default async (ctx: Koa.Context, next: Koa.Next): Promise<null> => {
2222
styles.forEach((style: any) => cssObj.add(style._getContent()))
2323
const { html, fetchResult } = await genHtml(path, insertCss, store)
2424
const { page } = fetchResult || {}
25-
let tdk = tdkConfig[path as keyof typeof tdkConfig]
25+
const curTDK = tdkConfig[path as keyof typeof tdkConfig]
26+
let tdk = {
27+
title: '',
28+
keywords: '',
29+
description: ''
30+
}
31+
if (curTDK) {
32+
tdk = curTDK
33+
}
34+
2635
// 添加TDK
27-
if (Object.keys(page).length) {
36+
if (Object.keys(page || {}).length) {
2837
tdk = page
2938
}
3039
const styles: string[] = []

0 commit comments

Comments
 (0)