更新记录
1.0.0(2025-09-30)
下载此版本
初版提交,具体功能看使用方法说明
平台兼容性
uni-app(3.6.5)
Vue2 |
Vue2插件版本 |
Vue3 |
Vue2插件版本 |
Chrome |
Safari |
app-vue |
app-vue插件版本 |
app-nvue |
app-nvue插件版本 |
Android |
iOS |
鸿蒙 |
√ |
1.0.0 |
√ |
1.0.0 |
- |
- |
√ |
1.0.0 |
√ |
1.0.0 |
- |
- |
- |
微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
快应用-华为 |
快应用-联盟 |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
uni-app x(3.6.5)
Chrome |
Safari |
Android |
iOS |
鸿蒙 |
微信小程序 |
- |
- |
- |
- |
- |
- |
xiaopao-storage
功能列表及用法:
1、检测目录是否存在
/**
* 检测目录是否存在
* @param {string} basePath - 目录基本路径(如 "_doc")
* @param {string} dirName - 目录名(如 "image")
* @returns {Promise<boolean>} 目录是否存在
*/
xiaopaoStorage.checkDirExists(basePath, dirName).then((exists) => {
if (exists) {
// 存在
} else {
// 目录不存在
}
})
2、检测目录下文件是否存在
/**
* 检测目录下文件是否存在
* @param {string} filePath - 文件路径(如 "_doc/image/ban_img.png")
* @returns {Promise<boolean>} 文件是否存在
*/
xiaopaoStorage.checkFileExists(filePath).then((exists) => {
if (exists) {
// 存在
} else {
// 文件不存在
}
})
3、创建目录
/**
* 创建目录
* @param {string} dirName 指定文件夹名
* @param {string} basePath 文件基本路径
* @returns 返回目录条目对象
*/
xiaopaoStorage.createDirectory(dirName, basePath).then((entry) => {
// entry 返回目录条目对象
})
4、获取对应目录下的总文件大小
/**
* 获取对应目录下的总文件大小
* @param {string} dirName - 目录名(如 "image")
* @param {string} basePath - 目录路径(如 "_doc")
* @param {string[]} notIncludeDir - 不包含的目录(如 ["video"])
* @returns {Promise<Entry[]>} 目录列表
*/
xiaopaoStorage.getFolderSize(dirName, basePath = '_doc', notIncludeDir = []).then((totalSize) => {
// totalSize 总文件大小
})
5、格式化字节单位
/**
* 格式化字节单位
* @param {number} bytes 字节数
* @returns {string} 格式化后的字符串
*/
const str = xiaopaoStorage.formatBytes(bytes)
6、格式化字节单位
/**
* 获取文件信息
* @param {object} filePath 文件路径
* @returns {Promise<object>} 文件信息对象: size 文件大小,以字节为单位 createTime 文件保存时的时间戳
*/
xiaopaoStorage.getFileInfo(filePath).then((info) => {
// info
})
7、清理指定目录下所有文件和子目录
/**
* 清理指定目录下所有文件和子目录
* @param {string} dirName 指定文件夹名
* @param {string} basePath 文件基本路径
* @param {string[]} notIncludeDir - 不包含的目录(如 ["video"])
* @returns {Promise<boolean>} 是否清除成功
*/
// 清除 _doc下的video目录
xiaopaoStorage.clearDirectory('video').then((isOk) => {
// isOk 为 true or false
})
8、获取手机总存储空间
/**
* 获取手机总存储空间
*/
const totalSpace = xiaopaoStorage.getFileSystemSize()
9、获取手机剩余存储空间
/**
* 获取手机剩余存储空间
*/
const freeSpace = xiaopaoStorage.getFileSystemFreeSize()