pages.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <view
  3. v-if="isShow"
  4. class="pagesList"
  5. >
  6. <!-- <objectAnalysis
  7. v-if="isLoaded"
  8. :data="pages"
  9. :isOpenFirst="true"
  10. :width="710"
  11. /> -->
  12. <template v-if="isLoaded">
  13. <view
  14. v-for="(item, index) in pages"
  15. :key="index"
  16. class="pageItem"
  17. @longpress.stop="longpress(item)"
  18. >
  19. <text
  20. v-if="pages.length == index + 1"
  21. class="t-red"
  22. >
  23. 当前
  24. </text>
  25. <view class="routeInfo">
  26. <text class="path">{{ item.route }}</text>
  27. <text class="options">{{ item.options }}</text>
  28. </view>
  29. </view>
  30. </template>
  31. <view
  32. v-else
  33. class="dataLoading"
  34. >
  35. <text class="status">加载中</text>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import objectAnalysis from "./objectAnalysis.vue";
  41. export default {
  42. components: {
  43. objectAnalysis,
  44. },
  45. props: {
  46. /**
  47. * 是否渲染
  48. */
  49. isShow: {
  50. type: Boolean,
  51. default: true,
  52. },
  53. },
  54. data() {
  55. return {
  56. /**
  57. * 是否完成加载
  58. */
  59. isLoaded: false,
  60. /**
  61. * 页面路由数据
  62. */
  63. pages: [],
  64. };
  65. },
  66. methods: {
  67. /**
  68. * 加载数据
  69. */
  70. getData() {
  71. let that = this;
  72. that.isLoaded = false;
  73. let pageList = getCurrentPages().map((x) => {
  74. let options = "";
  75. if (x.options) {
  76. Object.keys(x.options).map((key) => {
  77. options = options + (options == "" ? "" : "&") + key + "=" + x.options[key];
  78. });
  79. }
  80. return {
  81. route: x.route,
  82. options,
  83. };
  84. });
  85. pageList.pop();
  86. that.pages = pageList;
  87. that.isLoaded = true;
  88. },
  89. /**
  90. * 长按事件
  91. */
  92. longpress(item) {
  93. let that = this;
  94. let menu = [
  95. {
  96. text: `复制路径`,
  97. click() {
  98. uni.setClipboardData({
  99. data: item.route,
  100. });
  101. },
  102. },
  103. ...(item.options
  104. ? [
  105. {
  106. text: `复制参数`,
  107. click() {
  108. uni.setClipboardData({
  109. data: item.options,
  110. });
  111. },
  112. },
  113. {
  114. text: `复制路径+参数`,
  115. click() {
  116. uni.setClipboardData({
  117. data: item.route + item.options ? "?" + item.options : "",
  118. });
  119. },
  120. },
  121. ]
  122. : []),
  123. ];
  124. uni.showActionSheet({
  125. itemList: menu.map((x) => x.text),
  126. success({ tapIndex }) {
  127. menu[tapIndex].click();
  128. },
  129. });
  130. },
  131. },
  132. };
  133. </script>
  134. <style lang="scss" scoped>
  135. .pagesList {
  136. width: 750rpx;
  137. display: flex;
  138. flex-direction: column;
  139. .pageItem {
  140. display: flex;
  141. flex-direction: row;
  142. align-items: center;
  143. padding: 15rpx 20rpx;
  144. border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  145. &:active {
  146. background-color: rgba(0, 0, 0, 0.05);
  147. }
  148. .t-red {
  149. font-size: 20rpx;
  150. color: #fff;
  151. padding: 3rpx 8rpx;
  152. background-color: #ff2d55;
  153. border-radius: 10rpx;
  154. margin-right: 10rpx;
  155. height: 34rpx;
  156. }
  157. .routeInfo {
  158. display: flex;
  159. flex-direction: column;
  160. width: 580rpx;
  161. .path {
  162. font-size: 26rpx;
  163. line-height: 30rpx;
  164. color: #333;
  165. width: 580rpx;
  166. /* #ifndef APP-PLUS */
  167. word-wrap: break-word;
  168. overflow-wrap: break-word;
  169. white-space: normal;
  170. /* #endif */
  171. }
  172. .options {
  173. margin-top: 4rpx;
  174. font-size: 20rpx;
  175. line-height: 26rpx;
  176. color: #888;
  177. width: 580rpx;
  178. /* #ifndef APP-PLUS */
  179. word-wrap: break-word;
  180. overflow-wrap: break-word;
  181. white-space: normal;
  182. /* #endif */
  183. }
  184. }
  185. }
  186. }
  187. .dataLoading {
  188. width: 750rpx;
  189. height: 100rpx;
  190. display: flex;
  191. flex-direction: row;
  192. align-items: center;
  193. justify-content: center;
  194. .status {
  195. font-size: 20rpx;
  196. color: #888;
  197. line-height: 20rpx;
  198. }
  199. }
  200. </style>