Skip to content

Commit c37d557

Browse files
authored
Merge pull request #27 from rustfs/refactor/unified-task-manager
refactor: unify upload and delete task management
2 parents 379e36e + 58832df commit c37d557

27 files changed

Lines changed: 3397 additions & 5141 deletions

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ coverage
1010
.github
1111
.specify
1212
auto-imports.d.ts
13-
components.d.ts
13+
components.d.ts
14+
pnpm-lock.yaml

AGENTS.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,39 @@
1616
- `pnpm vue-tsc --noEmit` – perform a strict type check.
1717
- `pnpm lint` – run `vue-tsc` and Prettier (format check only).
1818

19+
## Mandatory Code Quality Checks
20+
21+
**⚠️ CRITICAL: These checks MUST pass before every commit.**
22+
23+
Before committing any code changes, you MUST run and pass:
24+
25+
1. **Lockfile Sync Check**: `pnpm install --frozen-lockfile`
26+
- Ensures `pnpm-lock.yaml` is in sync with `package.json`
27+
- **MUST run `pnpm install` after modifying `package.json` and commit the updated `pnpm-lock.yaml`**
28+
- CI will fail if lockfile is out of sync
29+
30+
2. **TypeScript Type Check**: `pnpm vue-tsc --noEmit`
31+
- Ensures all TypeScript types are correct
32+
- Must have zero errors before committing
33+
34+
3. **Prettier Format Check**: `pnpm prettier --check .`
35+
- Ensures all code follows formatting standards
36+
- If it fails, run `pnpm lint:fix` to auto-fix formatting issues
37+
38+
**Automated Enforcement**: The pre-commit hook (`scripts/pre-commit-check.sh`) automatically runs these checks. If any check fails, the commit will be blocked.
39+
40+
**Quick Fix Command**: If checks fail:
41+
42+
1. Run `pnpm install` to sync lockfile (if package.json changed)
43+
2. Run `pnpm lint:fix` to auto-fix formatting
44+
3. Address any TypeScript errors manually
45+
1946
## Coding Style & Naming Conventions
2047

2148
- Use Prettier defaults (see `.prettierrc.ts`); run `pnpm lint` or `pnpm lint:fix`.
2249
- **Always run `pnpm run lint:fix` after making code changes to ensure formatting compliance before committing.**
2350
- Vue files use `<script setup>` with TypeScript; prefer composables for shared logic.
24-
- Component files use **kebab-case** (e.g. `bucket-selector.vue`), but reference them using **StudlyCase** in templates (e.g. `<BucketSelector />`).
51+
- Component files use **kebab-case** (e.g. `bucket-selector.vue`), but reference them using **StudlyCase** in templates (e.g., `<BucketSelector />`).
2552
- Override shadcn primitives **outside** `components/ui/`; never edit files in that directory directly.
2653
- Render tabular data with the shared `DataTable` + `useDataTable` utilities unless a specific requirement makes them unsuitable.
2754
- Language pack files should exclude test directories when processing translation keys.

CLAUDE.md

Lines changed: 0 additions & 145 deletions
This file was deleted.

components/object/delete/stats.vue

Lines changed: 0 additions & 19 deletions
This file was deleted.

components/object/delete/task/item.vue

Lines changed: 0 additions & 38 deletions
This file was deleted.

components/object/delete/task/list.vue

Lines changed: 0 additions & 15 deletions
This file was deleted.

components/object/list.vue

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
</label>
1010
</div>
1111
<template #actions>
12-
<object-upload-stats />
13-
<object-delete-stats />
12+
<object-task-stats :tasks="taskStore.tasks" :on-clear-tasks="taskStore.clearTasks">
13+
<template #task-list="{ tasks }">
14+
<object-task-list :tasks="tasks" />
15+
</template>
16+
</object-task-stats>
1417
<!-- <Button variant="outline" @click="() => handleNewObject(true)">
1518
<Icon name="ri:add-line" class="size-4" />
1619
<span>{{ t('New Folder') }}</span>
@@ -102,9 +105,8 @@ import { saveAs } from 'file-saver'
102105
import JSZip from 'jszip'
103106
import { joinRelativeURL } from 'ufo'
104107
import type { VNode } from 'vue'
105-
import { computed, h, ref, watch } from 'vue'
106-
import { useDeleteTaskManagerStore } from '~/store/delete-tasks'
107-
import { useUploadTaskManagerStore } from '~/store/upload-tasks'
108+
import { computed, h, onMounted, onUnmounted, ref, watch } from 'vue'
109+
import { useTaskManagerStore } from '~/store/tasks'
108110
109111
const { $s3Client } = useNuxtApp()
110112
const { t } = useI18n()
@@ -139,8 +141,7 @@ watch(searchTerm, () => {
139141
handleSearch()
140142
})
141143
142-
const uploadTaskStore = useUploadTaskManagerStore()
143-
const deleteTaskStore = useDeleteTaskManagerStore()
144+
const taskStore = useTaskManagerStore()
144145
145146
type ObjectRow = {
146147
Key: string
@@ -352,17 +353,22 @@ const { table, selectedRowIds } = useDataTable<ObjectRow>({
352353
// Use selectedRowIds from data-table instead of manually maintaining checkedKeys
353354
const checkedKeys = computed(() => selectedRowIds.value)
354355
355-
watch(
356-
() => uploadTaskStore.tasks,
357-
() => setTimeout(() => refresh(), 500),
358-
{ deep: true }
359-
)
356+
// 监听任务完成事件,只在所有任务完成时刷新列表
357+
// 这样可以避免在上传/删除大量文件时频繁刷新
358+
// 保存事件处理函数引用,以便在卸载时正确清理
359+
const handleAllTasksCompleted = () => {
360+
refresh()
361+
}
360362
361-
watch(
362-
() => deleteTaskStore.tasks,
363-
() => setTimeout(() => refresh(), 500),
364-
{ deep: true }
365-
)
363+
onMounted(() => {
364+
// 监听所有任务全部完成事件(上传/删除)
365+
taskStore.on('drained', handleAllTasksCompleted)
366+
})
367+
368+
onUnmounted(() => {
369+
// 清理事件监听器
370+
taskStore.off('drained', handleAllTasksCompleted)
371+
})
366372
367373
const goToNextPage = () => {
368374
if (!nextToken.value) return
@@ -518,7 +524,7 @@ const handleDelete = async (keys: string[]) => {
518524
if (!targets.length) {
519525
message.success(t('Delete Success'))
520526
} else {
521-
deleteTaskStore.addKeys(targets, bucketName.value)
527+
taskStore.addDeleteKeys(targets, bucketName.value)
522528
message.success(t('Delete task created'))
523529
}
524530
table.resetRowSelection()

0 commit comments

Comments
 (0)