From 220d017a0f24f482501bf063c382348528a2b353 Mon Sep 17 00:00:00 2001 From: chenjiajian <798095202@qq.com> Date: Mon, 22 Apr 2019 14:28:41 +0800 Subject: [PATCH 01/10] =?UTF-8?q?fix(taro-cli):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=20npm=20=E8=B7=AF=E5=BE=84=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-cli/src/plugin.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/taro-cli/src/plugin.js b/packages/taro-cli/src/plugin.js index d21945e7e4dd..f3a8236e41d5 100644 --- a/packages/taro-cli/src/plugin.js +++ b/packages/taro-cli/src/plugin.js @@ -258,16 +258,18 @@ function wxPluginWatchFiles () { // 最后删除 output/plugin const names = glob.sync(`${outputPath}/${PLUGIN_ROOT}/**/*`) if (names.length) { - const jsNames = glob.sync(`${outputPath}/${PLUGIN_ROOT}/!(npm)/**/*.js`) + const jsNames = glob.sync(`${outputPath}/${PLUGIN_ROOT}/{,!(npm)/**/}*.js`) const ioPromises = jsNames.map(async name => { let content = await fs.readFile(name) content = content.toString() - let shouldWrite - const replacement = content.replace(/['|"](\.\.\/)+npm\/.+?['|"]/g, str => { - shouldWrite = true - return str.replace('../', '') + + let isShouldBeWritten + let replacement = content.replace(/['|"]((\.\.\/)+)npm\/.+?['|"]/g, (str, $1) => { + isShouldBeWritten = true + return $1 === '../' ? str.replace('../', './') : str.replace('../', '') }) - if (shouldWrite) await fs.writeFile(name, replacement) + + if (isShouldBeWritten) await fs.writeFile(name, replacement) }) await Promise.all(ioPromises) @@ -359,12 +361,14 @@ async function buildWxPlugin ({ watch }) { const ioPromises = names.map(async name => { let content = await fs.readFile(name) content = content.toString() - let shouldWrite - const replacement = content.replace(/['|"]((\.\.\/)+)npm\/.+?['|"]/g, (str, $1) => { - shouldWrite = true + + let isShouldBeWritten + let replacement = content.replace(/['|"]((\.\.\/)+)npm\/.+?['|"]/g, (str, $1) => { + isShouldBeWritten = true return $1 === '../' ? str.replace('../', './') : str.replace('../', '') }) - if (shouldWrite) await fs.writeFile(path.join(appPath, name), replacement) + + if (isShouldBeWritten) await fs.writeFile(path.join(appPath, name), replacement) }) await Promise.all(ioPromises) From 1bad473fe86a75acbec2d7633bef18227303a4f9 Mon Sep 17 00:00:00 2001 From: chenjiajian <798095202@qq.com> Date: Mon, 22 Apr 2019 15:29:30 +0800 Subject: [PATCH 02/10] =?UTF-8?q?fix(taro-cli):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E9=9D=99=E6=80=81=E8=B5=84=E6=BA=90=E5=BC=95?= =?UTF-8?q?=E7=94=A8=E8=B7=AF=E5=BE=84=E3=80=82close=20#2829?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-cli/src/plugin.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/taro-cli/src/plugin.js b/packages/taro-cli/src/plugin.js index f3a8236e41d5..b1d2491348c8 100644 --- a/packages/taro-cli/src/plugin.js +++ b/packages/taro-cli/src/plugin.js @@ -269,6 +269,14 @@ function wxPluginWatchFiles () { return $1 === '../' ? str.replace('../', './') : str.replace('../', '') }) + const REG_PLUGIN_DEPS = RegExp(`['|"](/${PLUGIN_ROOT}.+)['|"]`, 'g') + replacement = replacement.replace(REG_PLUGIN_DEPS, (str, $1) => { + if (Util.REG_FONT.test($1) || Util.REG_IMAGE.test($1) || Util.REG_MEDIA.test($1)) { + return str.replace(RegExp(`^['|"]/${PLUGIN_ROOT}`, 'g'), str => str.replace(`${PLUGIN_ROOT}`, '')) + } + return str + }) + if (isShouldBeWritten) await fs.writeFile(name, replacement) }) await Promise.all(ioPromises) @@ -368,6 +376,14 @@ async function buildWxPlugin ({ watch }) { return $1 === '../' ? str.replace('../', './') : str.replace('../', '') }) + const REG_PLUGIN_DEPS = RegExp(`['|"](/${PLUGIN_ROOT}.+)['|"]`, 'g') + replacement = replacement.replace(REG_PLUGIN_DEPS, (str, $1) => { + if (Util.REG_FONT.test($1) || Util.REG_IMAGE.test($1) || Util.REG_MEDIA.test($1)) { + return str.replace(RegExp(`^['|"]/${PLUGIN_ROOT}`, 'g'), str => str.replace(`${PLUGIN_ROOT}`, '')) + } + return str + }) + if (isShouldBeWritten) await fs.writeFile(path.join(appPath, name), replacement) }) await Promise.all(ioPromises) From 43ccd536594b34aa3cf921f891eba461a93697cd Mon Sep 17 00:00:00 2001 From: littly <544028951@qq.com> Date: Mon, 22 Apr 2019 17:20:18 +0800 Subject: [PATCH 03/10] =?UTF-8?q?feat(h5):=20h5=E5=A2=9E=E5=8A=A0api=20cho?= =?UTF-8?q?oseLocation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/api/location/chooseLocation.js | 133 ++++++++++++++++++ packages/taro-h5/src/api/location/index.js | 2 +- packages/taro-h5/src/api/location/style.css | 78 ++++++++++ .../taro-h5/src/api/unsupportedApi/index.js | 2 +- 4 files changed, 213 insertions(+), 2 deletions(-) create mode 100644 packages/taro-h5/src/api/location/chooseLocation.js create mode 100644 packages/taro-h5/src/api/location/style.css diff --git a/packages/taro-h5/src/api/location/chooseLocation.js b/packages/taro-h5/src/api/location/chooseLocation.js new file mode 100644 index 000000000000..90e2adea6f3a --- /dev/null +++ b/packages/taro-h5/src/api/location/chooseLocation.js @@ -0,0 +1,133 @@ +/* global LOCATION_APIKEY */ +import Taro from '../../taro' +import Nerv from 'nervjs' + +import './style.css' + +/** @type {LocationChooser} */ +let locationChooser + +class LocationChooser extends Taro.Component { + constructor (props, context) { + super(props, context) + locationChooser = this + } + getWrapRef = ref => { + if (ref) this.wrapRef = ref + } + show = () => { + setTimeout(() => { + this.wrapRef.style.top = '0' + }) + } + hide = () => { + this.wrapRef.style.top = '100%' + } + onBack = () => { + this.props.handler({ errMsg: 'chooseLOcation:fail cancel' }) + this.hide() + } + onSubmit = () => { + this.props.handler() + this.hide() + } + render () { + return Nerv.createPortal( +
+
+
+

位置

+ +
+