当前位置: 首页 > wzjs >正文

网站建设情况调查表seo是哪个英文的缩写

网站建设情况调查表,seo是哪个英文的缩写,龙岗永湖网站建设,做网站每天任务及实训过程目录 移动文件到指定文件夹 新增本地文件夹 设定本地文件过期时间,清除超时文件,释放内存 操作本地文件之----删除 uniapp获取设备剩余存储空间的方法 读取本地文件夹下的文件 移动文件到指定文件夹 function moveTempFile(tempFilePath, targetFo…

目录

移动文件到指定文件夹

新增本地文件夹

设定本地文件过期时间,清除超时文件,释放内存

操作本地文件之----删除

uniapp获取设备剩余存储空间的方法

读取本地文件夹下的文件


移动文件到指定文件夹

	function moveTempFile(tempFilePath, targetFolderPath, targetFileName) {plus.io.resolveLocalFileSystemURL(tempFilePath, function(entry) {// 获取目标目录的Entry对象plus.io.resolveLocalFileSystemURL(targetFolderPath, function(dirEntry) {// 执行复制操作entry.copyTo(dirEntry, targetFileName, function(newEntry) {//删除临时文件plus.io.resolveLocalFileSystemURL(tempFilePath, (entry) => {entry.remove(() => {console.log('临时文件转移成功');}, function(error) {console.error('临时文件转移失败:' + error.code);});});if (targetFileName.endsWith("mp4")) {console.log('判断临时文件为视频文件');getVideoNum()}}, function(e) {console.error('文件复制失败: ' + JSON.stringify(e));});}, function(e) {console.error('无法访问目标目录: ' + JSON.stringify(e));});}, function(e) {console.error('无法访问源文件: ' + JSON.stringify(e));});}
}

新增本地文件夹

//创建一个新目录
function CreateNewDir(url, dirName) {//url值可支持相对路径URL、本地路径URLreturn new Promise((resolver, reject) => {plus.io.resolveLocalFileSystemURL(url, function(entry) {entry.getDirectory(dirName, {create: true,exclusive: false}, function(dir) {resolver(true)}, function(error) {reject(error.message)uni.showToast({title: dirName + '目录创建失败:' + error.message,duration: 2000,icon: 'none'});});}, function(e) {reject(error.message)uni.showToast({title: '获取目录失败:' + e.message,duration: 2000,icon: 'none'});});})
}

设定本地文件过期时间,清除超时文件,释放内存

dataNum为文件的保质期

	//获取当前n天之前的日期getDelTime(dataNum){let today = new Date();let nDaysAgo = new Date(today.setDate(today.getDate() - dataNum));let year = nDaysAgo.getFullYear();let month = nDaysAgo.getMonth() + 1; // 月份是从0开始的,所以需要加1let day = nDaysAgo.getDate();// 将年月日转换为数字格式的字符串,不带任何分隔符-------n天前的年月日let numericDate = year.toString() + (month < 10 ? '0' + month : month).toString() + (day < 10 ? '0' + day : day).toString();	this.delExpiredFile(Number(numericDate))},//循环遍历视频图片文件夹,遍历出n天前的文件list,并执行删除操作async delExpiredFile(maxTime){// console.log('maxTime',maxTime);//获取所有图片文件await this.getImgList(maxTime)//获取所有视频文件await this.getVideoList(maxTime)},getImgList(maxTime){// console.log('开始获取图片',maxTime);this.imgNameList=[]plus.io.resolveLocalFileSystemURL("/storage/emulated/0/_A/img", //指定的目录(entry) => {let directoryReader = entry.createReader(); //获取读取目录对象directoryReader.readEntries((entry) => { //历遍子目录entry.forEach((entryA)=> {if (entryA.isFile) {// 获取文件名let fileName = entryA.name;this.imgNameList.push(fileName)}});this.imgNameList.forEach((item)=> {let extractedString = item.substring(4, 12);let  result =Number(extractedString)if(result < maxTime){console.log("将要删除的图片名",item);this.delFile(item,"picture")}});},(err) => {console.log("访问目录失败");});},(err) => {console.log("访问指定目录失败:" + err.message);});},getVideoList(maxTime){this.videoNameList=[]plus.io.resolveLocalFileSystemURL("/storage/emulated/0/_A/video", //指定的目录(entry) => {let directoryReader = entry.createReader(); //获取读取目录对象directoryReader.readEntries((entry) => { //历遍子目录即可entry.forEach((entryB)=> {if (entryB.isFile) {// 获取文件名let fileName = entryB.name;this.videoNameList.push(fileName)}});this.videoNameList.forEach((item)=> {let extractedString = item.substring(6, 14);let  result =Number(extractedString)if(result < maxTime){this.delFile(item,"video")}});},(err) => {console.log("访问目录失败");});},(err) => {console.log("访问指定目录失败:" + err.message);});},//删除文件delFile(fileName,fileType){console.log('将要删除的文件名fileName',fileName);return new Promise((resolve, reject) => {let filePath=nullif(fileType=="video"){filePath=`/storage/emulated/0/_A/video/${fileName}`}else if(fileType=="picture"){filePath=`/storage/emulated/0/_A/img/${fileName}`}//删除视频文件					plus.io.resolveLocalFileSystemURL(filePath, (entry)=> {   // 删除文件entry.remove(()=> {console.log('文件删除成功');}, function(error) {console.error('文件删除失败:' + error.code);});});})},

操作本地文件之----删除

delFile(fileName,fileType){return new Promise((resolve, reject) => {let filePath=nullif(fileType=="video"){filePath=`/storage/emulated/0/_A/video/${fileName}`}else if(fileType=="picture"){filePath=`/storage/emulated/0/_A/img/${fileName}`}				//删除视频文件					plus.io.resolveLocalFileSystemURL(filePath, (entry)=> {   // 删除文件entry.remove(()=> {console.log('文件删除成功');}, function(error) {console.error('文件删除失败:' + error.code);});});})
}

uniapp获取设备剩余存储空间的方法

function getStorage() {const environment = plus.android.importClass("android.os.Environment");const statFs = plus.android.importClass("android.os.StatFs");plus.android.importClass("java.io.File");const Files = environment.getDataDirectory();const StatFs = new statFs(Files.getPath());const blockAva = parseFloat(StatFs.getAvailableBlocks());const blockSize = parseFloat(StatFs.getBlockSize());const internalMemSize = blockSize * blockAva;// 自己根据单位来计算结果,本示例计算的是以为G单位的剩余容量const freeSize = internalMemSize / 1024 / 1024 / 1024;return freeSize.toFixed(2) + 'G'
}

读取本地文件夹下的文件

注意:如果不用箭头函数的话,在plus.的方法里面是不能使用this访问外部变量的,一定一定要使用箭头函数处理。

		readFile() {const folderPath = 'file://storage/sdcard0/Android/data/io.dcloud.HBuilder/files/';this.aFileList = [];plus.io.resolveLocalFileSystemURL(folderPath, //指定的目录(entry) => {var directoryReader = entry.createReader(); //获取读取目录对象directoryReader.readEntries((entries) => { //返回的是指定文件夹下的文件列表this.aFileList = entriesthis.aFileList.forEach(i => {if (/\./.test(i.name)) {this.list.push({name: i.name})}})},(err) => {console.log("访问目录失败");});},(err) => {console.log("访问指定目录失败:" + err.message);});},

http://www.dtcms.com/wzjs/217324.html

相关文章:

  • 专业嵌入式软件开发杭州网站关键词排名优化
  • 网页设计外文文献优化公司排名
  • 公司网站用个人备案可以短视频剪辑培训班速成
  • 怎么写网站建设与运营电商seo引流
  • 怎么用ip做网站武汉seo群
  • 蚌埠网站建设哪家好中国广告公司前十强
  • 网站建设工作厦门seo排名扣费
  • 做设计兼职的网站百度网址大全网站
  • 网站设计用什么软件做的台州做优化
  • 做网站犯法外贸营销策略都有哪些
  • 客服网站制作湘潭网站seo
  • wordpress熊掌号专业版企业站seo外包
  • 公司网站用哪个软件做百度服务中心人工客服电话
  • 2022营业执照年审合肥网站seo费用
  • seo查询站长搜索引擎营销的简称
  • 临沂网站建设 百度优化宁波好的seo外包公司
  • 手机网站开发目的114网址大全
  • 如何注销网站备案负责人巩义网络推广
  • 东莞企业网站电话广州各区正在进一步优化以下措施
  • 公司被其它人拿来做网站公司网站制作流程
  • 东莞室内设计公司排名苏州首页关键词优化
  • 网站如何做长沙网站排名推广
  • 新区网站建设seo怎么优化
  • 网站建设推广新闻发稿平台
  • 大庆市让胡路区规划建设局网站广州seo公司排名
  • 工作细胞樱花动漫长沙靠谱seo优化
  • 专业网站开发设计搜索引擎入口yandex
  • 离线网站制作小广告多的网站
  • 天水 网站建设网站推广什么意思
  • 做网站学什么软件百度站内搜索提升关键词排名