TaskPage.vue
2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<script setup>
import { onMounted, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { useRoute, useRouter } from 'vue-router'
import { Badge, Card } from '@drama/ui'
import { api, getToken } from '../api.js'
const { t } = useI18n()
const route = useRoute()
const router = useRouter()
const detail = ref(null)
const error = ref('')
const when = (/** @type {string} */ iso) => new Date(iso).toLocaleString()
onMounted(async () => {
if (getToken() === null) {
await router.push({ path: '/login', query: { next: route.fullPath } })
return
}
try {
detail.value = await api('GET', `/api/voko/agents/${route.params.id}/tasks/${route.params.taskId}`)
} catch (err) {
error.value = err instanceof Error ? err.message : String(err)
}
})
</script>
<template>
<p><router-link :to="`/agents/${route.params.id}/board`">{{ t('task.back') }}</router-link></p>
<p v-if="error" role="alert">{{ error }}</p>
<template v-if="detail">
<h1>{{ detail.task.title }} <Badge>{{ t(`board.status.${detail.task.status}`) }}</Badge></h1>
<p>{{ t(`board.templates.${detail.task.template}`) }} · {{ t('board.reward', { reward: detail.task.reward }) }} · {{ t('board.rarity', { rarity: detail.task.rarity }) }} · {{ t('board.deadline', { deadline: when(detail.task.deadline) }) }}</p>
<Card class="voko-section">
<p class="voko-pre">{{ detail.task.spec }}</p>
<h2>{{ t('task.acceptance') }}</h2>
<ol><li v-for="item in detail.acceptance" :key="item.id">{{ item.text }}</li></ol>
</Card>
<Card class="voko-section">
<h2>{{ t('task.checkpoints') }}</h2>
<p v-if="detail.checkpoints.length === 0">{{ t('task.none') }}</p>
<p v-for="item in detail.checkpoints" :key="item.id">{{ when(item.created_at) }} · {{ item.progress }}% · {{ item.note }}</p>
</Card>
<Card class="voko-section">
<h2>{{ t('task.submissions') }}</h2>
<p v-if="detail.submissions.length === 0">{{ t('task.noSubmissions') }}</p>
<div v-for="item in detail.submissions" :key="item.id">
<p>{{ t('task.round', { round: item.round }) }} · {{ when(item.created_at) }}</p>
<p class="voko-pre">{{ item.summary }}</p>
<ul><li v-for="artifact in item.artifacts" :key="artifact.url"><a :href="artifact.url" rel="noopener noreferrer" target="_blank">{{ artifact.note || artifact.url }}</a></li></ul>
</div>
</Card>
<Card class="voko-section">
<h2>{{ t('task.comments') }}</h2>
<p v-if="detail.comments.length === 0">{{ t('task.none') }}</p>
<p v-for="item in detail.comments" :key="item.id" class="voko-pre">{{ when(item.created_at) }} · {{ item.body }}</p>
</Card>
</template>
</template>
<style scoped>
.voko-section {
margin-bottom: var(--drama-space-md);
}
.voko-pre {
white-space: pre-wrap;
}
</style>