Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/dcloudio/uni-app into v3
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Nov 20, 2019
2 parents 2b3ee86 + 780a0f7 commit f810c03
Show file tree
Hide file tree
Showing 21 changed files with 497 additions and 46 deletions.
23 changes: 23 additions & 0 deletions build/rollup.config.web-view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const path = require('path')
const babel = require('rollup-plugin-babel')
const alias = require('rollup-plugin-alias')
const uglify = require('rollup-plugin-uglify')
module.exports = {
input: 'src/core/runtime/web-view/index.js',
output: {
name: 'uni',
file: `dist/uni.webview.1.5.2.js`,
format: 'umd'
},
plugins: [
alias({
'uni-platforms': path.resolve(__dirname, '../src/platforms')
}),
babel(),
uglify.uglify({
output: {
ascii_only: true
}
})
]
}
1 change: 1 addition & 0 deletions dist/uni.webview.1.5.2.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"build:mp-weixin:mp": "npm run lint && cross-env UNI_PLATFORM=mp-weixin UNI_MP=true rollup -c build/rollup.config.mp.js",
"build:runtime": "npm run lint && npm run build:mp-weixin && npm run build:mp-qq && npm run build:mp-alipay && npm run build:mp-baidu && npm run build:mp-toutiao && npm run build:app-plus",
"build:stat": "npm run lint && rollup -c build/rollup.config.stat.js",
"build:web-view": "npm run lint && rollup -c build/rollup.config.web-view.js",
"test:cli": "cross-env NODE_ENV=test jest",
"test:unit": "cross-env NODE_ENV=test UNI_PLATFORM=h5 mocha-webpack --require tests/unit/setup.js --webpack-config build/webpack.config.test.js tests/unit/**/*.spec.js",
"release": "npm run lint:cli && lerna publish --force-publish=*",
Expand Down Expand Up @@ -66,9 +67,11 @@
"jsonfile": "^5.0.0",
"rollup": "^1.17.0",
"rollup-plugin-alias": "^1.4.0",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^10.0.1",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-uglify": "^6.0.3",
"shell-exec": "^1.0.2",
"strip-json-comments": "^2.0.1",
"vue": "^2.6.8",
Expand Down
19 changes: 13 additions & 6 deletions packages/uni-app-plus/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1134,10 +1134,10 @@ const hooks = [
function parseBaseApp (vm, {
mocks,
initRefs
}) {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
}) {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}

Vue.prototype.mpHost = "app-plus";

