logItem.vue 2.9 KB

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