Skip to content

Commit 760c7f0

Browse files
committed
feat: 支持使用 query 参数 concurrency 设置并发数, <=0 则为清除自定义设置, 默认为 3. 若因并发导致爆内存, 可设为 1
1 parent b107636 commit 760c7f0

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store-front-end",
3-
"version": "2.15.82",
3+
"version": "2.15.83",
44
"private": true,
55
"scripts": {
66
"dev": "vite --host",

src/hooks/useHostAPI.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,25 @@ export const useHostAPI = () => {
148148
return false; // 没有URL参数,返回false
149149
}
150150

151+
// 处理 concurrency 参数
152+
const concurrency = query
153+
.slice(1)
154+
.split('&')
155+
.map(i => i.split('='))
156+
.find(i => i[0] === 'concurrency');
157+
if (concurrency) {
158+
const value = parseInt(concurrency[1], 10);
159+
if (!isNaN(value)) {
160+
if (value >= 1) {
161+
console.log(`设置并发数 ${value}`)
162+
localStorage.setItem('concurrency', value.toString());
163+
} else {
164+
console.log(`清除并发数设置`)
165+
localStorage.removeItem('concurrency');
166+
}
167+
}
168+
}
169+
151170
// 处理api参数
152171
const apiUrl = query
153172
.slice(1)

src/store/subs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ export const useSubsStore = defineStore('subsStore', {
309309

310310
await executeAsyncTasks(
311311
flowsUrlList.map((item, index) => () => asyncGetFlow(item, index)),
312-
{ concurrency: 3 }
312+
{ concurrency: localStorage.getItem('concurrency') ? parseInt(localStorage.getItem('concurrency') as string, 10) : 3 }
313313
)
314314

315315
// const batches = [];

0 commit comments

Comments
 (0)