Expand Down Expand Up @@ -1178,8 +1178,8 @@ function parseBaseApp (vm, {
app: this
};

this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;

this.$vm._isMounted = true;
Expand All @@ -1191,6 +1191,13 @@ function parseBaseApp (vm, {

// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}

initHooks(appOptions, hooks);

Expand Down
19 changes: 13 additions & 6 deletions packages/uni-mp-alipay/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1526,10 +1526,10 @@ const hooks = [
function parseBaseApp (vm, {
mocks,
initRefs
}) {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
}) {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}

Vue.prototype.mpHost = "mp-alipay";

Expand Down Expand Up @@ -1570,8 +1570,8 @@ function parseBaseApp (vm, {
app: this
};

this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;

this.$vm._isMounted = true;
Expand All @@ -1583,6 +1583,13 @@ function parseBaseApp (vm, {

// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}

initHooks(appOptions, hooks);

Expand Down
19 changes: 13 additions & 6 deletions packages/uni-mp-baidu/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1271,10 +1271,10 @@ const hooks = [
function parseBaseApp (vm, {
mocks,
initRefs
}) {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
}) {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}

Vue.prototype.mpHost = "mp-baidu";

Expand Down Expand Up @@ -1315,8 +1315,8 @@ function parseBaseApp (vm, {
app: this
};

this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;

this.$vm._isMounted = true;
Expand All @@ -1328,6 +1328,13 @@ function parseBaseApp (vm, {

// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}

initHooks(appOptions, hooks);

Expand Down
19 changes: 13 additions & 6 deletions packages/uni-mp-qq/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1189,10 +1189,10 @@ const hooks = [
function parseBaseApp (vm, {
mocks,
initRefs
}) {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
}) {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}

Vue.prototype.mpHost = "mp-qq";

Expand Down Expand Up @@ -1238,8 +1238,8 @@ function parseBaseApp (vm, {
app: this
};

this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;

this.$vm._isMounted = true;
Expand All @@ -1251,6 +1251,13 @@ function parseBaseApp (vm, {

// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}

initHooks(appOptions, hooks);

Expand Down
19 changes: 13 additions & 6 deletions packages/uni-mp-toutiao/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1281,10 +1281,10 @@ const hooks = [
function parseBaseApp (vm, {
mocks,
initRefs
}) {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
}) {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}

Vue.prototype.mpHost = "mp-toutiao";

Expand Down Expand Up @@ -1325,8 +1325,8 @@ function parseBaseApp (vm, {
app: this
};

this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;

this.$vm._isMounted = true;
Expand All @@ -1338,6 +1338,13 @@ function parseBaseApp (vm, {

// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}

initHooks(appOptions, hooks);

Expand Down
19 changes: 13 additions & 6 deletions packages/uni-mp-weixin/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1129,10 +1129,10 @@ const hooks = [
function parseBaseApp (vm, {
mocks,
initRefs
}) {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}
}) {
if (vm.$options.store) {
Vue.prototype.$store = vm.$options.store;
}

Vue.prototype.mpHost = "mp-weixin";

Expand Down Expand Up @@ -1178,8 +1178,8 @@ function parseBaseApp (vm, {
app: this
};

this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.$scope = this;
// vm 上也挂载 globalData
this.$vm.globalData = this.globalData;

this.$vm._isMounted = true;
Expand All @@ -1191,6 +1191,13 @@ function parseBaseApp (vm, {

// 兼容旧版本 globalData
appOptions.globalData = vm.$options.globalData || {};
// 将 methods 中的方法挂在 getApp() 中
const methods = vm.$options.methods;
if (methods) {
Object.keys(methods).forEach(name => {
appOptions[name] = methods[name];
});
}

initHooks(appOptions, hooks);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,67 @@
const path = require('path')

const {
removeExt,
normalizePath,
getPagesJson
} = require('@dcloudio/uni-cli-shared')

const {
normalizeNodeModules
} = require('@dcloudio/webpack-uni-mp-loader/lib/shared')

const SCROLLER_COMPONENTS = [
'list',
'scroller',
'scroll-view',
'waterfall'
]

module.exports = function(content) {
this.cacheable && this.cacheable()
if (content.indexOf('recycle-list') === -1) {
return `<scroll-view :scroll-y="true" :enableBackToTop="true" bubble="true" style="flex-direction:column">${content}</scroll-view>`
const source = content.trim()

if (SCROLLER_COMPONENTS.find(name => source.indexOf('<' + name) === 0)) {
return content
}
return content
if (source.indexOf('<recycle-list') !== -1) {
return content
}

let resourcePath = normalizeNodeModules(
removeExt(normalizePath(path.relative(process.env.UNI_INPUT_DIR, this.resourcePath)))
)

if (
!process.UNI_NVUE_ENTRY[resourcePath] &&
this._module.issuer &&
this._module.issuer.issuer
) {
// <template src=""/>
resourcePath = normalizeNodeModules(
removeExt(normalizePath(path.relative(process.env.UNI_INPUT_DIR, this._module.issuer.issuer.resource)))
)
}

if (!process.UNI_NVUE_ENTRY[resourcePath]) {
return content
}
// 暂时实时读取配置信息,查找是否 disableScroll
const appJson = getPagesJson()
if (!appJson.nvue || !appJson.nvue.pages) {
return content
}
const pagePath = resourcePath + '.html'
const pageJson = appJson.nvue.pages.find(page => page.path === pagePath)
if (!pageJson) {
return content
}
Object.assign(appJson.globalStyle, appJson.globalStyle['app-plus'] || {})
Object.assign(pageJson.style, pageJson.style['app-plus'] || {})
const pageJsonStyle = Object.assign(appJson.globalStyle, pageJson.style)
if (pageJsonStyle.disableScroll === true) {
return content
}

return `<scroll-view :scroll-y="true" :enableBackToTop="true" bubble="true" style="flex-direction:column">${content}</scroll-view>`
}
Loading

0 comments on commit f810c03

Please sign in to comment.