打包之后多了一个图片请求
Request URL: https://cdn.dcloud.net.cn/img/shadow-grey.png
导致谷歌广告投放失败,怎么解决
2***@qq.com
- 发布:2020-03-02 15:26
- 更新:2023-09-22 16:42
- 阅读:5484
uni-app打包之后多了一个请求
分类:HBuilderX
这个图片是阴影效果预加载加速显示用的,如果不需要参考下面的配置
H5 平台:在起始页 html 文件中添加下面代码,参考 manifest H5 index.html 模板配置
<head>
...
<link rel="stylesheet" href="<%= BASE_URL %>static/index.css" />
<style>
body::after {
content: none;
}
</style>
</head>
可以使用自定义插件在编译后的文件中删除cdn资源引用源码的方式解决:
在根目录添加 "vue.config.js" 文件并配置以下代码:
module.exports = {
configureWebpack: (config) => {
// 编译后删除css文件里自带的uni-app资源引用
config.plugins.push(function (compiler) {
const pathReg = /\s*background(-image)?:\s*url\(\S*?\/\/[\w\.-]*?dcloud.net.cn\S*?\);?[ \t]*/gi
const eachReplace = (dirPath) => {
fs.readdirSync(dirPath, { withFileTypes: true }).forEach(dirent => {
const filePath = path.join(dirPath, dirent.name)
if (dirent.isDirectory()) {
eachReplace(filePath)
} else if (dirent.isFile() && /.(c|ac|wx)ss$/.test(dirent.name)) {
try {
const fileData = fs.readFileSync(filePath, 'utf8')
if (pathReg.test(fileData)) {
fs.writeFileSync(filePath, fileData.replace(pathReg, ''), 'utf8')
}
} catch (e) {}
}
})
}
compiler.hooks.done.tap('removeUniCdnPath', eachReplace.bind(null, process.env.UNI_OUTPUT_DIR))
})
}
}
2***@qq.com (作者)
I have checked your website with our internal tool, finding that your website 8675787933 contains bad links and I may give those link by the followings:
Malware Link :
https://cdn.dcloud.net.cn/img/shadow-grey.png
I may suggest you to firstly contact your webmaster remove those bad links from your website and try to remove the template, plug-in, scripts or any part related to unsafe domain. Once you already complete the mentioned process, kindly reply back with the evidence or screenshot from the tools you have checked to this email for further escalation.
2020-03-03 10:12
2***@qq.com (作者)
谷歌认为这是恶意脚本
2020-03-03 10:13
DCloud_heavensoft
回复 2***@qq.com: 这个问题很奇怪。1、你可以向谷歌申诉,说这是一张阴影图片,不涉及任何安全问题。2、确认下,你到底是哪个平台有问题,是h5平台吗?
2020-03-03 18:51
2***@qq.com (作者)
回复 DCloud_heavens在h5平台,谷歌认为是恶意脚本,根本不给通过,我把导航栏禁止了,打包还有这个阴影
2020-03-04 09:44
DCloud_heavensoft
回复 2***@qq.com: 先在编译后的代码里,手动删除这个图片的引用吧。我们后续提供一个简单的方法
2020-03-05 17:37