<template>
|
<fieldset>
|
<legend>设置</legend>
|
<div class="row">
|
<label>
|
<input type="checkbox"
|
v-model="enableAutoTask"
|
@change="saveCheckBox($event,EnableAutoTaskKey)"
|
>
|
开启《搜索》轮询
|
</label>
|
<label>
|
缓存
|
<select v-model="cache" @change="saveSelect($event,CacheKey)">
|
<option :value="v" v-for="v of ['default','force-cache']">{{ v }}</option>
|
</select>
|
</label>
|
<hr width="100%"/>
|
<label>
|
<input type="checkbox"
|
v-model="reserve"
|
@change="saveCheckBox($event,TaskReserveKey)"
|
>
|
测试时不标记任务
|
</label>
|
<label>
|
任务类型
|
<select v-model="taskType" @change="saveSelect($event,TaskTypeKey)">
|
<option :value="row.value" v-for="row of taskTypeLabels">{{ row.label }}</option>
|
</select>
|
</label>
|
</div>
|
</fieldset>
|
<fieldset>
|
<legend>表单填写设置</legend>
|
<div class="row">
|
<label>
|
<input type="checkbox"
|
v-model="autoCloseTab"
|
@change="saveCheckBox($event,AutoCloseTabKey)"
|
>
|
自动关闭标签
|
</label>
|
<label v-if="canHistoryMock">
|
<input type="checkbox"
|
:checked="useHistoryMock!==false"
|
@change="useHistoryMock=$event.target.checked;saveCheckBox($event,UseHistoryMockKey)"
|
>
|
使用历史记录模拟数据
|
</label>
|
<template v-if="canHistoryMock && useHistoryMock!==false">
|
<hr width="100%"/>
|
<label>
|
模拟数据目标
|
|
<select id="history-select" @change="saveMockTarget">
|
<option value="true">随机</option>
|
<option
|
v-for="item in history"
|
:key="item.id"
|
:value="item.id"
|
>
|
{{ item.name }} - {{ item.goodsId }}
|
</option>
|
</select>
|
</label>
|
</template>
|
</div>
|
</fieldset>
|
</template>
|
|
<script lang="ts" setup>
|
import {onMounted} from "vue";
|
import {StorageLocal} from "gs-br-ext";
|
import {
|
AutoCloseTabKey,
|
BidFormData,
|
CacheKey,
|
Db,
|
EnableAutoTaskKey,
|
TaskReserveKey, TaskType,
|
TaskTypeKey,
|
UseHistoryMockKey
|
} from "/src-com";
|
|
const enableAutoTask = ref(false)
|
const reserve = ref(false)
|
const autoCloseTab = ref(false)
|
const useHistoryMock = ref<boolean | number>(false)
|
const taskType = ref('')
|
const cache = ref('default')
|
const canHistoryMock = ref(false)
|
const history = ref<BidFormData[]>([]);
|
|
const taskTypeLabels: { value: TaskType|'', label: string }[] = [
|
{value: '', label: '全部'},
|
{value: 'bid', label: '仅拍卖'},
|
{value: 'buyItNow', label: '仅一口价'},
|
{value: 'search', label: '搜索'},
|
{value: 'detail', label: '详情'},
|
]
|
|
onMounted(async () => {
|
enableAutoTask.value = !!(await StorageLocal.getValue(EnableAutoTaskKey))
|
reserve.value = !!(await StorageLocal.getValue(TaskReserveKey))
|
autoCloseTab.value = !!(await StorageLocal.getValue(AutoCloseTabKey))
|
useHistoryMock.value = !!(await StorageLocal.getValue(UseHistoryMockKey))
|
taskType.value = await StorageLocal.getValue(TaskTypeKey) || ''
|
const sc = await StorageLocal.getValue('cache');
|
if (sc) {
|
cache.value = sc
|
}
|
await Db.bidTaskAddedHistory.batchRead(async s => {
|
canHistoryMock.value = await s.count() > 0;
|
history.value = await s.all();
|
})
|
})
|
|
async function saveCheckBox(e: any, key: string) {
|
await StorageLocal.setValue(key, e.target.checked)
|
}
|
|
async function saveSelect(e: any, key: string) {
|
await StorageLocal.setValue(key, e.target.value)
|
}
|
|
async function saveMockTarget(e: any) {
|
let v: any = e.target.value;
|
if (/^\d+$/.test(v)) {
|
v = Number(v)
|
} else {
|
v = Boolean(v)
|
}
|
await StorageLocal.setValue(UseHistoryMockKey, v)
|
}
|
|
|
</script>
|