diff --git a/packages/uni-stat/dist/index.js b/packages/uni-stat/dist/index.js index 83c5b966e31949943889809810876a4e5e4867a1..42f5c81c337025e260add67b845a9c6b2e677ba7 100644 --- a/packages/uni-stat/dist/index.js +++ b/packages/uni-stat/dist/index.js @@ -629,39 +629,39 @@ class Util { this.imageRequest(optionsData); return } - - if (getPlatformName() === 'n' && this.statData.p === 'a') { - setTimeout(() => { - this._sendRequest(optionsData); - }, 200); - return - } + + if (getPlatformName() === 'n' && this.statData.p === 'a') { + setTimeout(() => { + this._sendRequest(optionsData); + }, 200); + return + } this._sendRequest(optionsData); - } - _sendRequest(optionsData){ - uni.request({ - url: STAT_URL, - method: 'POST', - // header: { - // 'content-type': 'application/json' // 默认值 - // }, - data: optionsData, - success: () => { - // if (process.env.NODE_ENV === 'development') { - // console.log('stat request success'); - // } - }, - fail: (e) => { - // if (process.env.NODE_ENV === 'development') { - // console.log('stat request fail', e); - // } - if (++this._retry < 3) { - setTimeout(() => { - this.request(data); - }, 1000); - } - } - }); + } + _sendRequest(optionsData) { + uni.request({ + url: STAT_URL, + method: 'POST', + // header: { + // 'content-type': 'application/json' // 默认值 + // }, + data: optionsData, + success: () => { + // if (process.env.NODE_ENV === 'development') { + // console.log('stat request success'); + // } + }, + fail: (e) => { + // if (process.env.NODE_ENV === 'development') { + // console.log('stat request fail', e); + // } + if (++this._retry < 3) { + setTimeout(() => { + this.request(data); + }, 1000); + } + } + }); } /** * h5 请求 @@ -775,15 +775,17 @@ class Stat extends Util { show(self) { this.self = self; if (!getPageTypes(self)) { + this._pageShow(self); + } else { this._applicationShow(self); } } ready(self) { - this.self = self; - if (getPageTypes(self)) { - this._pageShow(self); - } + // this.self = self; + // if (getPageTypes(self)) { + // this._pageShow(self); + // } } hide(self) { this.self = self; diff --git a/packages/uni-stat/src/stat.js b/packages/uni-stat/src/stat.js index bb501cb710c9d2f83e3485a52212de509e743994..58cb8d9a483b437c77acb50c101864a890b8008b 100644 --- a/packages/uni-stat/src/stat.js +++ b/packages/uni-stat/src/stat.js @@ -364,39 +364,39 @@ class Util { this.imageRequest(optionsData) return } - - if (getPlatformName() === 'n' && this.statData.p === 'a') { - setTimeout(() => { - this._sendRequest(optionsData); - }, 200) - return - } + + if (getPlatformName() === 'n' && this.statData.p === 'a') { + setTimeout(() => { + this._sendRequest(optionsData); + }, 200) + return + } this._sendRequest(optionsData) - } - _sendRequest(optionsData){ - uni.request({ - url: STAT_URL, - method: 'POST', - // header: { - // 'content-type': 'application/json' // 默认值 - // }, - data: optionsData, - success: () => { - // if (process.env.NODE_ENV === 'development') { - // console.log('stat request success'); - // } - }, - fail: (e) => { - // if (process.env.NODE_ENV === 'development') { - // console.log('stat request fail', e); - // } - if (++this._retry < 3) { - setTimeout(() => { - this.request(data); - }, 1000); - } - } - }); + } + _sendRequest(optionsData) { + uni.request({ + url: STAT_URL, + method: 'POST', + // header: { + // 'content-type': 'application/json' // 默认值 + // }, + data: optionsData, + success: () => { + // if (process.env.NODE_ENV === 'development') { + // console.log('stat request success'); + // } + }, + fail: (e) => { + // if (process.env.NODE_ENV === 'development') { + // console.log('stat request fail', e); + // } + if (++this._retry < 3) { + setTimeout(() => { + this.request(data); + }, 1000); + } + } + }); } /** * h5 请求 @@ -509,16 +509,18 @@ class Stat extends Util { show(self) { this.self = self; - if (!getPageTypes(self)) { + if (getPageTypes(self)) { + this._pageShow(self); + } else { this._applicationShow(self); } } ready(self) { - this.self = self; - if (getPageTypes(self)) { - this._pageShow(self); - } + // this.self = self; + // if (getPageTypes(self)) { + // this._pageShow(self); + // } } hide(self) { this.self = self; diff --git a/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js b/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js index d3401e460217003edaf50d874a79dc322de5c3cd..ddd6c15f749d035b244f49e7db258cb7935fa9d6 100644 --- a/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js +++ b/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js @@ -12,6 +12,7 @@ const { const WebpackAppPlusNVuePlugin = require('../packages/webpack-app-plus-nvue-plugin') const WebpackErrorsPlugin = require('@dcloudio/vue-cli-plugin-uni/packages/webpack-errors-plugin') +const WebpackUniMPPlugin = require('@dcloudio/webpack-uni-mp-loader/lib/plugin/index-new') const onErrors = require('@dcloudio/vue-cli-plugin-uni/util/on-errors') @@ -91,9 +92,9 @@ const rules = [{ } }, jsPreprocessorLoader - ], - exclude (modulePath) { - return excludeModuleReg.test(modulePath) && modulePath.indexOf('@dcloudio') === -1 + ], + exclude (modulePath) { + return excludeModuleReg.test(modulePath) && modulePath.indexOf('@dcloudio') === -1 } }, { @@ -146,6 +147,7 @@ if (process.env.UNI_USING_NVUE_COMPILER) { }) } if (process.env.UNI_USING_NATIVE) { + plugins.push(new WebpackUniMPPlugin()) plugins.push(new CopyWebpackPlugin([{ from: path.resolve(process.env.UNI_INPUT_DIR, 'static'), to: 'static' @@ -170,13 +172,15 @@ if (process.env.UNI_USING_NATIVE) { }])) } -module.exports = function (entry) { +module.exports = function () { return { target: 'node', // 激活 vue-loader 的 isServer 逻辑 mode: process.env.NODE_ENV, devtool: process.env.NODE_ENV === 'development' ? 'inline-source-map' : false, watch: process.env.NODE_ENV === 'development', - entry, + entry () { + return process.UNI_NVUE_ENTRY + }, externals: { 'vue': 'Vue' }, diff --git a/packages/webpack-uni-mp-loader/lib/plugin/index-new.js b/packages/webpack-uni-mp-loader/lib/plugin/index-new.js index fb78e0e05178d819d646d17689e5befc024d87e5..4039c497eca29c4c1459cc7370fea6892e440a34 100644 --- a/packages/webpack-uni-mp-loader/lib/plugin/index-new.js +++ b/packages/webpack-uni-mp-loader/lib/plugin/index-new.js @@ -67,25 +67,26 @@ function addSubPackagesRequire (compilation) { class WebpackUniMPPlugin { apply (compiler) { - compiler.hooks.emit.tapPromise('webpack-uni-mp-emit', compilation => { - return new Promise((resolve, reject) => { - addSubPackagesRequire(compilation) + if (!process.env.UNI_USING_NATIVE) { + compiler.hooks.emit.tapPromise('webpack-uni-mp-emit', compilation => { + return new Promise((resolve, reject) => { + addSubPackagesRequire(compilation) - generateJson(compilation) + generateJson(compilation) - // app.js,app.wxss - generateApp(compilation) - .forEach(({ - file, - source - }) => emitFile(file, source, compilation)) + // app.js,app.wxss + generateApp(compilation) + .forEach(({ + file, + source + }) => emitFile(file, source, compilation)) - generateComponent(compilation) + generateComponent(compilation) - resolve() + resolve() + }) }) - }) - + } compiler.hooks.invalid.tap('webpack-uni-mp-invalid', (fileName, changeTime) => { if ( fileName &&