重构代码结构、数据传递方式,方便数据存取

This commit is contained in:
fofolee
2025-01-05 00:22:53 +08:00
parent dcaa00823b
commit 827c702e50
42 changed files with 2713 additions and 2143 deletions

View File

@@ -5,7 +5,7 @@
<VariableInput
v-model="localConfigs.goto.url"
label="网址"
:command="{ icon: 'link' }"
icon="link"
@update:model-value="updateConfigs"
/>
</div>
@@ -17,7 +17,7 @@
<VariableInput
v-model="localConfigs.goto.headers.Referer"
label="Referer"
:command="{ icon: 'link' }"
icon="link"
@update:model-value="updateConfigs"
/>
</div>
@@ -27,7 +27,7 @@
<VariableInput
v-model="localConfigs.goto.headers.userAgent"
label="User-Agent"
:command="{ icon: 'devices' }"
icon="devices"
@update:model-value="updateConfigs"
/>
</div>
@@ -55,9 +55,9 @@
<!-- 超时配置 -->
<div class="col-12">
<VariableInput
<NumberInput
v-model="localConfigs.goto.timeout"
:command="{ icon: 'timer', inputType: 'number' }"
icon="timer"
label="超时时间(ms)"
@update:model-value="updateConfigs"
/>
@@ -67,13 +67,15 @@
<script>
import { defineComponent } from "vue";
import { defaultUBrowserConfigs } from "js/composer/ubrowserConfig";
import { userAgent } from "js/options/httpOptions";
import VariableInput from "components/composer/ui/VariableInput.vue";
import NumberInput from "components/composer/ui/NumberInput.vue";
export default defineComponent({
name: "UBrowserBasic",
components: {
VariableInput,
NumberInput,
},
props: {
configs: {
@@ -84,20 +86,7 @@ export default defineComponent({
data() {
return {
selectedUA: null,
localConfigs: {
useragent: {
preset: null,
value: "",
},
goto: {
url: "",
headers: {
Referer: "",
userAgent: "",
},
timeout: 60000,
},
},
localConfigs: defaultUBrowserConfigs.goto,
userAgentOptions: userAgent,
};
},
@@ -119,7 +108,8 @@ export default defineComponent({
},
selectedUA(value) {
if (value) {
this.localConfigs.goto.headers.userAgent = value;
this.localConfigs.goto.headers.userAgent.value = value;
this.localConfigs.goto.headers.userAgent.isString = true;
this.updateConfigs();
this.selectedUA = null;
}

View File

@@ -35,34 +35,30 @@
<div class="col-12">
<div class="row q-col-gutter-sm">
<div class="col-3">
<VariableInput
<NumberInput
v-model="localConfigs.run.width"
label="窗口宽度"
:command="{ inputType: 'number' }"
@update:model-value="updateConfig('width', $event)"
/>
</div>
<div class="col-3">
<VariableInput
<NumberInput
v-model="localConfigs.run.height"
label="窗口高度"
:command="{ inputType: 'number' }"
@update:model-value="updateConfig('height', $event)"
/>
</div>
<div class="col-3">
<VariableInput
<NumberInput
v-model="localConfigs.run.x"
label="X坐标"
:command="{ inputType: 'number' }"
@update:model-value="updateConfig('x', $event)"
/>
</div>
<div class="col-3">
<VariableInput
<NumberInput
v-model="localConfigs.run.y"
label="Y坐标"
:command="{ inputType: 'number' }"
@update:model-value="updateConfig('y', $event)"
/>
</div>
@@ -73,34 +69,30 @@
<div class="col-12">
<div class="row q-col-gutter-sm">
<div class="col-3">
<VariableInput
<NumberInput
v-model="localConfigs.run.minWidth"
label="最小宽度"
:command="{ inputType: 'number' }"
@update:model-value="updateConfig('minWidth', $event)"
/>
</div>
<div class="col-3">
<VariableInput
<NumberInput
v-model="localConfigs.run.minHeight"
label="最小高度"
:command="{ inputType: 'number' }"
@update:model-value="updateConfig('minHeight', $event)"
/>
</div>
<div class="col-3">
<VariableInput
<NumberInput
v-model="localConfigs.run.maxWidth"
label="最大宽度"
:command="{ inputType: 'number' }"
@update:model-value="updateConfig('maxWidth', $event)"
/>
</div>
<div class="col-3">
<VariableInput
<NumberInput
v-model="localConfigs.run.maxHeight"
label="最大高度"
:command="{ inputType: 'number' }"
@update:model-value="updateConfig('maxHeight', $event)"
/>
</div>
@@ -164,12 +156,12 @@
<script>
import { defineComponent } from "vue";
import VariableInput from "components/composer/ui/VariableInput.vue";
import NumberInput from "components/composer/ui/NumberInput.vue";
export default defineComponent({
name: "UBrowserRun",
components: {
VariableInput,
NumberInput,
},
props: {
configs: {

View File

@@ -24,7 +24,7 @@
</template>
<!-- 基本输入类型的处理 -->
<template v-if="field.type === 'input'">
<template v-if="field.type === 'varInput'">
<!-- 设备名称特殊处理 -->
<template v-if="field.key === 'deviceName'">
<UBrowserDeviceName
@@ -48,6 +48,16 @@
</template>
</template>
<!-- 数字输入框 -->
<template v-else-if="field.type === 'numInput'">
<NumberInput
v-model="fieldValue[field.key]"
:label="field.label"
:command="{ icon: field.icon }"
@update:model-value="updateValue(field.key, $event)"
/>
</template>
<!-- 文本区域 -->
<template v-else-if="field.type === 'textarea'">
<UBrowserTextarea
@@ -143,7 +153,7 @@ import UBrowserDeviceName from "./UBrowserDeviceName.vue";
import UBrowserTextarea from "./UBrowserTextarea.vue";
import VariableInput from "components/composer/ui/VariableInput.vue";
import UBrowserCheckboxGroup from "./UBrowserCheckboxGroup.vue";
import NumberInput from "components/composer/ui/NumberInput.vue";
export default defineComponent({
name: "UBrowserOperation",
components: {
@@ -159,6 +169,7 @@ export default defineComponent({
UBrowserTextarea,
VariableInput,
UBrowserCheckboxGroup,
NumberInput,
},
props: {
configs: {