Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
feat: some misc option
Browse files Browse the repository at this point in the history
  • Loading branch information
neko-para committed Aug 6, 2023
1 parent 8fe6b48 commit d8ef6b1
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const fastNavigate = computed<number>({
</div>
<div class="flex gap-2 flex-1 min-h-0">
<NCard
class="max-w-md min-h-0"
class="max-w-sm min-h-0"
content-style="max-height: 100%; display: flex; flex-direction: column"
>
<TaskTree v-model:expand="expands"></TaskTree>
Expand Down
135 changes: 135 additions & 0 deletions src/components/MiscEdit.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<script setup lang="ts">
import { NInput, NInputNumber, NSelect, NSwitch } from 'naive-ui'
import { computed } from 'vue'
import { type UseProducer, applyEditOn, updateEditOn } from '@/persis'
import type { Task } from '@/types'
import TargetEdit from './TargetEdit.vue'
import ArrayNavigateEdit from './task/ArrayNavigateEdit.vue'
import SingleStringEdit from '@/components/array/SingleStringEdit.vue'
import ClearButton from '@/components/atomic/ClearButton.vue'
import IntInput from '@/components/atomic/IntInput.vue'
const props = defineProps<{
value: Task
edit: UseProducer<Task>
}>()
</script>

<template>
<div
class="grid items-center"
style="
grid-template-columns: max-content minmax(0, 1fr);
column-gap: 0.5rem;
row-gap: 1rem;
"
>
<ClearButton :value="value.next ?? null" :edit="applyEditOn(edit, 'next')">
正常后续
</ClearButton>
<ArrayNavigateEdit
:value="value.next ?? null"
:edit="applyEditOn(edit, 'next')"
></ArrayNavigateEdit>
<ClearButton
:value="value.is_sub ?? null"
:edit="applyEditOn(edit, 'is_sub')"
>
子任务
</ClearButton>
<div>
<NSwitch
:value="value.is_sub ?? false"
@update:value="v => updateEditOn(edit, 'is_sub', v)"
></NSwitch>
</div>
<ClearButton
:value="value.timeout ?? null"
:edit="applyEditOn(edit, 'timeout')"
>
超时
</ClearButton>
<NInputNumber
:value="value.timeout ?? null"
@update:value="v => updateEditOn(edit, 'timeout', v)"
placeholder="20000"
:min="0"
>
<template #suffix>ms</template></NInputNumber
>
<ClearButton
:value="value.timeout_next ?? null"
:edit="applyEditOn(edit, 'timeout_next')"
>
超时后
</ClearButton>
<ArrayNavigateEdit
:value="value.timeout_next ?? null"
:edit="applyEditOn(edit, 'timeout_next')"
></ArrayNavigateEdit>
<ClearButton
:value="value.times_limit ?? null"
:edit="applyEditOn(edit, 'times_limit')"
>
次数
</ClearButton>
<NInputNumber
:value="value.times_limit ?? null"
@update:value="v => updateEditOn(edit, 'times_limit', v)"
placeholder="<UINT_MAX>"
:min="0"
></NInputNumber>
<ClearButton
:value="value.runout_next ?? null"
:edit="applyEditOn(edit, 'runout_next')"
>
超次数后
</ClearButton>
<ArrayNavigateEdit
:value="value.runout_next ?? null"
:edit="applyEditOn(edit, 'runout_next')"
></ArrayNavigateEdit>
<ClearButton
:value="value.pre_delay ?? null"
:edit="applyEditOn(edit, 'pre_delay')"
>
前延时
</ClearButton>
<NInputNumber
:value="value.pre_delay ?? null"
@update:value="v => updateEditOn(edit, 'pre_delay', v)"
placeholder="200"
:min="0"
>
<template #suffix>ms</template></NInputNumber
>
<ClearButton
:value="value.post_delay ?? null"
:edit="applyEditOn(edit, 'post_delay')"
>
后延时
</ClearButton>
<NInputNumber
:value="value.post_delay ?? null"
@update:value="v => updateEditOn(edit, 'post_delay', v)"
placeholder="500"
:min="0"
>
<template #suffix>ms</template>
</NInputNumber>
<ClearButton
:value="value.notify ?? null"
:edit="applyEditOn(edit, 'notify')"
>
触发回调
</ClearButton>
<div>
<NSwitch
:value="value.notify ?? false"
@update:value="v => updateEditOn(edit, 'notify', v)"
></NSwitch>
</div>
</div>
</template>
44 changes: 14 additions & 30 deletions src/components/TaskEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ import { computed, ref } from 'vue'
import { commitDelete, commitDuplicate, commitMove, navigate } from '@/data'
import { taskIndex } from '@/data/task'
import { Util } from '@/fs'
import { type UseProducer, applyEditOn } from '@/persis'
import { type Task } from '@/types'
import type { UseProducer } from '@/persis'
import type { Task } from '@/types'
import ActionEdit from './ActionEdit.vue'
import MiscEdit from './MiscEdit.vue'
import RecognizerEdit from './RecognizerEdit.vue'
import ClearButton from '@/components/atomic/ClearButton.vue'
import JsonEdit from '@/components/atomic/JsonEdit.vue'
import ArrayNavigateEdit from '@/components/task/ArrayNavigateEdit.vue'
import SingleNavigateEdit from '@/components/task/SingleNavigateEdit.vue'
const props = defineProps<{
Expand Down Expand Up @@ -189,8 +188,11 @@ function tryDelete() {
</template>
</NButton>
</div>
<div class="flex flex-col flex-1 overflow-auto">
<div class="flex gap-2">
<div class="flex flex-1 gap-2 min-h-0">
<div
class="flex flex-col flex-1 overflow-y-auto min-h-0"
style="min-width: 500px"
>
<NCollapse :default-expanded-names="['reco', 'act', 'misc']">
<NCollapseItem title="识别" name="reco">
<RecognizerEdit :value="value" :edit="edit"></RecognizerEdit>
Expand All @@ -199,33 +201,15 @@ function tryDelete() {
<ActionEdit :value="value" :edit="edit"></ActionEdit>
</NCollapseItem>
<NCollapseItem title="其他" name="misc">
<div
class="grid items-center"
style="
grid-template-columns: max-content minmax(0, 1fr);
column-gap: 0.5rem;
row-gap: 1rem;
"
>
<ClearButton
:value="value.next ?? null"
:edit="applyEditOn(edit, 'next')"
>
Next
</ClearButton>
<ArrayNavigateEdit
:value="value.next ?? null"
:edit="applyEditOn(edit, 'next')"
></ArrayNavigateEdit>
</div>
<MiscEdit :value="value" :edit="edit"></MiscEdit>
</NCollapseItem>
</NCollapse>
<JsonEdit
style="min-width: 28rem"
:value="value"
@update:value="v => edit(() => v)"
></JsonEdit>
</div>
<JsonEdit
style="min-width: 350px"
:value="value"
@update:value="v => edit(() => v)"
></JsonEdit>
</div>
</div>
</template>
5 changes: 4 additions & 1 deletion src/components/task/SingleNavigateEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import {
AdsClickOutlined,
MovingOutlined,
RepeatOutlined,
SwipeRightOutlined,
TranslateOutlined,
WavingHandOutlined
Expand Down Expand Up @@ -49,12 +50,14 @@ const options = computed(() => {
<template>
<div class="flex gap-2">
<NButton
v-if="navTask"
:disabled="!(value in taskIndex)"
@click="navigate(taskIndex[value])"
>
<template #icon>
<NIcon>
<MovingOutlined></MovingOutlined>
<RepeatOutlined v-if="navTask.is_sub"></RepeatOutlined>
<MovingOutlined v-else></MovingOutlined>
</NIcon>
</template>
</NButton>
Expand Down
4 changes: 2 additions & 2 deletions src/persis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ export function applyEditOn<T, K extends keyof T>(
export function updateEditOn<T, K extends keyof T>(
edit: UseProducer<T>,
key: K,
val: T[K]
val: T[K] | null
) {
edit(draft => {
if ((val ?? null) === null) {
delete draft[key]
} else {
draft[key] = val
draft[key] = val as T[K]
}
})
}
Expand Down

0 comments on commit d8ef6b1

Please sign in to comment.