diff --git a/frontend/crawlab-ui/src/components/core/autoprobe/AutoProbeForm.vue b/frontend/crawlab-ui/src/components/core/autoprobe/AutoProbeForm.vue index c7e4d074..f50bd21a 100644 --- a/frontend/crawlab-ui/src/components/core/autoprobe/AutoProbeForm.vue +++ b/frontend/crawlab-ui/src/components/core/autoprobe/AutoProbeForm.vue @@ -1,7 +1,8 @@ @@ -45,8 +73,11 @@ defineOptions({ name: 'ClAutoProbeForm' }); v-model="form.url" :disabled="isFormItemDisabled('url')" :placeholder="t('components.autoprobe.form.url')" - type="textarea" - /> + > + + + + + + + + + + + + {{ t('components.autoprobe.form.viewportWidth') }}: + {{ form.viewport?.width }} + {{ t('components.autoprobe.form.viewportPx') }} + + + {{ t('components.autoprobe.form.viewportHeight') }}: + {{ form.viewport?.height }} + {{ t('components.autoprobe.form.viewportPx') }} + + + + + + + diff --git a/frontend/crawlab-ui/src/components/core/autoprobe/AutoProbeItemDetail.vue b/frontend/crawlab-ui/src/components/core/autoprobe/AutoProbeItemDetail.vue index f721b2c0..0c9049b2 100644 --- a/frontend/crawlab-ui/src/components/core/autoprobe/AutoProbeItemDetail.vue +++ b/frontend/crawlab-ui/src/components/core/autoprobe/AutoProbeItemDetail.vue @@ -85,7 +85,7 @@ const tableColumns = computed>(() => { case 'list': const list = row.rule as ListRule; const selectorType = list.item_selector_type; - const selector = [list.item_selector, list.list_selector] + const selector = [list.list_selector, list.item_selector] .filter(item => item) .join(' > '); return ( diff --git a/frontend/crawlab-ui/src/components/core/autoprobe/AutoProbeResultsContainer.vue b/frontend/crawlab-ui/src/components/core/autoprobe/AutoProbeResultsContainer.vue index 71ac52bd..0525c614 100644 --- a/frontend/crawlab-ui/src/components/core/autoprobe/AutoProbeResultsContainer.vue +++ b/frontend/crawlab-ui/src/components/core/autoprobe/AutoProbeResultsContainer.vue @@ -1,10 +1,9 @@ + + + + + + + + + + + + + {{ el.name }} + + + + + + + + + diff --git a/frontend/crawlab-ui/src/components/core/autoprobe/useAutoProbe.ts b/frontend/crawlab-ui/src/components/core/autoprobe/useAutoProbe.ts index cca87af5..17a67e88 100644 --- a/frontend/crawlab-ui/src/components/core/autoprobe/useAutoProbe.ts +++ b/frontend/crawlab-ui/src/components/core/autoprobe/useAutoProbe.ts @@ -13,7 +13,12 @@ const useAutoProbe = (store: Store) => { const state = store.state[ns]; // form rules - const formRules: FormRules = {}; + const formRules: FormRules = { + url: { + pattern: /^https?:\/\/.+/, + message: 'URL is not valid (must start with http:// or https://)', + }, + }; // all autoprobe select options const allAutoProbeSelectOptions = computed(() => diff --git a/frontend/crawlab-ui/src/components/index.ts b/frontend/crawlab-ui/src/components/index.ts index 8e494723..c4b1205a 100644 --- a/frontend/crawlab-ui/src/components/index.ts +++ b/frontend/crawlab-ui/src/components/index.ts @@ -24,6 +24,7 @@ import AutoProbeItemDetail from './core/autoprobe/AutoProbeItemDetail.vue'; import AutoProbePagePatternsSidebar from './core/autoprobe/AutoProbePagePatternsSidebar.vue'; import AutoProbePatternStats from './core/autoprobe/AutoProbePatternStats.vue'; import AutoProbeResultsContainer from './core/autoprobe/AutoProbeResultsContainer.vue'; +import AutoProbeResultsPreview from './core/autoprobe/AutoProbeResultsPreview.vue'; import AutoProbeSelector from './core/autoprobe/AutoProbeSelector.vue'; import AutoProbeTaskStatus from './core/autoprobe/AutoProbeTaskStatus.vue'; import BlockOptionsDropdownList from './ui/lexical/components/BlockOptionsDropdownList.vue'; @@ -279,6 +280,7 @@ export { AutoProbePagePatternsSidebar as ClAutoProbePagePatternsSidebar, AutoProbePatternStats as ClAutoProbePatternStats, AutoProbeResultsContainer as ClAutoProbeResultsContainer, + AutoProbeResultsPreview as ClAutoProbeResultsPreview, AutoProbeSelector as ClAutoProbeSelector, AutoProbeTaskStatus as ClAutoProbeTaskStatus, BlockOptionsDropdownList as ClBlockOptionsDropdownList, diff --git a/frontend/crawlab-ui/src/i18n/lang/en/components/autoprobe.ts b/frontend/crawlab-ui/src/i18n/lang/en/components/autoprobe.ts index 7bd02426..8c64d459 100644 --- a/frontend/crawlab-ui/src/i18n/lang/en/components/autoprobe.ts +++ b/frontend/crawlab-ui/src/i18n/lang/en/components/autoprobe.ts @@ -3,6 +3,20 @@ const autoprobe: LComponentsAutoProbe = { name: 'Name', url: 'URL', query: 'Query', + queryPlaceholder: + 'User instruction query to extract data (default to system prompt only)', + runOnCreate: 'Run on Create', + viewport: 'Viewport', + viewports: { + pc: { + normal: 'PC (Normal)', + wide: 'PC (Wide)', + small: 'PC (Small)', + }, + }, + viewportWidth: 'Viewport Width', + viewportHeight: 'Viewport Height', + viewportPx: 'px', }, task: { status: { diff --git a/frontend/crawlab-ui/src/i18n/lang/zh/components/autoprobe.ts b/frontend/crawlab-ui/src/i18n/lang/zh/components/autoprobe.ts index 814eab33..17fc9743 100644 --- a/frontend/crawlab-ui/src/i18n/lang/zh/components/autoprobe.ts +++ b/frontend/crawlab-ui/src/i18n/lang/zh/components/autoprobe.ts @@ -3,6 +3,19 @@ const autoprobe: LComponentsAutoProbe = { name: '名称', url: 'URL', query: '查询', + queryPlaceholder: '用户指令查询以提取数据 (默认为系统提示)', + runOnCreate: '创建时运行', + viewport: '视窗大小', + viewports: { + pc: { + normal: 'PC (正常)', + wide: 'PC (宽)', + small: 'PC (小)', + }, + }, + viewportWidth: '视窗宽度', + viewportHeight: '视窗高度', + viewportPx: '像素', }, task: { status: { diff --git a/frontend/crawlab-ui/src/interfaces/i18n/components/autoprobe.d.ts b/frontend/crawlab-ui/src/interfaces/i18n/components/autoprobe.d.ts index 3e0c5148..d79cb9ec 100644 --- a/frontend/crawlab-ui/src/interfaces/i18n/components/autoprobe.d.ts +++ b/frontend/crawlab-ui/src/interfaces/i18n/components/autoprobe.d.ts @@ -3,6 +3,19 @@ interface LComponentsAutoProbe { name: string; url: string; query: string; + queryPlaceholder: string; + runOnCreate: string; + viewport: string; + viewports: { + pc: { + normal: string; + wide: string; + small: string; + }; + }; + viewportWidth: string; + viewportHeight: string; + viewportPx: string; }; task: { status: { diff --git a/frontend/crawlab-ui/src/interfaces/models/autoprobe.d.ts b/frontend/crawlab-ui/src/interfaces/models/autoprobe.d.ts index d524d78f..b1508538 100644 --- a/frontend/crawlab-ui/src/interfaces/models/autoprobe.d.ts +++ b/frontend/crawlab-ui/src/interfaces/models/autoprobe.d.ts @@ -6,8 +6,10 @@ export declare global { last_task_id?: string; last_task?: AutoProbeTask; default_task_id?: string; + run_on_create?: boolean; page_pattern?: PagePattern; page_data?: PageData; + viewport?: PageViewPort; } type AutoProbeTaskStatus = @@ -121,4 +123,10 @@ export declare global { screenshot_base64: string; page_elements: PageElement[]; } + + type ViewPortValue = 'pc-normal' | 'pc-wide' | 'pc-small'; + + interface ViewPortSelectOption extends SelectOption { + viewport: PageViewPort; + } } diff --git a/frontend/crawlab-ui/src/store/modules/autoprobe.ts b/frontend/crawlab-ui/src/store/modules/autoprobe.ts index 96be8ca5..21a1c53d 100644 --- a/frontend/crawlab-ui/src/store/modules/autoprobe.ts +++ b/frontend/crawlab-ui/src/store/modules/autoprobe.ts @@ -11,6 +11,7 @@ import { } from '@/constants/tab'; import { translate } from '@/utils/i18n'; import useRequest from '@/services/request'; +import { getViewPortOptions } from '@/utils'; // i18n const t = translate; @@ -19,6 +20,13 @@ const { post } = useRequest(); const state = { ...getDefaultStoreState('autoprobe'), + newFormFn: () => { + return { + run_on_create: true, + viewport: getViewPortOptions().find(v => v.value === 'pc-normal') + ?.viewport, + }; + }, tabs: [ { id: TAB_NAME_OVERVIEW, title: t('common.tabs.overview') }, { id: TAB_NAME_TASKS, title: t('common.tabs.tasks') }, diff --git a/frontend/crawlab-ui/src/utils/autoprobe.ts b/frontend/crawlab-ui/src/utils/autoprobe.ts index e08b64de..52ad9fd3 100644 --- a/frontend/crawlab-ui/src/utils/autoprobe.ts +++ b/frontend/crawlab-ui/src/utils/autoprobe.ts @@ -1,3 +1,7 @@ +import { translate } from '@/utils'; + +const t = translate; + export const getIconBySelectorType = (selectorType: SelectorType): Icon => { switch (selectorType) { case 'css': @@ -50,4 +54,24 @@ export const getIconByPageElementType = (itemType?: PageElementType): Icon => { default: return ['fa', 'question']; } -} +}; + +export const getViewPortOptions = () => { + return [ + { + label: t('components.autoprobe.form.viewports.pc.normal'), + value: 'pc-normal', + viewport: { width: 1280, height: 800 }, + }, + { + label: t('components.autoprobe.form.viewports.pc.wide'), + value: 'pc-wide', + viewport: { width: 1920, height: 1080 }, + }, + { + label: t('components.autoprobe.form.viewports.pc.small'), + value: 'pc-small', + viewport: { width: 1024, height: 768 }, + }, + ] as ViewPortSelectOption[]; +}; diff --git a/frontend/crawlab-ui/src/views/autoprobe/detail/tabs/AutoProbeDetailTabPatterns.vue b/frontend/crawlab-ui/src/views/autoprobe/detail/tabs/AutoProbeDetailTabPatterns.vue index 7035dac8..3c48193d 100644 --- a/frontend/crawlab-ui/src/views/autoprobe/detail/tabs/AutoProbeDetailTabPatterns.vue +++ b/frontend/crawlab-ui/src/views/autoprobe/detail/tabs/AutoProbeDetailTabPatterns.vue @@ -264,6 +264,7 @@ defineOptions({ name: 'ClAutoProbeDetailTabPatterns' }); :fields="resultsFields" :active-field-name="resultsActiveField?.name" :url="form.url" + :viewport="form.viewport" :active-id="activeId" @size-change="onSizeChange" />