index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <div class="data-test-container">
  3. <div class="page-header">
  4. <h1>数据测试</h1>
  5. <p>用于测试和验证比赛数据的页面</p>
  6. </div>
  7. <div class="content-area">
  8. <div class="test-panel">
  9. <h2>测试数据展示</h2>
  10. <div class="data-display">
  11. <div class="data-item">
  12. <label>当前时间:</label>
  13. <span>{{ currentTime }}</span>
  14. </div>
  15. <!-- <div class="data-item">
  16. <label>测试状态:</label>
  17. <span class="status-success">正常运行</span>
  18. </div> -->
  19. <div class="data-item">
  20. <label>数据源:</label>
  21. <span>比赛管理系统</span>
  22. </div>
  23. </div>
  24. <div class="radio-options">
  25. <div class="radio-group">
  26. <label class="radio-label">
  27. <input
  28. type="radio"
  29. name="testMode"
  30. value="1"
  31. v-model="selectedTestMode"
  32. class="radio-input"
  33. >
  34. <span class="radio-text">今日</span>
  35. </label>
  36. <label class="radio-label">
  37. <input
  38. type="radio"
  39. name="testMode"
  40. value="0"
  41. v-model="selectedTestMode"
  42. class="radio-input"
  43. >
  44. <span class="radio-text">早盘</span>
  45. </label>
  46. <label class="radio-label">
  47. <input
  48. type="radio"
  49. name="testMode"
  50. value=""
  51. v-model="selectedTestMode"
  52. class="radio-input"
  53. >
  54. <span class="radio-text">全部</span>
  55. </label>
  56. </div>
  57. </div>
  58. <div class="action-buttons">
  59. <button class="btn btn-primary" @click="refreshData">
  60. 刷新数据
  61. </button>
  62. <button class="btn btn-secondary" @click="runTest">
  63. 运行测试
  64. </button>
  65. <button class="btn btn-secondary" @click="verifyData">
  66. 验证数据
  67. </button>
  68. <button class="btn btn-secondary" @click="filterLive">
  69. 筛选滚球
  70. </button>
  71. </div>
  72. </div>
  73. </div>
  74. <div class="data-table">
  75. <vue-json-pretty :data="prettyData" :indent="prettyIndent" :deep="prettyDeep"></vue-json-pretty>
  76. </div>
  77. </div>
  78. </template>
  79. <script setup>
  80. import { ref, onMounted } from 'vue';
  81. import { requestClient } from '#/api/request';
  82. import dayjs from 'dayjs';
  83. import VueJsonPretty from 'vue-json-pretty';
  84. import 'vue-json-pretty/lib/styles.css';
  85. const currentTime = ref('');
  86. const gamesRelation = ref([]);
  87. const gamesSolution = ref({});
  88. const selectedTestMode = ref('1');
  89. const prettyData = ref(null);
  90. const prettyIndent = ref(2);
  91. const prettyDeep = ref(0);
  92. const updateTime = () => {
  93. currentTime.value = new Date().toLocaleString('zh-CN')
  94. }
  95. const refreshData = () => {
  96. updateTime();
  97. Promise.all([
  98. requestClient.get('/pstery/get_games_relation', { params: { mk: selectedTestMode.value } }),
  99. requestClient.get('/pstery/get_solutions', { params: { win_min: -99999 } })
  100. ])
  101. .then(([relations, solutions]) => {
  102. gamesRelation.value = relations;
  103. gamesSolution.value = solutions;
  104. console.log('数据已刷新');
  105. });
  106. }
  107. const runTest = () => {
  108. const gamesList = gamesRelation.value.map(item => {
  109. const { eventId, leagueId, leagueName, teamHomeName, teamAwayName, timestamp } = item?.rel?.ps ?? {};
  110. const datetime = dayjs(timestamp).format('YYYY-MM-DD HH:mm:ss');
  111. return { eventId, leagueId, leagueName, teamHomeName, teamAwayName, datetime };
  112. });
  113. gamesSolution.value.solutions.forEach((solution) => {
  114. const { sid, info: { id }} = solution;
  115. const currentGame = gamesList.find(game => game.eventId === id);
  116. if (!currentGame) {
  117. console.log('game not found', id);
  118. }
  119. else {
  120. if (!currentGame.solutions) {
  121. currentGame.solutions = [];
  122. }
  123. currentGame.solutions.push(sid);
  124. }
  125. });
  126. prettyData.value = gamesList;
  127. prettyDeep.value = 2;
  128. // console.log('gamesRelation', gamesList);
  129. }
  130. const verifyData = () => {
  131. const solutions = gamesSolution.value.solutions;
  132. const invalidSolutions = [];
  133. solutions.forEach((solution) => {
  134. const { sol: { win_average, win_profit_rate } } = solution;
  135. if (win_average * win_profit_rate < 0) {
  136. invalidSolutions.push(solution)
  137. }
  138. });
  139. prettyData.value = invalidSolutions;
  140. prettyDeep.value = 2;
  141. // console.log('invalidSolutions', invalidSolutions);
  142. }
  143. const filterLive = () => {
  144. const solutions = gamesSolution.value.solutions;
  145. const liveSolutions = solutions.filter((solution) => {
  146. const { info: { ob, hg, ps } } = solution;
  147. return ps.stage;
  148. });
  149. prettyData.value = liveSolutions;
  150. prettyDeep.value = 2;
  151. // console.log('liveSolutions', liveSolutions);
  152. }
  153. // const currentTime = ref('')
  154. // const updateTime = () => {
  155. // currentTime.value = new Date().toLocaleString('zh-CN')
  156. // }
  157. // const refreshData = () => {
  158. // updateTime()
  159. // console.log('数据已刷新')
  160. // }
  161. // const runTest = () => {
  162. // console.log('开始运行测试...')
  163. // // 这里可以添加具体的测试逻辑
  164. // }
  165. onMounted(() => {
  166. refreshData();
  167. })
  168. </script>
  169. <style lang="scss" scoped>
  170. .data-test-container {
  171. padding: 20px;
  172. .page-header {
  173. margin-bottom: 30px;
  174. h1 {
  175. font-size: 24px;
  176. font-weight: bold;
  177. margin-bottom: 8px;
  178. color: #333;
  179. }
  180. p {
  181. color: #666;
  182. font-size: 14px;
  183. }
  184. }
  185. .content-area {
  186. .test-panel {
  187. background: #fff;
  188. border-radius: 8px;
  189. padding: 24px;
  190. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  191. h2 {
  192. font-size: 18px;
  193. font-weight: 600;
  194. margin-bottom: 20px;
  195. color: #333;
  196. }
  197. .data-display {
  198. margin-bottom: 24px;
  199. .data-item {
  200. display: flex;
  201. align-items: center;
  202. margin-bottom: 12px;
  203. label {
  204. font-weight: 500;
  205. color: #555;
  206. min-width: 100px;
  207. }
  208. span {
  209. color: #333;
  210. &.status-success {
  211. color: #52c41a;
  212. font-weight: 500;
  213. }
  214. }
  215. }
  216. }
  217. .radio-options {
  218. margin-bottom: 20px;
  219. .radio-group {
  220. display: flex;
  221. gap: 20px;
  222. .radio-label {
  223. display: flex;
  224. align-items: center;
  225. cursor: pointer;
  226. user-select: none;
  227. .radio-input {
  228. margin-right: 8px;
  229. cursor: pointer;
  230. }
  231. .radio-text {
  232. font-size: 14px;
  233. color: #333;
  234. }
  235. }
  236. }
  237. }
  238. .action-buttons {
  239. display: flex;
  240. gap: 12px;
  241. .btn {
  242. padding: 8px 16px;
  243. border-radius: 6px;
  244. border: none;
  245. cursor: pointer;
  246. font-size: 14px;
  247. transition: all 0.2s;
  248. &.btn-primary {
  249. background: #1890ff;
  250. color: white;
  251. &:hover {
  252. background: #40a9ff;
  253. }
  254. }
  255. &.btn-secondary {
  256. background: #f5f5f5;
  257. color: #333;
  258. border: 1px solid #d9d9d9;
  259. &:hover {
  260. background: #e6f7ff;
  261. border-color: #1890ff;
  262. }
  263. }
  264. }
  265. }
  266. }
  267. }
  268. }
  269. .data-table {
  270. padding: 20px;
  271. }
  272. </style>