提交 44750bb6 编写于 作者: Q qiang

Merge branch 'dev' of github.com:dcloudio/uni-app into dev

...@@ -40,7 +40,7 @@ service.run('build', { ...@@ -40,7 +40,7 @@ service.run('build', {
formats: process.env.UNI_WATCH === 'true' ? 'umd' : 'umd-min', formats: process.env.UNI_WATCH === 'true' ? 'umd' : 'umd-min',
entry, entry,
'inline-vue': !!process.env.UNI_VIEW, 'inline-vue': !!process.env.UNI_VIEW,
// clean: !process.env.UNI_VIEW, clean: false, //! process.env.UNI_VIEW,
mode: process.env.NODE_ENV mode: process.env.NODE_ENV
}).then(function () { }).then(function () {
if ( if (
......
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const SIGN_DIR_NAME = 'sign'
// TODO quickapp ide 有bug,不识别项目根目录 sign,暂时拷贝到 .quickapp 目录
const SIGN_OUT_DIR_NAME = '.quickapp/sign'
function getSignCopyOption () {
const signDir = path.resolve(process.env.UNI_INPUT_DIR, SIGN_DIR_NAME)
if (fs.existsSync(signDir)) {
return {
from: signDir,
to: SIGN_OUT_DIR_NAME
}
}
}
module.exports = { module.exports = {
options: { options: {
cssVars: { cssVars: {
...@@ -24,11 +38,19 @@ module.exports = { ...@@ -24,11 +38,19 @@ module.exports = {
} }
}, },
copyWebpackOptions (platformOptions, vueOptions) { copyWebpackOptions (platformOptions, vueOptions) {
const jsConfigPath = path.resolve(process.env.UNI_INPUT_DIR, 'jsconfig.json') const copyOptions = []
if (fs.existsSync(jsConfigPath)) { let jsConfigPath = path.resolve(process.env.UNI_INPUT_DIR, 'jsconfig.json')
return [jsConfigPath] if (!fs.existsSync(jsConfigPath)) {
} jsConfigPath = path.resolve(__dirname, 'assets/jsconfig.json')
return [path.resolve(__dirname, 'assets/jsconfig.json')] }
copyOptions.push(jsConfigPath)
const signCopyOption = getSignCopyOption()
if (signCopyOption) {
copyOptions.push(signCopyOption)
}
return copyOptions
}, },
configureWebpack () { configureWebpack () {
return { return {
......
...@@ -35,17 +35,7 @@ module.exports = (api, options) => { ...@@ -35,17 +35,7 @@ module.exports = (api, options) => {
} }
} }
const port = args['auto-port'] || process.env.UNI_AUTOMATOR_PORT require('./util').initAutomator(args)
if (port) {
const host = args['auto-host'] || process.env.UNI_AUTOMATOR_HOST || '0.0.0.0'
const prepareURLs = require('@vue/cli-service/lib/util/prepareURLs')
const urls = prepareURLs('ws', host, port, '')
if (urls.lanUrlForConfig) {
process.env.UNI_AUTOMATOR_WS_ENDPOINT = 'ws://' + urls.lanUrlForConfig + ':' + port
} else {
process.env.UNI_AUTOMATOR_WS_ENDPOINT = urls.localUrlForBrowser
}
}
args.entry = args.entry || args._[0] args.entry = args.entry || args._[0]
......
...@@ -21,10 +21,14 @@ module.exports = (api, options) => { ...@@ -21,10 +21,14 @@ module.exports = (api, options) => {
'--host': `specify host (default: ${defaults.host})`, '--host': `specify host (default: ${defaults.host})`,
'--port': `specify port (default: ${defaults.port})`, '--port': `specify port (default: ${defaults.port})`,
'--https': `use https (default: ${defaults.https})`, '--https': `use https (default: ${defaults.https})`,
'--public': 'specify the public network URL for the HMR client' '--public': 'specify the public network URL for the HMR client',
'--auto-host': 'specify automator host',
'--auto-port': 'specify automator port'
} }
}, async function serve (args) { }, async function serve (args) {
info('Starting development server...') info('Starting development server...')
require('./util').initAutomator(args)
// although this is primarily a dev server, it is possible that we // although this is primarily a dev server, it is possible that we
// are running it in a mode with a production env, e.g. in E2E tests. // are running it in a mode with a production env, e.g. in E2E tests.
......
module.exports = {
initAutomator (args) {
const port = args['auto-port'] || process.env.UNI_AUTOMATOR_PORT
if (port) {
const host = args['auto-host'] || process.env.UNI_AUTOMATOR_HOST || '0.0.0.0'
const prepareURLs = require('@vue/cli-service/lib/util/prepareURLs')
const urls = prepareURLs('ws', host, port, '')
if (urls.lanUrlForConfig) {
process.env.UNI_AUTOMATOR_WS_ENDPOINT = 'ws://' + urls.lanUrlForConfig + ':' + port
} else {
process.env.UNI_AUTOMATOR_WS_ENDPOINT = urls.localUrlForBrowser
}
}
}
}
...@@ -116,7 +116,8 @@ module.exports = { ...@@ -116,7 +116,8 @@ module.exports = {
loader: path.resolve(__dirname, '../../packages/wrap-loader'), loader: path.resolve(__dirname, '../../packages/wrap-loader'),
options: { options: {
before: [ before: [
beforeCode + statCode + getGlobalUsingComponentsCode() beforeCode + require('../util').getAutomatorCode() + statCode +
getGlobalUsingComponentsCode()
] ]
} }
}] }]
...@@ -179,4 +180,4 @@ module.exports = { ...@@ -179,4 +180,4 @@ module.exports = {
require('./cssnano-options')(webpackConfig) require('./cssnano-options')(webpackConfig)
} }
} }
} }
...@@ -81,9 +81,6 @@ module.exports = { ...@@ -81,9 +81,6 @@ module.exports = {
const beforeCode = 'import \'uni-pages\';' const beforeCode = 'import \'uni-pages\';'
const automator = `@dcloudio/uni-${process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM}/dist/automator`
const automatorCode = process.env.UNI_AUTOMATOR_WS_ENDPOINT ? `import '${automator}';` : ''
return { return {
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development', mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
entry () { entry () {
...@@ -112,7 +109,7 @@ module.exports = { ...@@ -112,7 +109,7 @@ module.exports = {
loader: path.resolve(__dirname, '../../packages/wrap-loader'), loader: path.resolve(__dirname, '../../packages/wrap-loader'),
options: { options: {
before: [ before: [
beforeCode + automatorCode + statCode beforeCode + require('../util').getAutomatorCode() + statCode
] ]
} }
}, { }, {
...@@ -200,4 +197,4 @@ module.exports = { ...@@ -200,4 +197,4 @@ module.exports = {
webpackConfig.plugins.delete('preload') webpackConfig.plugins.delete('preload')
webpackConfig.plugins.delete('prefetch') webpackConfig.plugins.delete('prefetch')
} }
} }
...@@ -12,5 +12,9 @@ module.exports = { ...@@ -12,5 +12,9 @@ module.exports = {
}) })
} }
return partialIdentifier return partialIdentifier
},
getAutomatorCode () {
const automator = `@dcloudio/uni-${process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM}/dist/automator`
return process.env.UNI_AUTOMATOR_WS_ENDPOINT ? `import '${automator}';` : ''
} }
} }
...@@ -60,8 +60,8 @@ function createValidator (type) { ...@@ -60,8 +60,8 @@ function createValidator (type) {
} }
} }
// tabBar不允许传递参数 // switchTab不允许传递参数,reLaunch到一个tabBar页面是可以的
if (routeOptions.meta.isTabBar) { if (type === 'switchTab' && routeOptions.meta.isTabBar) {
url = pagePath url = pagePath
} }
......
import { import {
hasOwn hasOwn
} from 'uni-shared' } from 'uni-shared'
export default function createPage (pageVm) { export default function createPage (pageVm, options) {
const $route = pageVm.$route const $route = pageVm.$route
pageVm.route = $route.meta.pagePath pageVm.route = $route.meta.pagePath
if (!pageVm.options) { // 可能开发者会声明 options 属性
pageVm.options = options
}
const id = hasOwn($route.params, '__id__') ? $route.params.__id__ : $route.meta.id const id = hasOwn($route.params, '__id__') ? $route.params.__id__ : $route.meta.id
pageVm.__page__ = { pageVm.__page__ = {
id, id,
path: $route.path, path: $route.path,
route: $route.meta.pagePath, route: $route.meta.pagePath,
options: options,
meta: Object.assign({}, $route.meta) meta: Object.assign({}, $route.meta)
} }
// 兼容 mpvue // 兼容 mpvue
......
...@@ -20,8 +20,9 @@ function getDecodedQuery (query = {}) { ...@@ -20,8 +20,9 @@ function getDecodedQuery (query = {}) {
export function createPageMixin () { export function createPageMixin () {
return { return {
created: function pageCreated () { created: function pageCreated () {
createPage(this) const options = getDecodedQuery(this.$route.query)
callPageHook(this, 'onLoad', getDecodedQuery(this.$route.query)) createPage(this, options)
callPageHook(this, 'onLoad', options)
callPageHook(this, 'onShow') callPageHook(this, 'onShow')
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册