filter
This commit is contained in:
1 parent
3082794436
commit
67d30a6f32
4 files changed
+16
-7
No files matched your search
+6
-2
@@ -1,13 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import { useEventSource } from '@vueuse/core'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { computed, onMounted, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useStatusStore } from '@/stores/status.ts'
|
||||
import { useIssueStore } from '@/stores/issue.ts'
|
||||
import { useProjectStore } from '@/stores/project.ts'
|
||||
|
||||
const route = useRoute()
|
||||
const issueStore = useIssueStore()
|
||||
const statusStore = useStatusStore()
|
||||
const projectStore = useProjectStore()
|
||||
const { currentProjectId } = storeToRefs(projectStore)
|
||||
|
||||
interface IssueSseEvent {
|
||||
type: string
|
||||
@@ -35,7 +39,7 @@ watch(data, () => {
|
||||
data.value?.type === 'issue.updated' ||
|
||||
data.value?.type === 'issue.deleted'
|
||||
) {
|
||||
issueStore.getStat()
|
||||
issueStore.getStat(currentProjectId.value)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -46,7 +50,7 @@ const layout = computed(() => {
|
||||
|
||||
onMounted(async () => {
|
||||
await statusStore.list()
|
||||
await issueStore.getStat()
|
||||
await issueStore.getStat(currentProjectId.value)
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ export async function itemDelete(id: number) {
|
||||
return true
|
||||
}
|
||||
|
||||
export async function itemStat() {
|
||||
return apiClient.get<IssueStat>('/api/issues/stats')
|
||||
export async function itemStat(projectId?: string) {
|
||||
const query = toQuery({ projectId: projectId })
|
||||
return apiClient.get<IssueStat>(`/api/issues/stats${query}`)
|
||||
}
|
||||
+2
-2
@@ -75,9 +75,9 @@ export const useIssueStore = defineStore('item', () => {
|
||||
}
|
||||
}
|
||||
|
||||
async function getStat(): Promise<IssueStat | undefined> {
|
||||
async function getStat(projectId?: string | null): Promise<IssueStat | undefined> {
|
||||
try {
|
||||
stats.value = await itemStat()
|
||||
stats.value = await itemStat(projectId ?? undefined)
|
||||
|
||||
return stats.value
|
||||
} catch (e) {
|
||||
|
||||
@@ -83,9 +83,13 @@ watch(currentProjectId, async () => {
|
||||
clearBatch()
|
||||
close()
|
||||
await load()
|
||||
await issueStore.getStat(currentProjectId.value)
|
||||
})
|
||||
|
||||
onMounted(async () => await load())
|
||||
onMounted(async () => {
|
||||
await load()
|
||||
await issueStore.getStat(currentProjectId.value)
|
||||
})
|
||||
const gridTemplate = computed(() => (selected.value.length ? '1fr 1fr' : '1fr'))
|
||||
const goToIssue = (key: string[]) => router.push(`/issues/${key[0]}`)
|
||||
|
||||
|
||||
Reference in new issue
Block a user