当前位置:网站首页>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
边栏推荐
- Esp32 (UART 485 communication) - 485 communication of serial port (3)
- About the operation of unit file reading (I)
- [record] typeerror: this getOptions is not a function
- 该买什么设备,Keysight 给你挑好了
- Esp32 (UART event) - serial port event learning (1)
- Go 语言 GUI 框架 fyne 中文乱码或者不显示的问题
- Class loading process of JVM
- The first leg of the national tour of shengteng AI developer creation and enjoyment day was successfully held in Xi'an
- Nacos as service registry
- RPM包管理
猜你喜欢

Raspberry pie 18b20 temperature

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

Using Visual Studio code to develop Arduino

【历史上的今天】4 月 23 日:YouTube 上传第一个视频;网易云音乐正式上线;数字音频播放器的发明者出生

ESP32 LVGL8. 1 - input devices (input devices 18)

ESP32 LVGL8. 1 - img picture (IMG 20)

2022.04.23(LC_714_买卖股票的最佳时机含手续费)

Esp32 (UART event) - serial port event learning (1)

The difference between ordinary inner class and static inner class

Android Development: the client obtains the latest value in the database in real time and displays it on the interface
随机推荐
ESP32 LVGL8. 1. Detailed migration tutorial of m5stack + lvgl + IDF (27)
Go language GUI framework Fyne Chinese garbled or not displayed
7、 DOM (Part 2) - chapter after class exercises and answers
12 examples to consolidate promise Foundation
One of the reasons why the WebView web page cannot be opened (and some WebView problem records encountered by myself)
Nacos作为服务注册中心
ESP32 LVGL8. 1 - arc (arc 19)
Sword finger offer II 116 Number of provinces - spatial complexity O (n), time complexity O (n)
Screen right-click menu in souI
Tencent map and high logo removal method
在渤海期货办理开户安全吗。
Using 8266 as serial port debugging tool
简化路径(力扣71)
Druid SQL和Security在美团点评的实践
SSDB foundation 1
mysql_linux版本的下载及安装详解
Wechat video extraction and receiving file path
After opening the original normal project, the dependency package displays red and does not exist.
Simplified path (force buckle 71)
Treatment of incomplete display of listview height