177 lines
4.5 KiB
Vue
Executable File
177 lines
4.5 KiB
Vue
Executable File
<template>
|
|
<view class="page">
|
|
<!-- <view class="title">日志参数</view> -->
|
|
<view class="title-switch"><text>启用日志</text><switch :checked="isOpenLog" @change="isOpenLogChange"/></view>
|
|
<view class="title-switch" @click="clearAllLog" ><text>清除日志</text><view class="opsoft-clear-icon" style="background-image: url(../../../static/myinfo/refresh.png);"/></view>
|
|
<view class="title-switch" @click="clearYesterdayLog"><text>清除前一天日志</text><view class="opsoft-clear-icon" style="background-image: url(../../../static/myinfo/refresh.png);"/></view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
isOpenLog:true
|
|
}
|
|
},
|
|
components: {},
|
|
computed: {},
|
|
onLoad() {
|
|
this.isOpenLog = uni.getStorageSync('isOpenLog');
|
|
},
|
|
onShow() {
|
|
this.isOpenLog = uni.getStorageSync('isOpenLog');
|
|
},
|
|
methods: {
|
|
isOpenLogChange(){
|
|
this.isOpenLog = !this.isOpenLog;
|
|
uni.setStorageSync('isOpenLog', this.isOpenLog);
|
|
console.log(this.isOpenLog);
|
|
},
|
|
clearAllLog(){
|
|
let dirPath = '';
|
|
// #ifdef APP-PLUS
|
|
plus.io.requestFileSystem(plus.io.PUBLIC_DOCUMENTS,function(fs){
|
|
let a = fs.root.toURL();
|
|
dirPath = a + '/' + 'app-log';
|
|
console.log('dirPath',dirPath);
|
|
plus.io.resolveLocalFileSystemURL(dirPath,function(entry){
|
|
//读取当前目录对象
|
|
var directoryReader = entry.createReader();
|
|
//读取这个目录下的所有文件
|
|
directoryReader.readEntries(function(entries){
|
|
console.log(entries, 'entries')
|
|
var i;
|
|
for( i=0; i < entries.length; i++ ) {
|
|
console.log( entries[i].name );
|
|
}
|
|
if(entries.length > 0){
|
|
entry.removeRecursively(function(entry){
|
|
callback();
|
|
console.log('删除成功回调');
|
|
}, function(err){
|
|
console.log(err.message + ' ?!')
|
|
});
|
|
}
|
|
});
|
|
});
|
|
});
|
|
// #endif
|
|
},
|
|
getTimeStampDatetime(format = 'yyyy-MM-dd HH:mm:ss', timeStamp) {
|
|
let nowDatetime = new Date()
|
|
timeStamp ? nowDatetime = new Date(timeStamp) : nowDatetime = new Date()
|
|
return nowDatetime.Format(format)
|
|
},
|
|
clearYesterdayLog(){
|
|
let dirPath = '';
|
|
let curDate = this.getTimeStampDatetime("yyyy-MM-dd");
|
|
let yesterdayDate = this.getTimeStampDatetime("yyyy-MM-dd", (new Date(curDate).getTime()-86400000));
|
|
// #ifdef APP-PLUS
|
|
plus.io.requestFileSystem(plus.io.PUBLIC_DOCUMENTS,function(fs){
|
|
let a = fs.root.toURL();
|
|
dirPath = a + '/' + 'app-log/' + yesterdayDate + 'log.text';
|
|
console.log('dirPath',dirPath);
|
|
plus.io.resolveLocalFileSystemURL(dirPath,function(entry){
|
|
entry.remove(function(entry){
|
|
callback();
|
|
console.log('删除成功回调');
|
|
}, function(err){
|
|
console.log(err.message + ' ?!')
|
|
});
|
|
});
|
|
});
|
|
// #endif
|
|
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.page {
|
|
width: 100%;
|
|
height: 100%;
|
|
background: #FFFFFF;
|
|
}
|
|
.opsoft-clear-icon{
|
|
height: 60rpx;
|
|
width: 60rpx;
|
|
background-repeat: no-repeat;
|
|
background-size: 100%;
|
|
margin-right: 64rpx;
|
|
}
|
|
.title{
|
|
height: 90.57upx;
|
|
line-height: 90.57upx;
|
|
font-size: 28.98upx;
|
|
font-family: PingFangSC-Regular, PingFang SC;
|
|
font-weight: 400;
|
|
color: #686868;
|
|
margin-left: 43.47upx;
|
|
}
|
|
.title-switch{
|
|
display: flex;
|
|
width: 100%;
|
|
flex-direction: row;
|
|
background: #FFFFFF;
|
|
margin-top: 3.62upx;
|
|
align-items: center;
|
|
border-bottom: #e5e5e5 solid 1px;
|
|
}
|
|
|
|
.title-switch text{
|
|
width: 100%;
|
|
height: 108.69upx;
|
|
line-height: 108.69upx;
|
|
font-size: 32.6upx;
|
|
font-family: PingFangSC-Regular, PingFang SC;
|
|
font-weight: 400;
|
|
color: #232323;
|
|
margin-left: 43.47upx;
|
|
}
|
|
switch{
|
|
width: 79.71upx;
|
|
transform: scale(0.7);
|
|
margin-right: 43.47upx;
|
|
}
|
|
image{
|
|
height: 40rpx;
|
|
width: 40rpx;
|
|
margin-right: 43.47upx;
|
|
}
|
|
.my-body-outline{
|
|
height: 108.69rpx;
|
|
display: flex;
|
|
flex-direction:
|
|
row;align-items: center;
|
|
}
|
|
.left-img{
|
|
height: 50.72rpx;
|
|
width: 50.72rpx;
|
|
margin-left: 43.47rpx;
|
|
}
|
|
.my-body{
|
|
width: 80%;
|
|
display: flex;
|
|
flex-direction: row;
|
|
align-items: center;
|
|
justify-content: start;
|
|
height: 108.69rpx;
|
|
line-height: 108.69rpx;
|
|
margin-left: 43.47rpx;
|
|
margin-right: 43.47rpx;
|
|
border-bottom: #F1F1F1 solid 1.81rpx;
|
|
}
|
|
.my-body image{
|
|
height: 32.6rpx;
|
|
width: 32.6rpx;
|
|
}
|
|
.my-body view{
|
|
margin-left: 21.73rpx;
|
|
width: 100%;
|
|
font-size: 32.6rpx;
|
|
}
|
|
</style>
|