Skip to content

Commit

Permalink
Merge branch 'alpha'
Browse files Browse the repository at this point in the history
  • Loading branch information
zhetengbiji committed Jun 16, 2020
2 parents ad8f9e9 + 909d2a9 commit bb12fca
Show file tree
Hide file tree
Showing 134 changed files with 1,770 additions and 679 deletions.
22 changes: 16 additions & 6 deletions build/build.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ let pluginDir = process.argv[2]
if (!pluginDir) {
console.error('缺少参数')
process.exit(0)
}

if (pluginDir.indexOf('/') === -1) {
pluginDir = path.resolve(__dirname, '../packages/uni-' + pluginDir)
}
}

if (pluginDir.indexOf('/') === -1) {
pluginDir = path.resolve(__dirname, '../packages/uni-' + pluginDir)
}

const pkg = require(path.join(pluginDir, 'package.json'))
if (!pkg['uni-app']) {
Expand All @@ -47,9 +47,19 @@ service.webpackRawConfigFns.push(function () {
},
module: {
rules: [{
test: path.resolve(__dirname, '../src/core/view/components/index.js'),
use: [{
loader: path.resolve(__dirname, '../lib/extends-component-loader'),
options: {
extends: path.resolve(pluginDir, 'src/view/components'),
base: path.resolve(__dirname, '../src/core/view/components'),
platform: path.resolve(__dirname, '../src/platforms/h5/view/components')
}
}]
}, {
test: path.resolve(__dirname, '../src/platforms/h5/service/api/index.js'),
use: [{
loader: path.resolve(__dirname, '../lib/extends-loader'),
loader: path.resolve(__dirname, '../lib/extends-api-loader'),
options: {
extends: path.resolve(pluginDir, 'src/service/api'),
base: path.resolve(__dirname, '../src/platforms/h5/service/api')
Expand Down
4 changes: 3 additions & 1 deletion docs/component/web-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
**属性说明**

|属性名|类型|说明|平台差异说明|
|:-|:-|:-|:|
|:-|:-|:-|:-|
|src|String|webview 指向网页的链接| |
|allow|String|用于为 [iframe](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/iframe) 指定其[特征策略](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/策略特征)|H5|
|sandbox|String|该属性对呈现在 [iframe](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/iframe) 框架中的内容启用一些额外的限制条件。|H5|
|webview-styles|Object|webview 的样式|App|
|@message|EventHandler|网页向应用 `postMessage` 时,会在特定时机(后退、组件销毁、分享)触发并收到消息。|H5 暂不支持|
|@onPostMessage|EventHandler|网页向应用实时 `postMessage`|App-nvue|
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"message": "chore(release): publish %s"
}
},
"version": "2.0.0-alpha-27920200602001"
"version": "2.0.0-alpha-27920200613003"
}
24 changes: 14 additions & 10 deletions lib/apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const network = [
'sendSocketMessage',
'onSocketMessage',
'closeSocket',
'onSocketClose'
'onSocketClose',
'getUpdateManager'
]

const route = [
Expand Down Expand Up @@ -59,7 +60,7 @@ const media = [
'saveVideoToPhotosAlbum',
'createVideoContext',
'createCameraContext',
'createLivePlayerContext',
'createLivePlayerContext',
'createLivePusherContext'
]

Expand Down Expand Up @@ -115,7 +116,7 @@ const device = [
'stopBeaconDiscovery',
'checkIsSupportSoterAuthentication',
'checkIsSoterEnrolledInDevice',
'startSoterAuthentication',
'startSoterAuthentication',
'onUIStyleChange'
]

Expand Down Expand Up @@ -154,7 +155,7 @@ const ui = [
'startPullDownRefresh',
'stopPullDownRefresh',
'createSelectorQuery',
'createIntersectionObserver',
'createIntersectionObserver',
'getMenuButtonBoundingClientRect'
]

Expand Down Expand Up @@ -201,13 +202,16 @@ const third = [
'upx2px',
'restoreGlobal',
'getSubNVueById',
'getCurrentSubNVue',
'setPageMeta',
'onNativeEventReceive',
'sendNativeEvent'
'getCurrentSubNVue',
'setPageMeta',
'onNativeEventReceive',
'sendNativeEvent',
'preloadPage',
'unPreloadPage',
'loadSubPackage'
]

const ad = [
const ad = [
'createRewardedVideoAd'
]

Expand All @@ -224,7 +228,7 @@ const apis = [
...event,
...file,
...canvas,
...third,
...third,
...ad
]

Expand Down
File renamed without changes.
58 changes: 58 additions & 0 deletions lib/extends-component-loader/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const fs = require('fs')
const path = require('path')

const glob = require('glob')
const loaderUtils = require('loader-utils')

const isWin = /^win/.test(process.platform)
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)

module.exports = function loader(source) {
const options = loaderUtils.getOptions(this)
const baseDir = options['base']
const platformDir = options['platform']
const extendsDir = options['extends']

const components = []
const extendsFiles = []
// extends目录均导出
glob.sync('**/index.vue', {
cwd: extendsDir
}).forEach(file => {
extendsFiles.push(file)
components.push(normalizePath(path.join(extendsDir, file)))
})

//base目录中有,extends无的导出
glob.sync('**/index.vue', {
cwd: baseDir
}).forEach(file => {
if (!extendsFiles.includes(file)) {
components.push(normalizePath(path.join(baseDir, file)))
}
})
//platform目录中有,extends无的导出
glob.sync('**/index.vue', {
cwd: platformDir
}).forEach(file => {
if (!extendsFiles.includes(file)) {
components.push(normalizePath(path.join(platformDir, file)))
}
})

const componentsCode = components.map(component => {
return `require('${component}').default`
}).join(',')
return `
import Vue from 'vue'
import baseMixin from 'uni-mixins/base'
import animation from 'uni-mixins/animation'
[${componentsCode}].forEach(component=>{
component.mixins = component.mixins ? [].concat(baseMixin, component.mixins) : [baseMixin]
component.mixins.push(animation)
component.name = 'VUni' + component.name
component.isReserved = true
Vue.component(component.name, component)
})
`
}
2 changes: 1 addition & 1 deletion packages/uni-app-plus-nvue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dcloudio/uni-app-plus-nvue",
"version": "2.0.0-alpha-27920200602001",
"version": "2.0.0-alpha-27920200613003",
"description": "uni-app app-plus-nvue",
"main": "dist/index.js",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions packages/uni-app-plus/dist/automator.js

Large diffs are not rendered by default.

Loading

0 comments on commit bb12fca

Please sign in to comment.