当前位置:网站首页>Wechat applet part of the mobile phone Preview PDF did not respond
Wechat applet part of the mobile phone Preview PDF did not respond
2022-04-23 19:08:00 【Gougouliang】
Today, my colleagues reported that , preview PDF Cannot be opened . Other colleagues can open .
After debugging with him, I found , Indicates that the cache is full .
adopt api FileSystemManager.readdir
Show him the cached files , Found to have 234 individual .
Let it clean up the cache , Preview normally PDF 了 .
Post the code
// preview PDF
previewPdf(params) {
uni.showLoading({
title: 'loading'
})
GetPhoto(params.filePath).then(res => {
uni.hideLoading()
if (res.statusCode == 400) {
this.$Toast(' file does not exist ')
return
}
let pdfBase64 = res.data
let fs = uni.getFileSystemManager();
fs.writeFile({
filePath: wx.env.USER_DATA_PATH + "/" + params.fileName + '.pdf',
data: uni.base64ToArrayBuffer(pdfBase64.replace(/[\r\n]/g, "")),
success: res => {
uni.openDocument({
filePath: wx.env.USER_DATA_PATH + "/" + params.fileName +
'.pdf',
showMenu: true,
success: function(res) {
},
fail(err) {
}
})
}
})
})
},
// Clean cache
removeFile() {
uni.showLoading({
title:' Cleaning up ...'
})
const fs = wx.getFileSystemManager()
fs.readdir({
dirPath: `${
wx.env.USER_DATA_PATH}/`,
success(res) {
let length = 0
for (let i of res.files) {
length++
if (length == res.files.length) {
setTimeout(()=>{
uni.hideLoading()
uni.showToast({
title: ' Clean up '
})
},500)
}
let name = (`${
wx.env.USER_DATA_PATH}/` + i)
if (name.indexOf('miniprogramLog') > -1) {
// No permission to delete skip
continue;
}
fs.unlink({
filePath: name,
fail(e) {
console.log(' File deletion failed :', e)
},
success(succ) {
console.log(' File deleted successfully :', succ);
}
})
}
},
fail(res) {
console.error(res)
}
})
},
版权声明
本文为[Gougouliang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210602029749.html
边栏推荐
- 特征选择feature_selection--SelectKBest
- Solutions such as unknown or garbled code or certificate problem prompt in Charles's mobile phone packet capture, actual measurement.
- Dynamically add and delete layouts
- SSDB基础
- #yyds干货盘点#stringprep --- 因特网字符串预备
- ESP32 LVGL8. 1 - input devices (input devices 18)
- 腾讯云GPU最佳实践-使用jupyter pycharm远程开发训练
- The type initializer for ‘Gdip‘ threw an exception
- Circuit on-line simulation
- ESP32 LVGL8. 1 - calendar (calendar 25)
猜你喜欢
浅谈c语言指针的强制转换
Simplified path (force buckle 71)
MySQL restores or rolls back data through binlog
PyGame tank battle
Chondroitin sulfate in vitreous
Some records used by VS2010
MySQL Téléchargement et installation de la version Linux
Machine learning practice - naive Bayes
ESP32 LVGL8. 1. Detailed migration tutorial of m5stack + lvgl + IDF (27)
mysql_linux版本的下载及安装详解
随机推荐
The difference between ordinary inner class and static inner class
Sentinel service fusing practice (sentinel integration ribbon + openfeign + fallback)
[advanced level 11 of C language -- character and string functions and their simulation implementation (2)]
Sword finger offer II 116 Number of provinces - spatial complexity O (n), time complexity O (n)
Getting started with vcpkg
2022.04.23 (lc_763_divided into letter interval)
Usage of functions decode() and replace() in SQL
Android Development: the client obtains the latest value in the database in real time and displays it on the interface
Résolution: cnpm: impossible de charger le fichier... Cnpm. PS1 parce que l'exécution de scripts est désactivée sur ce système
FTP、ssh远程访问及控制
redis优化系列(三)解决主从配置后的常见问题
SSDB foundation 3
该买什么设备,Keysight 给你挑好了
PyGame tank battle
Class loading process of JVM
ESP32 LVGL8. 1 - textarea text area (textarea 26)
ESP32 LVGL8. 1 - arc (arc 19)
Esp32 (UART 485 communication) - 485 communication of serial port (3)
SSDB foundation 1
Some records used by VS2010