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

Commit

Permalink
feat: finish options
Browse files Browse the repository at this point in the history
  • Loading branch information
neko-para committed Aug 6, 2023
1 parent d8ef6b1 commit 8c38a23
Show file tree
Hide file tree
Showing 12 changed files with 195 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/components/ActionEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { computed } from 'vue'
import { type UseProducer, applyEditOn, updateEditOn } from '@/persis'
import type { Task } from '@/types'
import TargetEdit from './TargetEdit.vue'
import SingleStringEdit from '@/components/array/SingleStringEdit.vue'
import ClearButton from '@/components/atomic/ClearButton.vue'
import JsonEdit from '@/components/atomic/JsonEdit.vue'
import TargetEdit from '@/components/task/TargetEdit.vue'
const props = defineProps<{
value: Task
Expand Down
23 changes: 23 additions & 0 deletions src/components/MiscEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ 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'
import FreezeEdit from '@/components/task/FreezeEdit.vue'
const props = defineProps<{
value: Task
Expand Down Expand Up @@ -119,6 +120,28 @@ const props = defineProps<{
>
<template #suffix>ms</template>
</NInputNumber>
<ClearButton
:value="value.pre_wait_freezes ?? null"
:edit="applyEditOn(edit, 'pre_wait_freezes')"
>
前静止等待
</ClearButton>
<FreezeEdit
:value="value.pre_wait_freezes ?? null"
:edit="applyEditOn(edit, 'pre_wait_freezes')"
>
</FreezeEdit>
<ClearButton
:value="value.post_wait_freezes ?? null"
:edit="applyEditOn(edit, 'post_wait_freezes')"
>
后静止等待
</ClearButton>
<FreezeEdit
:value="value.post_wait_freezes ?? null"
:edit="applyEditOn(edit, 'post_wait_freezes')"
>
</FreezeEdit>
<ClearButton
:value="value.notify ?? null"
:edit="applyEditOn(edit, 'notify')"
Expand Down
2 changes: 1 addition & 1 deletion src/components/TaskEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function tryDelete() {
</NCollapse>
</div>
<JsonEdit
style="min-width: 350px"
style="width: 400px"
:value="value"
@update:value="v => edit(() => v)"
></JsonEdit>
Expand Down
7 changes: 5 additions & 2 deletions src/components/TemplateEdit.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<script setup lang="ts">
import { DataArrayOutlined } from '@vicons/material'
import { computed, watch } from 'vue'
import { type UseProducer, updateEdit } from '@/persis'
import ArrayEdit from '@/components/array/ArrayEdit.vue'
import SwitchButton from '@/components/array/SwitchButton.vue'
import ClearButton from '@/components/atomic/ClearButton.vue'
import FloatInput from '@/components/atomic/FloatInput.vue'
import ImageHover from '@/components/atomic/ImageHover.vue'
import SwitchButton from '@/components/atomic/SwitchButton.vue'
import SingleTemplateEdit from '@/components/task/SingleTemplateEdit.vue'
type TTemp = string | string[] | null
Expand Down Expand Up @@ -127,7 +128,9 @@ const fixThre = (v: number) => {
<SwitchButton
v-model:value="thresholdSingle"
:disabled="isTemplateSingle"
></SwitchButton>
>
<DataArrayOutlined></DataArrayOutlined>
</SwitchButton>
</div>
<FloatInput
v-if="isThresholdSingle"
Expand Down
31 changes: 11 additions & 20 deletions src/components/array/ArrayEdit.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<script setup lang="ts" generic="T">
import { AddOutlined, DeleteOutlined } from '@vicons/material'
import {
AddOutlined,
DataArrayOutlined,
DeleteOutlined
} from '@vicons/material'
import { produce } from 'immer'
import { NButton, NIcon } from 'naive-ui'
import { computed } from 'vue'
import type { UseProducer } from '@/persis'
import SwitchButton from './SwitchButton.vue'
import SwitchButton from '@/components/atomic/SwitchButton.vue'
type U = T | T[] | null
Expand Down Expand Up @@ -89,18 +93,6 @@ function add() {
}
}
function set(idx: number, v: T) {
if (isSingle.value) {
props.edit(() => {
return v
})
} else {
props.edit(draft => {
;(draft as T[])[idx] = v
})
}
}
function remove(idx: number) {
if (isSingle.value) {
if (props.nullable) {
Expand All @@ -120,12 +112,11 @@ function remove(idx: number) {

<template>
<div class="flex flex-col gap-2">
<div class="flex gap-2">
<SwitchButton
v-if="type === 'both'"
v-model:value="single"
></SwitchButton>
<NButton :disabled="single && value !== null" @click="add">
<div class="flex gap-2" v-if="type === 'both' || !single || value === null">
<SwitchButton v-if="type === 'both'" v-model:value="single">
<DataArrayOutlined></DataArrayOutlined>
</SwitchButton>
<NButton v-if="!single || value === null" @click="add">
<template #icon>
<NIcon>
<AddOutlined></AddOutlined>
Expand Down
3 changes: 2 additions & 1 deletion src/components/atomic/JsonEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ async function stringify(v: unknown) {
return await prettier.format(JSON.stringify(v), {
parser: 'json',
plugins: [babel, estree],
tabWidth: 4
tabWidth: 4,
printWidth: 50
})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { DataArrayOutlined } from '@vicons/material'
import { NButton, NIcon } from 'naive-ui'
defineProps<{
Expand All @@ -19,7 +18,7 @@ const single = defineModel<boolean>('value', {
>
<template #icon>
<NIcon>
<DataArrayOutlined></DataArrayOutlined>
<slot></slot>
</NIcon>
</template>
</NButton>
Expand Down
132 changes: 132 additions & 0 deletions src/components/task/FreezeEdit.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<script setup lang="ts">
import { DataObjectOutlined } from '@vicons/material'
import { NInputNumber, NSelect } from 'naive-ui'
import { computed } from 'vue'
import { type UseProducer, applyEditOn, updateEditOn } from '@/persis'
import type { WaitFreezes } from '@/types'
import ClearButton from '@/components/atomic/ClearButton.vue'
import FloatInput from '@/components/atomic/FloatInput.vue'
import SwitchButton from '@/components/atomic/SwitchButton.vue'
import TargetEdit from '@/components/task/TargetEdit.vue'
type T = null | number | WaitFreezes
const props = defineProps<{
value: T
edit: UseProducer<T>
}>()
const notObject = computed({
set(nv: boolean) {
if (nv) {
props.edit(() => {
return (props.value as WaitFreezes).time ?? 1
})
} else {
props.edit(() => {
return {
time: (props.value as number | null) ?? 0
} satisfies WaitFreezes
})
}
},
get() {
return props.value === null || typeof props.value === 'number'
}
})
const wfv = computed(() => {
return props.value as WaitFreezes
})
const wfe = computed(() => {
return props.edit as UseProducer<WaitFreezes>
})
const fixThre = (v: number) => {
return v < 0 ? 0 : v > 1 ? 1 : v
}
const templMethodOptions = [1, 3, 5].map(x => ({
label: `${x}`,
value: x
}))
</script>

<template>
<div class="flex flex-col gap-2">
<div>
<SwitchButton v-model:value="notObject">
<DataObjectOutlined></DataObjectOutlined>
</SwitchButton>
</div>
<div
class="grid items-center"
style="
grid-template-columns: max-content minmax(0, 1fr);
column-gap: 0.5rem;
row-gap: 1rem;
"
>
<template v-if="notObject">
<ClearButton :value="value" :edit="() => edit(() => null)">
延时
</ClearButton>
<NInputNumber
:value="value as number | null"
@update:value="v => edit(() => v)"
placeholder="0"
>
<template #suffix> ms </template>
</NInputNumber>
</template>
<template v-else>
<ClearButton :value="wfv.time ?? null" :edit="applyEditOn(wfe, 'time')">
延时
</ClearButton>
<NInputNumber
:value="wfv.time ?? null"
@update:value="v => updateEditOn(wfe, 'time', v)"
placeholder="1"
>
<template #suffix> ms </template>
</NInputNumber>
<TargetEdit
name="目标"
:target="wfv.target === true ? 1 : wfv.target ?? null"
:edit-target="applyEditOn(wfe, 'target')"
:offset="wfv.target_offset ?? null"
:edit-offset="applyEditOn(wfe, 'target_offset')"
>
</TargetEdit>
<ClearButton
:value="wfv.threshold ?? null"
:edit="applyEditOn(wfe, 'threshold')"
>
阈值
</ClearButton>
<FloatInput
:value="wfv.threshold ?? null"
@update:value="v => updateEditOn(wfe, 'threshold', v)"
nullable
:def="0.95"
:alter="fixThre"
>
</FloatInput>
<ClearButton
:value="wfv.method ?? null"
:edit="applyEditOn(wfe, 'method')"
>
匹配算法
</ClearButton>
<NSelect
:options="templMethodOptions"
:value="wfv.method ?? null"
@update:value="(v: 1 | 3 | 5) => updateEditOn(wfe, 'method', v)"
placeholder="5"
></NSelect>
</template>
</div>
</div>
</template>
17 changes: 14 additions & 3 deletions src/components/task/SingleNavigateEdit.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<script setup lang="ts">
import {
AdsClickOutlined,
ErrorOutlineOutlined,
MovingOutlined,
RepeatOutlined,
StartOutlined,
StopOutlined,
SwipeRightOutlined,
TranslateOutlined,
WavingHandOutlined
Expand Down Expand Up @@ -50,14 +53,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>
<RepeatOutlined v-if="navTask.is_sub"></RepeatOutlined>
<MovingOutlined v-else></MovingOutlined>
<RepeatOutlined v-if="navTask?.is_sub"></RepeatOutlined>
<MovingOutlined v-else-if="navTask"></MovingOutlined>
<ErrorOutlineOutlined v-else></ErrorOutlineOutlined>
</NIcon>
</template>
</NButton>
Expand Down Expand Up @@ -107,6 +110,14 @@ const options = computed(() => {
<SwipeRightOutlined
v-else-if="navTask.action === 'Swipe'"
></SwipeRightOutlined>
<StartOutlined
v-else-if="navTask.action === 'StartApp'"
></StartOutlined>
<StopOutlined
v-else-if="
navTask.action === 'StopApp' || navTask.action === 'StopTask'
"
></StopOutlined>
</NIcon>
</template>
</NButton>
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions src/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ body {
padding: 12px;
gap: 8px;
}

div::-webkit-scrollbar {
width: 0;
}
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ type Action = {
custom_action_param?: unknown
}

type WaitFreezes = {
export type WaitFreezes = {
time?: number
target?: true | string | Rect
target_offset?: Rect
Expand Down

0 comments on commit 8c38a23

Please sign in to comment.