Showing
3 changed files
with
196 additions
and
0 deletions
| ... | @@ -13,14 +13,19 @@ declare module '@vue/runtime-core' { | ... | @@ -13,14 +13,19 @@ declare module '@vue/runtime-core' { |
| 13 | RouterLink: typeof import('vue-router')['RouterLink'] | 13 | RouterLink: typeof import('vue-router')['RouterLink'] |
| 14 | RouterView: typeof import('vue-router')['RouterView'] | 14 | RouterView: typeof import('vue-router')['RouterView'] |
| 15 | VanButton: typeof import('vant/es')['Button'] | 15 | VanButton: typeof import('vant/es')['Button'] |
| 16 | + VanCellGroup: typeof import('vant/es')['CellGroup'] | ||
| 16 | VanCheckbox: typeof import('vant/es')['Checkbox'] | 17 | VanCheckbox: typeof import('vant/es')['Checkbox'] |
| 17 | VanCheckboxGroup: typeof import('vant/es')['CheckboxGroup'] | 18 | VanCheckboxGroup: typeof import('vant/es')['CheckboxGroup'] |
| 19 | + VanCol: typeof import('vant/es')['Col'] | ||
| 18 | VanDatePicker: typeof import('vant/es')['DatePicker'] | 20 | VanDatePicker: typeof import('vant/es')['DatePicker'] |
| 21 | + VanField: typeof import('vant/es')['Field'] | ||
| 22 | + VanForm: typeof import('vant/es')['Form'] | ||
| 19 | VanIcon: typeof import('vant/es')['Icon'] | 23 | VanIcon: typeof import('vant/es')['Icon'] |
| 20 | VanList: typeof import('vant/es')['List'] | 24 | VanList: typeof import('vant/es')['List'] |
| 21 | VanLoading: typeof import('vant/es')['Loading'] | 25 | VanLoading: typeof import('vant/es')['Loading'] |
| 22 | VanPicker: typeof import('vant/es')['Picker'] | 26 | VanPicker: typeof import('vant/es')['Picker'] |
| 23 | VanPopup: typeof import('vant/es')['Popup'] | 27 | VanPopup: typeof import('vant/es')['Popup'] |
| 28 | + VanRow: typeof import('vant/es')['Row'] | ||
| 24 | VanSwipe: typeof import('vant/es')['Swipe'] | 29 | VanSwipe: typeof import('vant/es')['Swipe'] |
| 25 | VanSwipeItem: typeof import('vant/es')['SwipeItem'] | 30 | VanSwipeItem: typeof import('vant/es')['SwipeItem'] |
| 26 | VanToast: typeof import('vant/es')['Toast'] | 31 | VanToast: typeof import('vant/es')['Toast'] | ... | ... |
| ... | @@ -118,4 +118,11 @@ export default [ | ... | @@ -118,4 +118,11 @@ export default [ |
| 118 | title: '我的', | 118 | title: '我的', |
| 119 | }, | 119 | }, |
| 120 | }, | 120 | }, |
| 121 | + { | ||
| 122 | + path: '/p_test', | ||
| 123 | + component: () => import('@/views/p_test.vue'), | ||
| 124 | + meta: { | ||
| 125 | + title: 'p_test', | ||
| 126 | + }, | ||
| 127 | + }, | ||
| 121 | ]; | 128 | ]; | ... | ... |
src/views/p_test.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div style="margin-top: 1rem;"> | ||
| 3 | + <van-form @submit="onSubmit"> | ||
| 4 | + <van-cell-group inset> | ||
| 5 | + <!-- <van-field | ||
| 6 | + v-model="openid" | ||
| 7 | + name="openid" | ||
| 8 | + label="openid" | ||
| 9 | + placeholder="openid" | ||
| 10 | + /> --> | ||
| 11 | + <van-field | ||
| 12 | + v-model="fieldValue" | ||
| 13 | + is-link | ||
| 14 | + readonly | ||
| 15 | + label="openid" | ||
| 16 | + placeholder="选择openid" | ||
| 17 | + @click="showPicker = true" | ||
| 18 | + /> | ||
| 19 | + <van-field | ||
| 20 | + v-model="count" | ||
| 21 | + name="count" | ||
| 22 | + label="count" | ||
| 23 | + placeholder="循环次数" | ||
| 24 | + /> | ||
| 25 | + <van-field | ||
| 26 | + v-model="offset" | ||
| 27 | + name="offset" | ||
| 28 | + label="offset" | ||
| 29 | + placeholder="起始值" | ||
| 30 | + /> | ||
| 31 | + </van-cell-group> | ||
| 32 | + <div style="margin: 16px;"> | ||
| 33 | + <van-row gutter="20"> | ||
| 34 | + <van-col span="12"> | ||
| 35 | + <van-button round block type="primary" native-type="submit"> | ||
| 36 | + 提交 | ||
| 37 | + </van-button> | ||
| 38 | + </van-col> | ||
| 39 | + <van-col span="12"> | ||
| 40 | + <van-button round block type="danger" @click="stop=true"> | ||
| 41 | + 终止 | ||
| 42 | + </van-button> | ||
| 43 | + </van-col> | ||
| 44 | + </van-row> | ||
| 45 | + </div> | ||
| 46 | + </van-form> | ||
| 47 | + <div style="padding: 1rem;"> | ||
| 48 | + <p>成功次数:{{ success_count }}</p> | ||
| 49 | + <div> | ||
| 50 | + <p>失败信息:</p> | ||
| 51 | + <p v-for="(item, index) in error_msg" :key="index">{{ item }}</p> | ||
| 52 | + </div> | ||
| 53 | + <div> | ||
| 54 | + <p>错误信息:</p> | ||
| 55 | + <p v-for="(item, index) in fail_msg" :key="index">{{ item }}</p> | ||
| 56 | + </div> | ||
| 57 | + </div> | ||
| 58 | + | ||
| 59 | + | ||
| 60 | + <van-popup v-model:show="showPicker" round position="bottom"> | ||
| 61 | + <van-picker | ||
| 62 | + :columns="columns" | ||
| 63 | + @cancel="showPicker = false" | ||
| 64 | + @confirm="onConfirm" | ||
| 65 | + /> | ||
| 66 | + </van-popup> | ||
| 67 | + </div> | ||
| 68 | +</template> | ||
| 69 | + | ||
| 70 | +<script setup> | ||
| 71 | +import { ref } from 'vue' | ||
| 72 | +import { useRoute, useRouter } from 'vue-router' | ||
| 73 | +import dayjs from 'dayjs'; | ||
| 74 | +import { Cookies, $, _, axios, storeToRefs, mainStore, Toast, useTitle } from '@/utils/generatePackage.js' | ||
| 75 | +//import { } from '@/utils/generateModules.js' | ||
| 76 | +//import { } from '@/utils/generateIcons.js' | ||
| 77 | +//import { } from '@/composables' | ||
| 78 | +const $route = useRoute(); | ||
| 79 | +const $router = useRouter(); | ||
| 80 | +useTitle($route.meta.title); | ||
| 81 | + | ||
| 82 | +const openid = ref(''); | ||
| 83 | +const count = ref(null); | ||
| 84 | +const offset = ref(0); | ||
| 85 | +const success_count = ref(0); | ||
| 86 | +const error_msg = ref([]); | ||
| 87 | +const fail_msg = ref([]); | ||
| 88 | +const stop = ref(false); | ||
| 89 | + | ||
| 90 | +watch( | ||
| 91 | + () => count.value, | ||
| 92 | + () => { | ||
| 93 | + if (!count.value) { | ||
| 94 | + console.warn('开始时间', dayjs().format('HH:mm:ss')); | ||
| 95 | + } | ||
| 96 | + } | ||
| 97 | +) | ||
| 98 | + | ||
| 99 | +const onSubmit = async () => { | ||
| 100 | + if (openid.value) { | ||
| 101 | + // for (let i = offset.value; count.value > 0; i--) { | ||
| 102 | + // count.value--; | ||
| 103 | + // offset.value++; | ||
| 104 | + // axios.get(`/srv/?a=no_auth_api&t=test_add_reserve&openid=${openid.value}&offset=${offset.value}`) | ||
| 105 | + // .then(res => { | ||
| 106 | + // if (res.data.code === 1) { | ||
| 107 | + // success_count.value++; | ||
| 108 | + // } else { | ||
| 109 | + // error_msg.value.push(res.data.msg); | ||
| 110 | + // } | ||
| 111 | + // }) | ||
| 112 | + // .catch(err => { | ||
| 113 | + // fail_msg.value.push(err); | ||
| 114 | + // }) | ||
| 115 | + // .finally(() => { // 最终执行 | ||
| 116 | + // }) | ||
| 117 | + // await sleep(1); // 等待1毫秒 | ||
| 118 | + // if (stop.value) { | ||
| 119 | + // break; | ||
| 120 | + // } | ||
| 121 | + // } | ||
| 122 | + // 定义并发请求的 URL 列表 | ||
| 123 | + const urls = [ | ||
| 124 | + ]; | ||
| 125 | + | ||
| 126 | + for (let i = offset.value; count.value > 0; i--) { | ||
| 127 | + count.value--; | ||
| 128 | + offset.value++; | ||
| 129 | + urls.push(`/srv/?a=no_auth_api&t=test_add_reserve&openid=${openid.value}&offset=${offset.value}`); | ||
| 130 | + await sleep(1); // 等待1毫秒 | ||
| 131 | + if (stop.value) { | ||
| 132 | + break; | ||
| 133 | + } | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + // 创建一个存储请求 Promise 的数组 | ||
| 137 | + const requests = urls.map(url => axios.get(url)); | ||
| 138 | + | ||
| 139 | + // 发送并发请求 | ||
| 140 | + Promise.all(requests) | ||
| 141 | + .then(responses => { | ||
| 142 | + // 处理所有请求的响应 | ||
| 143 | + responses.forEach(response => { | ||
| 144 | + if (response.data.code === 1) { | ||
| 145 | + success_count.value++; | ||
| 146 | + } else { | ||
| 147 | + error_msg.value.push(response.data.msg); | ||
| 148 | + } | ||
| 149 | + }); | ||
| 150 | + | ||
| 151 | + console.warn('结束时间', dayjs().format('HH:mm:ss')); | ||
| 152 | + }) | ||
| 153 | + .catch(error => { | ||
| 154 | + // 处理错误 | ||
| 155 | + console.log('请求出错:', error); | ||
| 156 | + }); | ||
| 157 | + } | ||
| 158 | +}; | ||
| 159 | + | ||
| 160 | +const sleep = (ms) => { | ||
| 161 | + return new Promise(resolve => setTimeout(resolve, ms)); | ||
| 162 | +} | ||
| 163 | + | ||
| 164 | +const columns = [ | ||
| 165 | + { text: '李琛', value: 'o5CsxuLo0afvJXB8xu6quygh4MPY' }, | ||
| 166 | + { text: '王鸿军', value: 'o5CsxuJLNcOYFPDDhO78q_jcIVQQ' }, | ||
| 167 | + { text: 'Doris', value: 'o5CsxuI7VnvA1df1_Z6fjKm5fAQw' }, | ||
| 168 | + { text: '胡一锐', value: 'o5CsxuF5AfUirRn4VUwaCSNZrUoM' }, | ||
| 169 | + { text: '王佳琪', value: 'o5CsxuPn6EZ6_IMeCWJuxamDls1Y' }, | ||
| 170 | + { text: '汪安军', value: 'o5CsxuEZkErN-51QKCb9r4LOCbtg' }, | ||
| 171 | +]; | ||
| 172 | +const showPicker = ref(false); | ||
| 173 | +const fieldValue = ref(''); | ||
| 174 | + | ||
| 175 | +const onConfirm = ({ selectedOptions }) => { | ||
| 176 | + showPicker.value = false; | ||
| 177 | + fieldValue.value = selectedOptions[0].text; | ||
| 178 | + openid.value = selectedOptions[0].value; | ||
| 179 | +}; | ||
| 180 | +</script> | ||
| 181 | + | ||
| 182 | +<style lang="less" scoped> | ||
| 183 | + | ||
| 184 | +</style> |
-
Please register or login to post a comment