Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
xysBooking
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2024-01-30 14:47:40 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9c63013c98d54b6c53493b06a5ab4e41f2c9c738
9c63013c
1 parent
f1ce43f9
测试页面
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
196 additions
and
0 deletions
components.d.ts
src/route.js
src/views/p_test.vue
components.d.ts
View file @
9c63013
...
...
@@ -13,14 +13,19 @@ declare module '@vue/runtime-core' {
RouterLink
:
typeof
import
(
'vue-router'
)[
'RouterLink'
]
RouterView
:
typeof
import
(
'vue-router'
)[
'RouterView'
]
VanButton
:
typeof
import
(
'vant/es'
)[
'Button'
]
VanCellGroup
:
typeof
import
(
'vant/es'
)[
'CellGroup'
]
VanCheckbox
:
typeof
import
(
'vant/es'
)[
'Checkbox'
]
VanCheckboxGroup
:
typeof
import
(
'vant/es'
)[
'CheckboxGroup'
]
VanCol
:
typeof
import
(
'vant/es'
)[
'Col'
]
VanDatePicker
:
typeof
import
(
'vant/es'
)[
'DatePicker'
]
VanField
:
typeof
import
(
'vant/es'
)[
'Field'
]
VanForm
:
typeof
import
(
'vant/es'
)[
'Form'
]
VanIcon
:
typeof
import
(
'vant/es'
)[
'Icon'
]
VanList
:
typeof
import
(
'vant/es'
)[
'List'
]
VanLoading
:
typeof
import
(
'vant/es'
)[
'Loading'
]
VanPicker
:
typeof
import
(
'vant/es'
)[
'Picker'
]
VanPopup
:
typeof
import
(
'vant/es'
)[
'Popup'
]
VanRow
:
typeof
import
(
'vant/es'
)[
'Row'
]
VanSwipe
:
typeof
import
(
'vant/es'
)[
'Swipe'
]
VanSwipeItem
:
typeof
import
(
'vant/es'
)[
'SwipeItem'
]
VanToast
:
typeof
import
(
'vant/es'
)[
'Toast'
]
...
...
src/route.js
View file @
9c63013
...
...
@@ -118,4 +118,11 @@ export default [
title
:
'我的'
,
},
},
{
path
:
'/p_test'
,
component
:
()
=>
import
(
'@/views/p_test.vue'
),
meta
:
{
title
:
'p_test'
,
},
},
];
...
...
src/views/p_test.vue
0 → 100644
View file @
9c63013
<template>
<div style="margin-top: 1rem;">
<van-form @submit="onSubmit">
<van-cell-group inset>
<!-- <van-field
v-model="openid"
name="openid"
label="openid"
placeholder="openid"
/> -->
<van-field
v-model="fieldValue"
is-link
readonly
label="openid"
placeholder="选择openid"
@click="showPicker = true"
/>
<van-field
v-model="count"
name="count"
label="count"
placeholder="循环次数"
/>
<van-field
v-model="offset"
name="offset"
label="offset"
placeholder="起始值"
/>
</van-cell-group>
<div style="margin: 16px;">
<van-row gutter="20">
<van-col span="12">
<van-button round block type="primary" native-type="submit">
提交
</van-button>
</van-col>
<van-col span="12">
<van-button round block type="danger" @click="stop=true">
终止
</van-button>
</van-col>
</van-row>
</div>
</van-form>
<div style="padding: 1rem;">
<p>成功次数:{{ success_count }}</p>
<div>
<p>失败信息:</p>
<p v-for="(item, index) in error_msg" :key="index">{{ item }}</p>
</div>
<div>
<p>错误信息:</p>
<p v-for="(item, index) in fail_msg" :key="index">{{ item }}</p>
</div>
</div>
<van-popup v-model:show="showPicker" round position="bottom">
<van-picker
:columns="columns"
@cancel="showPicker = false"
@confirm="onConfirm"
/>
</van-popup>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import dayjs from 'dayjs';
import { Cookies, $, _, axios, storeToRefs, mainStore, Toast, useTitle } from '@/utils/generatePackage.js'
//import { } from '@/utils/generateModules.js'
//import { } from '@/utils/generateIcons.js'
//import { } from '@/composables'
const $route = useRoute();
const $router = useRouter();
useTitle($route.meta.title);
const openid = ref('');
const count = ref(null);
const offset = ref(0);
const success_count = ref(0);
const error_msg = ref([]);
const fail_msg = ref([]);
const stop = ref(false);
watch(
() => count.value,
() => {
if (!count.value) {
console.warn('开始时间', dayjs().format('HH:mm:ss'));
}
}
)
const onSubmit = async () => {
if (openid.value) {
// for (let i = offset.value; count.value > 0; i--) {
// count.value--;
// offset.value++;
// axios.get(`/srv/?a=no_auth_api&t=test_add_reserve&openid=${openid.value}&offset=${offset.value}`)
// .then(res => {
// if (res.data.code === 1) {
// success_count.value++;
// } else {
// error_msg.value.push(res.data.msg);
// }
// })
// .catch(err => {
// fail_msg.value.push(err);
// })
// .finally(() => { // 最终执行
// })
// await sleep(1); // 等待1毫秒
// if (stop.value) {
// break;
// }
// }
// 定义并发请求的 URL 列表
const urls = [
];
for (let i = offset.value; count.value > 0; i--) {
count.value--;
offset.value++;
urls.push(`/srv/?a=no_auth_api&t=test_add_reserve&openid=${openid.value}&offset=${offset.value}`);
await sleep(1); // 等待1毫秒
if (stop.value) {
break;
}
}
// 创建一个存储请求 Promise 的数组
const requests = urls.map(url => axios.get(url));
// 发送并发请求
Promise.all(requests)
.then(responses => {
// 处理所有请求的响应
responses.forEach(response => {
if (response.data.code === 1) {
success_count.value++;
} else {
error_msg.value.push(response.data.msg);
}
});
console.warn('结束时间', dayjs().format('HH:mm:ss'));
})
.catch(error => {
// 处理错误
console.log('请求出错:', error);
});
}
};
const sleep = (ms) => {
return new Promise(resolve => setTimeout(resolve, ms));
}
const columns = [
{ text: '李琛', value: 'o5CsxuLo0afvJXB8xu6quygh4MPY' },
{ text: '王鸿军', value: 'o5CsxuJLNcOYFPDDhO78q_jcIVQQ' },
{ text: 'Doris', value: 'o5CsxuI7VnvA1df1_Z6fjKm5fAQw' },
{ text: '胡一锐', value: 'o5CsxuF5AfUirRn4VUwaCSNZrUoM' },
{ text: '王佳琪', value: 'o5CsxuPn6EZ6_IMeCWJuxamDls1Y' },
{ text: '汪安军', value: 'o5CsxuEZkErN-51QKCb9r4LOCbtg' },
];
const showPicker = ref(false);
const fieldValue = ref('');
const onConfirm = ({ selectedOptions }) => {
showPicker.value = false;
fieldValue.value = selectedOptions[0].text;
openid.value = selectedOptions[0].value;
};
</script>
<style lang="less" scoped>
</style>
Please
register
or
login
to post a comment