Skip to content

Commit

Permalink
fix(mini-runner): 修复快应用编译后页面标题展示不正确的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Dec 31, 2019
1 parent 55c4bed commit de5dc7b
Show file tree
Hide file tree
Showing 4 changed files with 281 additions and 238 deletions.
1 change: 1 addition & 0 deletions packages/taro-mini-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"css-what": "3.2.0",
"file-loader": "^4.0.0",
"fs-extra": "^8.0.1",
"less": "^3.10.3",
"less-loader": "^5.0.0",
"loader-utils": "^1.2.3",
"lodash": "^4.17.11",
Expand Down
8 changes: 4 additions & 4 deletions packages/taro-mini-runner/src/utils/helper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as path from 'path'
import * as _ from 'lodash'

import { getInstalledNpmPkgPath, promoteRelativePath } from '.'
import { getInstalledNpmPkgPath, promoteRelativePath, removeHeadSlash } from '.'
import { taroJsQuickAppComponents, REG_STYLE, REG_SCRIPT } from './constants'

export function getTaroJsQuickAppComponentsPath (nodeModulesPath: string): string {
Expand Down Expand Up @@ -94,20 +94,20 @@ export function generateQuickAppManifest ({
pageConf.launchMode = launchMode
}
}
routerPages[path.dirname(element)] = pageConf
routerPages[removeHeadSlash(path.dirname(element))] = pageConf
})
delete quickappJSON.customPageConfig
const routerEntry = pages.shift()
const router = {
entry: path.dirname(routerEntry as string),
entry: removeHeadSlash(path.dirname(routerEntry as string)),
pages: routerPages
}
// 生成 display
const display = JSON.parse(JSON.stringify(appConfig.window || {}))
display.pages = {}
pageConfigs.forEach((item, page) => {
if (item) {
display.pages[path.dirname(page)] = item
display.pages[removeHeadSlash(path.dirname(page))] = item
}
})
quickappJSON.router = router
Expand Down
4 changes: 4 additions & 0 deletions packages/taro-mini-runner/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,7 @@ export function printLog (type: processTypeEnum, tag: string, filePath?: string)
console.log(typeShow.color(typeShow.name), padding, tag, padding, filePath)
}
}

export function removeHeadSlash (str: string) {
return str.replace(/^(\/|\\)/, '')
}
Loading

0 comments on commit de5dc7b

Please sign in to comment.