Skip to content

Commit

Permalink
refactor: quickapp
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Apr 30, 2020
1 parent 7834536 commit c9fb32a
Show file tree
Hide file tree
Showing 94 changed files with 266 additions and 202 deletions.
8 changes: 4 additions & 4 deletions build/build.qa.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ dsl.onInitApp(function({
});`
})
const pageCode = pageOutput[0].code
const vueCode = fs.readFileSync(path.resolve(__dirname, '../packages/uni-quickapp-vue/assets/' + filename))
const vueCode = fs.readFileSync(path.resolve(__dirname, '../packages/uni-quickapp-native/assets/' + filename))

fs.writeFileSync(
path.resolve(__dirname, '../packages/uni-quickapp-vue/dist/' + filename),
path.resolve(__dirname, '../packages/uni-quickapp-native/dist/' + filename),
vueCode + bridgeCode + appCode + pageCode, {
encoding: 'utf8'
}
)

if (process.env.NODE_ENV === 'production') { // 命令会执行dev,prod两次,仅prod时执行copy
const componentsSrc = path.resolve(__dirname, '../src/platforms/quickapp-vue/view/components/**/*')
const componentsDest = path.resolve(__dirname, '../packages/uni-quickapp-vue/components')
const componentsSrc = path.resolve(__dirname, '../src/platforms/quickapp-native/view/components/**/*')
const componentsDest = path.resolve(__dirname, '../packages/uni-quickapp-native/components')

del.sync([componentsDest])

Expand Down
4 changes: 2 additions & 2 deletions build/rollup.config.mp.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ const PLATFORMS = {
prefix: 'tt',
title: '头条小程序'
},
'quickapp-light': {
'quickapp-webview': {
prefix: 'qa',
title: '快应用(Light)版'
title: '快应用(Webview)版'
},
'app-plus': {
prefix: 'wx',
Expand Down
16 changes: 8 additions & 8 deletions build/rollup.config.qa.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const commonjs = require('@rollup/plugin-commonjs')
const terser = require('rollup-plugin-terser')
const requireContext = require('../lib/rollup-plugin-require-context')

process.env.UNI_PLATFORM = 'quickapp-vue'
process.env.UNI_PLATFORM = 'quickapp-native'

const external = []

Expand Down Expand Up @@ -36,7 +36,7 @@ alias({
replacement: resolve('src/core')
}, {
find: 'uni-platform',
replacement: resolve('src/platforms/quickapp-vue')
replacement: resolve('src/platforms/quickapp-native')
}, {
find: 'uni-platforms',
replacement: resolve('src/platforms')
Expand All @@ -48,10 +48,10 @@ alias({
replacement: resolve('src/core/helpers')
}, {
find: 'uni-invoke-api',
replacement: resolve('src/platforms/quickapp-vue/service/invoke-api')
replacement: resolve('src/platforms/quickapp-native/service/invoke-api')
}, {
find: 'uni-service-api',
replacement: resolve('src/platforms/quickapp-vue/service/api')
replacement: resolve('src/platforms/quickapp-native/service/api')
}, {
find: 'uni-api-protocol',
replacement: resolve('src/core/helpers/protocol')
Expand All @@ -62,7 +62,7 @@ requireContext(),
commonjs(),
replace({
__PLATFORM__: JSON.stringify(process.env.UNI_PLATFORM),
__PLATFORM_TITLE__: '快应用(Vue)版'
__PLATFORM_TITLE__: '快应用(Native)版'
})
]

Expand All @@ -74,11 +74,11 @@ module.exports = function (type) {
let input = ''

if (type === 'bridge') {
input = 'src/platforms/quickapp-vue/runtime/bridge.js'
input = 'src/platforms/quickapp-native/runtime/bridge.js'
} else if (type === 'app') {
input = 'src/platforms/quickapp-vue/runtime/app.js'
input = 'src/platforms/quickapp-native/runtime/app.js'
} else if (type === 'page') {
input = 'src/platforms/quickapp-vue/runtime/page.js'
input = 'src/platforms/quickapp-native/runtime/page.js'
}

return {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
"build:mp-baidu": "cross-env UNI_PLATFORM=mp-baidu rollup -c build/rollup.config.mp.js",
"build:mp-alipay": "cross-env UNI_PLATFORM=mp-alipay rollup -c build/rollup.config.mp.js",
"build:mp-toutiao": "cross-env UNI_PLATFORM=mp-toutiao rollup -c build/rollup.config.mp.js",
"build:quickapp-light": "cross-env UNI_PLATFORM=quickapp-light rollup -c build/rollup.config.mp.js",
"build:quickapp-webview": "cross-env UNI_PLATFORM=quickapp-webview rollup -c build/rollup.config.mp.js",
"build:mp-weixin:mp": "cross-env UNI_PLATFORM=mp-weixin UNI_MP=true rollup -c build/rollup.config.mp.js",
"build:mp-weixin:wxs": "rollup -c build/rollup.config.wxs.js",
"build:quickapp-vue": "cross-env NODE_ENV=development node build/build.qa.js && cross-env NODE_ENV=production node build/build.qa.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 && npm run build:quickapp-light && npm run build:quickapp-vue",
"build:quickapp-native": "cross-env NODE_ENV=development node build/build.qa.js && cross-env NODE_ENV=production node build/build.qa.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 && npm run build:quickapp-webview && npm run build:quickapp-native",
"build:stat": "npm run lint && rollup -c build/rollup.config.stat.js",
"build:web-view": "rollup -c build/rollup.config.web-view.js",
"test:cli": "cross-env NODE_ENV=test jest",
Expand Down
42 changes: 26 additions & 16 deletions packages/uni-app-plus/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,10 +698,10 @@ function initVueComponent (Vue, vueOptions) {
let VueComponent;
if (isFn(vueOptions)) {
VueComponent = vueOptions;
vueOptions = VueComponent.extendOptions;
} else {
VueComponent = Vue.extend(vueOptions);
}
vueOptions = VueComponent.options;
return [VueComponent, vueOptions]
}

Expand Down Expand Up @@ -901,6 +901,11 @@ function wrapper$2 (event) {
event.detail = {};
}

if (hasOwn(event, 'markerId')) {
event.detail = typeof event.detail === 'object' ? event.detail : {};
event.detail.markerId = event.markerId;
}

if (isPlainObject(event.detail)) {
event.target = Object.assign({}, event.target, event.detail);
}
Expand Down Expand Up @@ -1085,18 +1090,18 @@ function handleEvent (event) {
handlerCtx.$parent.$parent
) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = handlerCtx.$parent.$parent;
}
if (methodName === '$emit') {
handlerCtx.$emit.apply(handlerCtx,
processEventArgs(
this.$vm,
event,
eventArray[1],
eventArray[2],
isCustom,
methodName
));
return
}
if (methodName === '$emit') {
handlerCtx.$emit.apply(handlerCtx,
processEventArgs(
this.$vm,
event,
eventArray[1],
eventArray[2],
isCustom,
methodName
));
return
}
const handler = handlerCtx[methodName];
if (!isFn(handler)) {
Expand Down Expand Up @@ -1382,6 +1387,10 @@ function parseBaseComponent (vueComponentOptions, {
__e: handleEvent
}
};
// externalClasses
if (vueOptions.externalClasses) {
componentOptions.externalClasses = vueOptions.externalClasses;
}

if (Array.isArray(vueOptions.wxsCallMethods)) {
vueOptions.wxsCallMethods.forEach(callMethod => {
Expand Down Expand Up @@ -1449,13 +1458,14 @@ const hooks$3 = [
'onNavigationBarButtonTap',
'onNavigationBarSearchInputChanged',
'onNavigationBarSearchInputConfirmed',
'onNavigationBarSearchInputClicked'
'onNavigationBarSearchInputClicked',
'onNavigationBarSearchInputFocusChanged'
];

function parsePage$1 (vuePageOptions) {
function parsePage$1 (vuePageOptions) {
const pageOptions = parsePage(vuePageOptions);

initHooks(pageOptions.methods, hooks$3);
initHooks(pageOptions.methods, hooks$3);

return pageOptions
}
Expand Down
2 changes: 1 addition & 1 deletion packages/uni-app-plus/dist/view.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/uni-app-plus/dist/view.umd.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/uni-cli-shared/lib/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,10 @@ function initAutoImportScanComponents () {

const components = getAutoComponentsByDir(componentsPath)

if (process.env.UNI_PLATFORM === 'quickapp-vue') {
if (process.env.UNI_PLATFORM === 'quickapp-native') {
if (!uniQuickAppAutoImportScanComponents) {
uniQuickAppAutoImportScanComponents = getAutoComponentsByDir(
path.resolve(require.resolve('@dcloudio/uni-quickapp-vue'), '../../components'),
path.resolve(require.resolve('@dcloudio/uni-quickapp-native'), '../../components'),
true
)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/uni-h5/dist/index.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/uni-h5/dist/index.umd.min.js

Large diffs are not rendered by default.

70 changes: 38 additions & 32 deletions packages/uni-mp-alipay/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,11 @@ const protocols = { // 需要做转换的 API 列表
returnValue: {
apFilePath: 'tempFilePath'
}
},
getFileInfo: {
args: {
filePath: 'apFilePath'
}
},
getFileInfo: {
args: {
filePath: 'apFilePath'
}
},
chooseVideo: {
// 支付宝小程序文档中未找到(仅在getSetting处提及),但实际可用
Expand Down Expand Up @@ -664,22 +664,19 @@ const protocols = { // 需要做转换的 API 列表
scanCode: {
name: 'scan',
args (fromArgs) {
if (fromArgs.scanType === 'qrCode') {
fromArgs.type = 'qr';
return {
onlyFromCamera: 'hideAlbum'
}
} else if (fromArgs.scanType === 'barCode') {
fromArgs.type = 'bar';
return {
onlyFromCamera: 'hideAlbum'
}
} else {
return {
scanType: false,
onlyFromCamera: 'hideAlbum'
if (fromArgs.scanType) {
switch (fromArgs.scanType[0]) {
case 'qrCode':
fromArgs.type = 'qr';
break
case 'barCode':
fromArgs.type = 'bar';
break
}
}
return {
onlyFromCamera: 'hideAlbum'
}
},
returnValue: {
code: 'result'
Expand Down Expand Up @@ -1170,10 +1167,10 @@ function initVueComponent (Vue, vueOptions) {
let VueComponent;
if (isFn(vueOptions)) {
VueComponent = vueOptions;
vueOptions = VueComponent.extendOptions;
} else {
VueComponent = Vue.extend(vueOptions);
}
vueOptions = VueComponent.options;
return [VueComponent, vueOptions]
}

Expand Down Expand Up @@ -1363,6 +1360,11 @@ function wrapper$1 (event) {
event.detail = {};
}

if (hasOwn(event, 'markerId')) {
event.detail = typeof event.detail === 'object' ? event.detail : {};
event.detail.markerId = event.markerId;
}

if (isPlainObject(event.detail)) {
event.target = Object.assign({}, event.target, event.detail);
}
Expand Down Expand Up @@ -1547,18 +1549,18 @@ function handleEvent (event) {
handlerCtx.$parent.$parent
) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = handlerCtx.$parent.$parent;
}
if (methodName === '$emit') {
handlerCtx.$emit.apply(handlerCtx,
processEventArgs(
this.$vm,
event,
eventArray[1],
eventArray[2],
isCustom,
methodName
));
return
}
if (methodName === '$emit') {
handlerCtx.$emit.apply(handlerCtx,
processEventArgs(
this.$vm,
event,
eventArray[1],
eventArray[2],
isCustom,
methodName
));
return
}
const handler = handlerCtx[methodName];
if (!isFn(handler)) {
Expand Down Expand Up @@ -1807,6 +1809,10 @@ function initSpecialMethods (mpInstance) {
specialMethods.forEach(method => {
if (isFn(mpInstance.$vm[method])) {
mpInstance[method] = function (event) {
if (hasOwn(event, 'markerId')) {
event.detail = typeof event.detail === 'object' ? event.detail : {};
event.detail.markerId = event.markerId;
}
// TODO normalizeEvent
mpInstance.$vm[method](event);
};
Expand Down
37 changes: 23 additions & 14 deletions packages/uni-mp-baidu/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -812,10 +812,10 @@ function initVueComponent (Vue, vueOptions) {
let VueComponent;
if (isFn(vueOptions)) {
VueComponent = vueOptions;
vueOptions = VueComponent.extendOptions;
} else {
VueComponent = Vue.extend(vueOptions);
}
vueOptions = VueComponent.options;
return [VueComponent, vueOptions]
}

Expand Down Expand Up @@ -1031,6 +1031,11 @@ function wrapper$1 (event) {
event.detail = {};
}

if (hasOwn(event, 'markerId')) {
event.detail = typeof event.detail === 'object' ? event.detail : {};
event.detail.markerId = event.markerId;
}

{ // mp-baidu,checked=>value
if (
isPlainObject(event.detail) &&
Expand Down Expand Up @@ -1225,18 +1230,18 @@ function handleEvent (event) {
handlerCtx.$parent.$parent
) { // mp-weixin,mp-toutiao 抽象节点模拟 scoped slots
handlerCtx = handlerCtx.$parent.$parent;
}
if (methodName === '$emit') {
handlerCtx.$emit.apply(handlerCtx,
processEventArgs(
this.$vm,
event,
eventArray[1],
eventArray[2],
isCustom,
methodName
));
return
}
if (methodName === '$emit') {
handlerCtx.$emit.apply(handlerCtx,
processEventArgs(
this.$vm,
event,
eventArray[1],
eventArray[2],
isCustom,
methodName
));
return
}
const handler = handlerCtx[methodName];
if (!isFn(handler)) {
Expand Down Expand Up @@ -1415,7 +1420,7 @@ function handleLink (event) {
vueOptions.parent = parentVm;
}

const mocks = ['nodeId', 'componentName'];
const mocks = ['nodeId', 'componentName', '_componentId'];

function isPage () {
return !this.ownerId
Expand Down Expand Up @@ -1518,6 +1523,10 @@ function parseBaseComponent (vueComponentOptions, {
__e: handleEvent
}
};
// externalClasses
if (vueOptions.externalClasses) {
componentOptions.externalClasses = vueOptions.externalClasses;
}

if (Array.isArray(vueOptions.wxsCallMethods)) {
vueOptions.wxsCallMethods.forEach(callMethod => {
Expand Down
Loading

0 comments on commit c9fb32a

Please sign in to comment.