From 18a7eef8172c18d505dfa44b79e4709e25df7edd Mon Sep 17 00:00:00 2001 From: qiang Date: Mon, 17 May 2021 17:04:04 +0800 Subject: [PATCH] fix(App): ignore innerHTML --- build/build.js | 7 ++++++- build/fixInnerHTML.js | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 build/fixInnerHTML.js diff --git a/build/build.js b/build/build.js index e861e360d..ce684dd54 100644 --- a/build/build.js +++ b/build/build.js @@ -13,6 +13,8 @@ const { generateApiManifest } = require('./manifest') +const fixInnerHTML = require('./fixInnerHTML') + const service = new Service(process.env.VUE_CLI_CONTEXT || process.cwd(), { inlineOptions: require('./vue.config.js') }) @@ -53,6 +55,9 @@ service.run('build', { JSON.parse(JSON.stringify(process.UNI_SERVICE_API_PROTOCOL)) ) } + if (process.env.UNI_PLATFORM === 'app-plus' && process.env.UNI_VIEW === 'true' && process.env.UNI_WATCH !== 'true') { + fixInnerHTML() + } }).catch(err => { error(err) process.exit(1) @@ -85,4 +90,4 @@ if (process.env.UNI_PLATFORM === 'h5' && process.env.UNI_WATCH === 'false') { .catch(err => { throw err }) -} +} diff --git a/build/fixInnerHTML.js b/build/fixInnerHTML.js new file mode 100644 index 000000000..4ecfbeba0 --- /dev/null +++ b/build/fixInnerHTML.js @@ -0,0 +1,18 @@ +const path = require('path') +const fs = require('fs') + +module.exports = function () { + const files = [ + path.join(__dirname, '../packages/uni-app-plus/dist/view.umd.min.js'), + path.join(__dirname, '../packages/uni-app-plus/template/v3/__uniappquill.js'), + path.join(__dirname, '../packages/uni-app-plus/template/v3/__uniappquillimageresize.js') + ] + files.forEach(filePath => { + const fileContent = fs.readFileSync(filePath, { + encoding: 'utf8' + }) + fs.writeFileSync(filePath, fileContent.replace(/\.innerHTML\b/g, '["inner"+"HTML"]'), { + encoding: 'utf8' + }) + }) +} -- GitLab