logItem.vue
2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<template>
<view
class="logItem"
@longpress.stop="logLongpress"
>
<view class="content">
<view>
<text class="text-xs">{{ item.m }}</text>
</view>
<view class="msgBar">
<text class="time">{{ item.date }}</text>
</view>
</view>
<view class="tools">
<view
class="copyBtn"
@click="copyItem"
>
<image
src="@/devTools/page/static/copy.png"
class="copyIcon"
/>
</view>
</view>
</view>
</template>
<script>
import devCache from "../../../core/libs/devCache";
export default {
props: {
/**
* logs单行数据
*/
item: {
type: Object,
default() {
return {
date: "",
m: "", //日志内容
};
},
},
},
methods: {
/**
* 复制
*/
copyItem() {
uni.setClipboardData({
data: this.item.m,
});
},
/**
* 长按事件
*/
logLongpress() {
let that = this;
let menu = [
{
text: `复制日志信息`,
click() {
uni.setClipboardData({
data: JSON.stringify(that.item),
});
},
},
{
text: `删除此记录`,
click() {
uni.$emit("devTools_delLog", that.item);
let logs = devCache.get("logReport");
if (!logs) logs = [];
let i = logs.findIndex(
(x) => x.m == that.item.m && x.t == that.item.t
);
if (i != -1) {
logs.splice(i, 1);
devCache.set("logReport", logs);
}
uni.showToast({
title: "删除成功!",
icon: "success",
});
},
},
];
uni.showActionSheet({
itemList: menu.map((x) => x.text),
success({ tapIndex }) {
menu[tapIndex].click();
},
});
},
},
};
</script>
<style lang="scss" scoped>
.logItem:active {
background-color: rgba(0, 0, 0, 0.03);
}
.logItem {
display: flex;
flex-direction: row;
align-items: flex-start;
justify-content: space-between;
width: 750rpx;
padding: 10rpx 20rpx;
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
.content {
width: 610rpx;
display: flex;
flex-direction: column;
.context {
font-size: 20rpx;
color: #333;
line-height: 24rpx;
}
.msgBar {
display: flex;
flex-direction: row;
.time {
font-size: 16rpx;
color: #888;
}
.page {
font-size: 16rpx;
color: #888;
margin-left: 20rpx;
}
}
}
}
.copyBtn:active {
background-color: rgba(103, 194, 58, 0.6);
}
.copyBtn {
padding: 5rpx;
border-radius: 999rpx;
overflow: hidden;
background-color: #67c23a;
.copyIcon {
width: 20rpx;
height: 20rpx;
}
}
.text-xs {
font-size: 20rpx;
}
</style>