mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 15:36:49 +08:00
feat: 优化用户界面和交互提示
This commit is contained in:
@@ -24,7 +24,7 @@ const workflowForm = ref<Workflow>({
|
|||||||
// 提示框
|
// 提示框
|
||||||
const $toast = useToast()
|
const $toast = useToast()
|
||||||
|
|
||||||
// 调用API 新增工作流
|
// 调用API 新增任务
|
||||||
async function addWorkflow() {
|
async function addWorkflow() {
|
||||||
if (!workflowForm.value.name || !workflowForm.value.timer) {
|
if (!workflowForm.value.name || !workflowForm.value.timer) {
|
||||||
$toast.error('请填写完整信息!')
|
$toast.error('请填写完整信息!')
|
||||||
@@ -34,10 +34,10 @@ async function addWorkflow() {
|
|||||||
try {
|
try {
|
||||||
const result: { [key: string]: string } = await api.post('workflow/', workflowForm.value)
|
const result: { [key: string]: string } = await api.post('workflow/', workflowForm.value)
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
$toast.success('新增工作流成功,请编辑流程!')
|
$toast.success('新增任务成功,请编辑流程!')
|
||||||
emit('save')
|
emit('save')
|
||||||
} else {
|
} else {
|
||||||
$toast.error(`新增工作流失败:${result.message}`)
|
$toast.error(`新增任务失败:${result.message}`)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
@@ -48,7 +48,7 @@ async function addWorkflow() {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VDialog scrollable :close-on-back="false" persistent eager max-width="30rem" :fullscreen="!display.mdAndUp.value">
|
<VDialog scrollable :close-on-back="false" persistent eager max-width="30rem" :fullscreen="!display.mdAndUp.value">
|
||||||
<VCard title="新增工作流" class="rounded-t">
|
<VCard title="新建任务" class="rounded-t">
|
||||||
<DialogCloseBtn @click="emit('close')" />
|
<DialogCloseBtn @click="emit('close')" />
|
||||||
<VDivider />
|
<VDivider />
|
||||||
<VCardText>
|
<VCardText>
|
||||||
@@ -60,7 +60,7 @@ async function addWorkflow() {
|
|||||||
label="别名"
|
label="别名"
|
||||||
:rules="[requiredValidator]"
|
:rules="[requiredValidator]"
|
||||||
persistent-hint
|
persistent-hint
|
||||||
hint="工作流名称"
|
hint="任务名称"
|
||||||
/>
|
/>
|
||||||
</VCol>
|
</VCol>
|
||||||
<VCol cols="12">
|
<VCol cols="12">
|
||||||
@@ -70,11 +70,11 @@ async function addWorkflow() {
|
|||||||
:rules="[requiredValidator]"
|
:rules="[requiredValidator]"
|
||||||
placeholder="5位cron表达式"
|
placeholder="5位cron表达式"
|
||||||
persistent-hint
|
persistent-hint
|
||||||
hint="工作流执行周期"
|
hint="任务执行周期"
|
||||||
/>
|
/>
|
||||||
</VCol>
|
</VCol>
|
||||||
<VCol cols="12">
|
<VCol cols="12">
|
||||||
<VTextarea v-model="workflowForm.description" label="工作流描述" />
|
<VTextarea v-model="workflowForm.description" label="任务描述" />
|
||||||
</VCol>
|
</VCol>
|
||||||
</VRow>
|
</VRow>
|
||||||
</VForm>
|
</VForm>
|
||||||
|
|||||||
@@ -29,11 +29,16 @@ const emit = defineEmits(['close', 'save'])
|
|||||||
<!-- Toolbar -->
|
<!-- Toolbar -->
|
||||||
<div>
|
<div>
|
||||||
<VToolbar color="primary">
|
<VToolbar color="primary">
|
||||||
<VToolbarTitle>编辑工作流 - {{ workflow?.name }}</VToolbarTitle>
|
<VToolbarItems>
|
||||||
|
<VBtn icon @click="emit('close')" class="ms-3">
|
||||||
|
<VIcon size="large" color="white" icon="mdi-close" />
|
||||||
|
</VBtn>
|
||||||
|
</VToolbarItems>
|
||||||
|
<VToolbarTitle> 编辑流程 - {{ workflow?.name }} </VToolbarTitle>
|
||||||
<VSpacer />
|
<VSpacer />
|
||||||
<VToolbarItems>
|
<VToolbarItems>
|
||||||
<VBtn icon variant="plain" @click="emit('close')" class="me-3">
|
<VBtn icon @click="emit('save')" class="me-5">
|
||||||
<VIcon size="large" color="white" icon="ri-close-line" />
|
<VIcon size="large" color="white" icon="mdi-content-save" />
|
||||||
</VBtn>
|
</VBtn>
|
||||||
</VToolbarItems>
|
</VToolbarItems>
|
||||||
</VToolbar>
|
</VToolbar>
|
||||||
@@ -50,10 +55,10 @@ const emit = defineEmits(['close', 'save'])
|
|||||||
<p v-if="isDragOver">Drop here</p>
|
<p v-if="isDragOver">Drop here</p>
|
||||||
</DropzoneBackground>
|
</DropzoneBackground>
|
||||||
</VueFlow>
|
</VueFlow>
|
||||||
|
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
</div> </VCardText
|
</div>
|
||||||
></VCard>
|
</VCardText>
|
||||||
|
</VCard>
|
||||||
</VDialog>
|
</VDialog>
|
||||||
</template>
|
</template>
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
+1
-1
@@ -96,7 +96,7 @@ initializeApp().then(() => {
|
|||||||
.use(VuetifyUseDialog, {
|
.use(VuetifyUseDialog, {
|
||||||
confirmDialog: {
|
confirmDialog: {
|
||||||
dialogProps: {
|
dialogProps: {
|
||||||
maxWidth: '40rem',
|
maxWidth: '30rem',
|
||||||
},
|
},
|
||||||
confirmationButtonProps: {
|
confirmationButtonProps: {
|
||||||
variant: 'elevated',
|
variant: 'elevated',
|
||||||
|
|||||||
@@ -633,7 +633,9 @@ onMounted(fetchData)
|
|||||||
</template>
|
</template>
|
||||||
<template #no-data> 没有数据 </template>
|
<template #no-data> 没有数据 </template>
|
||||||
</VDataTableVirtual>
|
</VDataTableVirtual>
|
||||||
<div class="flex items-center justify-center">
|
<!-- 分页 -->
|
||||||
|
<VDivider />
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
<div class="w-auto">
|
<div class="w-auto">
|
||||||
<VSelect v-model="itemsPerPage" :items="pageRange" density="compact" variant="solo" flat />
|
<VSelect v-model="itemsPerPage" :items="pageRange" density="compact" variant="solo" flat />
|
||||||
</div>
|
</div>
|
||||||
@@ -642,6 +644,7 @@ onMounted(fetchData)
|
|||||||
v-model="currentPage"
|
v-model="currentPage"
|
||||||
show-first-last-page
|
show-first-last-page
|
||||||
:length="totalPage"
|
:length="totalPage"
|
||||||
|
:total-visible="display.mdAndUp.value ? 7 : 0"
|
||||||
@next="currentPage + 1"
|
@next="currentPage + 1"
|
||||||
@prev="currentPage - 1"
|
@prev="currentPage - 1"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -14,30 +14,37 @@ const appMode = inject('pwaMode') && display.mdAndDown.value
|
|||||||
// 是否刷新
|
// 是否刷新
|
||||||
const isRefreshed = ref(false)
|
const isRefreshed = ref(false)
|
||||||
|
|
||||||
|
// 过滤关键字
|
||||||
|
const filter = ref('')
|
||||||
|
|
||||||
// 新增对话框
|
// 新增对话框
|
||||||
const addDialog = ref(false)
|
const addDialog = ref(false)
|
||||||
|
|
||||||
// 流程编辑对话框
|
// 流程编辑对话框
|
||||||
const editDialog = ref(false)
|
const editDialog = ref(false)
|
||||||
|
|
||||||
// 所有工作流
|
// 所有任务
|
||||||
const workflowList = ref<Workflow[]>([])
|
const workflowList = ref<Workflow[]>([])
|
||||||
|
|
||||||
// 当前编辑工作流
|
// 当前编辑任务
|
||||||
const currentWorkflow = ref<Workflow>()
|
const currentWorkflow = ref<Workflow>()
|
||||||
|
|
||||||
const options = ref({ page: 1, itemsPerPage: 25, sortBy: [''], sortDesc: [false] })
|
|
||||||
|
|
||||||
// headers
|
// headers
|
||||||
const headers = [
|
const headers = [
|
||||||
{ title: '名称', key: 'name' },
|
{ title: '任务', key: 'name' },
|
||||||
{ title: '定时', key: 'timer' },
|
{ title: '定时', key: 'timer' },
|
||||||
{ title: '当前任务', key: 'current_action' },
|
|
||||||
{ title: '状态', key: 'state' },
|
{ title: '状态', key: 'state' },
|
||||||
{ title: '进度', key: 'progress' },
|
{ title: '进度', key: 'progress' },
|
||||||
{ title: '', key: 'action' },
|
{ title: '操作', key: 'action' },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// 表格样式
|
||||||
|
const tableStyle = computed(() => {
|
||||||
|
return appMode
|
||||||
|
? 'height: calc(100vh - 12.5rem - env(safe-area-inset-bottom)'
|
||||||
|
: 'height: calc(100vh - 11.5rem - env(safe-area-inset-bottom)'
|
||||||
|
})
|
||||||
|
|
||||||
// 提示框
|
// 提示框
|
||||||
const $toast = useToast()
|
const $toast = useToast()
|
||||||
|
|
||||||
@@ -54,17 +61,17 @@ async function fetchData() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 编辑工作流
|
// 编辑任务
|
||||||
function handleEdit(item: Workflow) {
|
function handleEdit(item: Workflow) {
|
||||||
currentWorkflow.value = item
|
currentWorkflow.value = item
|
||||||
editDialog.value = true
|
editDialog.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除工作流
|
// 删除任务
|
||||||
async function handleDelete(item: Workflow) {
|
async function handleDelete(item: Workflow) {
|
||||||
const isConfirmed = await createConfirm({
|
const isConfirmed = await createConfirm({
|
||||||
title: '确认',
|
title: '确认',
|
||||||
content: `是否确认删除工作流 ${item.name} ?`,
|
content: `是否确认删除任务 ${item.name} ?`,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!isConfirmed) return
|
if (!isConfirmed) return
|
||||||
@@ -72,55 +79,55 @@ async function handleDelete(item: Workflow) {
|
|||||||
try {
|
try {
|
||||||
const result: { [key: string]: string } = await api.delete(`workflow/${item.id}`)
|
const result: { [key: string]: string } = await api.delete(`workflow/${item.id}`)
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
$toast.success('删除工作流成功!')
|
$toast.success('删除任务成功!')
|
||||||
fetchData()
|
fetchData()
|
||||||
} else {
|
} else {
|
||||||
$toast.error(`删除工作流失败:${result.message}`)
|
$toast.error(`删除任务失败:${result.message}`)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 开始工作流
|
// 开始任务
|
||||||
async function handleEnable(item: Workflow) {
|
async function handleEnable(item: Workflow) {
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: string } = await api.post(`workflow/${item.id}/start`)
|
const result: { [key: string]: string } = await api.post(`workflow/${item.id}/start`)
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
$toast.success('启用工作流成功!')
|
$toast.success('启用任务成功!')
|
||||||
fetchData()
|
fetchData()
|
||||||
} else {
|
} else {
|
||||||
$toast.error(`启用工作流失败:${result.message}`)
|
$toast.error(`启用任务失败:${result.message}`)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 停用工作流
|
// 停用任务
|
||||||
async function handlePause(item: Workflow) {
|
async function handlePause(item: Workflow) {
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: string } = await api.post(`workflow/${item.id}/pause`)
|
const result: { [key: string]: string } = await api.post(`workflow/${item.id}/pause`)
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
$toast.success('停用工作流成功!')
|
$toast.success('停用任务成功!')
|
||||||
fetchData()
|
fetchData()
|
||||||
} else {
|
} else {
|
||||||
$toast.error(`停用工作流失败:${result.message}`)
|
$toast.error(`停用任务失败:${result.message}`)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 立即执行工作流
|
// 立即执行任务
|
||||||
async function handleRun(item: Workflow) {
|
async function handleRun(item: Workflow) {
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: string } = await api.post(`workflow/${item.id}/run`)
|
const result: { [key: string]: string } = await api.post(`workflow/${item.id}/run`)
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
$toast.success('立即执行工作流成功!')
|
$toast.success('任务执行成功!')
|
||||||
fetchData()
|
fetchData()
|
||||||
} else {
|
} else {
|
||||||
$toast.error(`立即执行工作流失败:${result.message}`)
|
$toast.error(`任务执行失败:${result.message}`)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
@@ -142,13 +149,13 @@ const resolveProgress = (item: Workflow) => {
|
|||||||
return item.actions?.length ? Math.round((current_action_index / item.actions.length) * 100) : 0
|
return item.actions?.length ? Math.round((current_action_index / item.actions.length) * 100) : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增工作流成功
|
// 新增任务成功
|
||||||
const addDone = () => {
|
const addDone = () => {
|
||||||
addDialog.value = false
|
addDialog.value = false
|
||||||
fetchData()
|
fetchData()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改工作流成功
|
// 修改任务成功
|
||||||
const editDone = () => {
|
const editDone = () => {
|
||||||
editDialog.value = false
|
editDialog.value = false
|
||||||
fetchData()
|
fetchData()
|
||||||
@@ -170,6 +177,7 @@ onActivated(() => {
|
|||||||
<VCardTitle> 工作流 </VCardTitle>
|
<VCardTitle> 工作流 </VCardTitle>
|
||||||
<VSpacer />
|
<VSpacer />
|
||||||
<VCombobox
|
<VCombobox
|
||||||
|
v-model="filter"
|
||||||
max-width="300"
|
max-width="300"
|
||||||
key="search_navbar"
|
key="search_navbar"
|
||||||
class="text-disabled"
|
class="text-disabled"
|
||||||
@@ -188,22 +196,24 @@ onActivated(() => {
|
|||||||
<VDataTable
|
<VDataTable
|
||||||
:headers="headers"
|
:headers="headers"
|
||||||
:items="workflowList"
|
:items="workflowList"
|
||||||
:items-per-page="options.itemsPerPage"
|
:items-per-page="1000"
|
||||||
:page="options.page"
|
|
||||||
:options="options"
|
|
||||||
loading-text="加载中..."
|
loading-text="加载中..."
|
||||||
class="text-no-wrap"
|
class="text-no-wrap"
|
||||||
hover
|
hover
|
||||||
|
fixed-header
|
||||||
|
hide-default-footer
|
||||||
|
:style="tableStyle"
|
||||||
|
:search="filter"
|
||||||
>
|
>
|
||||||
<!-- name -->
|
<!-- name -->
|
||||||
<template #item.name="{ item }">
|
<template #item.name="{ item }">
|
||||||
<div class="d-flex align-center">
|
<div class="d-flex align-center">
|
||||||
<VAvatar size="32" color="primary" class="v-avatar-light-bg primary--text" variant="tonal">
|
<VAvatar size="32" color="primary" variant="tonal">
|
||||||
<span class="text-sm">{{ item.actions?.length }}</span>
|
<span class="text-sm">{{ item.actions?.length }}</span>
|
||||||
</VAvatar>
|
</VAvatar>
|
||||||
<div class="d-flex flex-column ms-3">
|
<div class="d-flex flex-column ms-3">
|
||||||
<span class="d-block font-weight-medium text-high-emphasis text-truncate">{{ item.name }}</span>
|
<span class="d-block text-base text-high-emphasis text-truncate">{{ item.name }}</span>
|
||||||
<small>{{ item.description }}</small>
|
<span class="text-sm">{{ item.description }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -240,25 +250,6 @@ onActivated(() => {
|
|||||||
<VIcon color="error" icon="mdi-delete" @click="handleDelete(item)" />
|
<VIcon color="error" icon="mdi-delete" @click="handleDelete(item)" />
|
||||||
</IconBtn>
|
</IconBtn>
|
||||||
</template>
|
</template>
|
||||||
<template #bottom>
|
|
||||||
<VCardText class="pt-2">
|
|
||||||
<div class="d-flex flex-wrap justify-space-between gap-y-2 mt-2">
|
|
||||||
<VSelect
|
|
||||||
v-model="options.itemsPerPage"
|
|
||||||
:items="[10, 25, 50, 100]"
|
|
||||||
label="每页条数:"
|
|
||||||
variant="underlined"
|
|
||||||
max-width="5rem"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<VPagination
|
|
||||||
v-model="options.page"
|
|
||||||
:total-visible="$vuetify.display.smAndDown ? 2 : 3"
|
|
||||||
:length="Math.ceil(workflowList.length / options.itemsPerPage)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</VCardText>
|
|
||||||
</template>
|
|
||||||
<template #no-data> 没有数据 </template>
|
<template #no-data> 没有数据 </template>
|
||||||
</VDataTable>
|
</VDataTable>
|
||||||
</VCard>
|
</VCard>
|
||||||
@@ -285,3 +276,8 @@ onActivated(() => {
|
|||||||
<!-- 新增对话框 -->
|
<!-- 新增对话框 -->
|
||||||
<WorkflowAddDialog v-if="addDialog" v-model="addDialog" @close="addDialog = false" @save="addDone" />
|
<WorkflowAddDialog v-if="addDialog" v-model="addDialog" @close="addDialog = false" @save="addDone" />
|
||||||
</template>
|
</template>
|
||||||
|
<style lang="scss">
|
||||||
|
.v-table th {
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user