chore(frontend): introduce prettier + eslint and prune unused code
- Add Prettier 3 with prettier-plugin-organize-imports (sorts/removes unused imports) - Add ESLint 10 flat config with typescript-eslint + eslint-plugin-vue + eslint-config-prettier - Add root scripts: format, format:check, lint, lint:fix - Reformat 257 files across admin-web, ops-web, desktop-client, packages - Remove unused locals/exports flagged by --noUnusedLocals/--noUnusedParameters - Fix duplicate localTabLabel key, surrogate-pair regex u-flag, NBSP literal in regex - Skip server/ (Go) and apps/browser-extension/ (deprecated per ADR) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,198 +1,207 @@
|
||||
<script setup lang="ts">
|
||||
import { MinusCircleFilled, PlusOutlined } from "@ant-design/icons-vue";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/vue-query";
|
||||
import { message } from "ant-design-vue";
|
||||
import type { PromptRuleSimple, ScheduleTask } from "@geo/shared-types";
|
||||
import { computed, reactive, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { MinusCircleFilled, PlusOutlined } from '@ant-design/icons-vue'
|
||||
import type { PromptRuleSimple, ScheduleTask } from '@geo/shared-types'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/vue-query'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
import CoverPickerModal from "@/components/CoverPickerModal.vue";
|
||||
import PromptRuleModal from "@/components/PromptRuleModal.vue";
|
||||
import { generateApi, imagesApi, mediaApi, promptRulesApi, resolveApiURL, schedulesApi, tenantAccountsApi } from "@/lib/api";
|
||||
import { coverUploadRequired, deriveCoverFileName } from "@/lib/cover-requirements";
|
||||
import { formatError } from "@/lib/errors";
|
||||
import CoverPickerModal from '@/components/CoverPickerModal.vue'
|
||||
import PromptRuleModal from '@/components/PromptRuleModal.vue'
|
||||
import {
|
||||
generateApi,
|
||||
imagesApi,
|
||||
mediaApi,
|
||||
promptRulesApi,
|
||||
resolveApiURL,
|
||||
schedulesApi,
|
||||
tenantAccountsApi,
|
||||
} from '@/lib/api'
|
||||
import { coverUploadRequired, deriveCoverFileName } from '@/lib/cover-requirements'
|
||||
import { formatError } from '@/lib/errors'
|
||||
import {
|
||||
buildPublishAccountCards,
|
||||
buildPublishPlatformMap,
|
||||
publishStatusShortLabel,
|
||||
type PublishAccountCard,
|
||||
} from "@/lib/publish-account-cards";
|
||||
} from '@/lib/publish-account-cards'
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
mode: "instant" | "schedule";
|
||||
task?: ScheduleTask | null;
|
||||
}>();
|
||||
open: boolean
|
||||
mode: 'instant' | 'schedule'
|
||||
task?: ScheduleTask | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
"update:open": [value: boolean];
|
||||
}>();
|
||||
'update:open': [value: boolean]
|
||||
}>()
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
const { t } = useI18n();
|
||||
const queryClient = useQueryClient()
|
||||
const { t } = useI18n()
|
||||
|
||||
const promptDrawerOpen = ref(false);
|
||||
const coverPickerOpen = ref(false);
|
||||
const promptDrawerOpen = ref(false)
|
||||
const coverPickerOpen = ref(false)
|
||||
|
||||
const form = reactive({
|
||||
name: "",
|
||||
name: '',
|
||||
promptRuleId: undefined as number | undefined,
|
||||
autoPublish: false,
|
||||
publishAccountIds: [] as string[],
|
||||
coverEnabled: false,
|
||||
coverAssetUrl: "",
|
||||
coverFileName: "",
|
||||
coverAssetUrl: '',
|
||||
coverFileName: '',
|
||||
coverImageAssetId: null as number | null,
|
||||
enableWebSearch: false,
|
||||
generateCount: 1,
|
||||
scheduleTime: "08:00:00",
|
||||
});
|
||||
scheduleTime: '08:00:00',
|
||||
})
|
||||
|
||||
const isSchedule = computed(() => props.mode === "schedule");
|
||||
const isSchedule = computed(() => props.mode === 'schedule')
|
||||
|
||||
const rulesQuery = useQuery({
|
||||
queryKey: ["promptRules", "simple"],
|
||||
queryKey: ['promptRules', 'simple'],
|
||||
queryFn: () => promptRulesApi.listSimple(),
|
||||
});
|
||||
})
|
||||
|
||||
const schedulePublishQueryEnabled = computed(() => props.open && isSchedule.value);
|
||||
const schedulePublishQueryEnabled = computed(() => props.open && isSchedule.value)
|
||||
|
||||
const platformsQuery = useQuery({
|
||||
queryKey: ["media", "platforms", "schedule-task-drawer"],
|
||||
queryKey: ['media', 'platforms', 'schedule-task-drawer'],
|
||||
enabled: schedulePublishQueryEnabled,
|
||||
queryFn: () => mediaApi.platforms(),
|
||||
});
|
||||
})
|
||||
|
||||
const accountsQuery = useQuery({
|
||||
queryKey: ["tenant", "desktop-accounts", "schedule-task-drawer"],
|
||||
queryKey: ['tenant', 'desktop-accounts', 'schedule-task-drawer'],
|
||||
enabled: schedulePublishQueryEnabled,
|
||||
queryFn: () => tenantAccountsApi.list(),
|
||||
});
|
||||
})
|
||||
|
||||
const promptOptions = computed(() =>
|
||||
(rulesQuery.data.value ?? []).map((rule: PromptRuleSimple) => ({
|
||||
label: rule.name,
|
||||
value: rule.id,
|
||||
})),
|
||||
);
|
||||
)
|
||||
|
||||
const platformMap = computed(() => buildPublishPlatformMap(platformsQuery.data.value ?? []));
|
||||
const platformMap = computed(() => buildPublishPlatformMap(platformsQuery.data.value ?? []))
|
||||
|
||||
const schedulePublishAccounts = computed<PublishAccountCard[]>(() =>
|
||||
buildPublishAccountCards(accountsQuery.data.value ?? [], platformMap.value),
|
||||
);
|
||||
)
|
||||
|
||||
const schedulePublishLoading = computed(
|
||||
() => platformsQuery.isPending.value || accountsQuery.isPending.value,
|
||||
);
|
||||
)
|
||||
|
||||
const selectedSchedulePublishPlatformIds = computed(() => {
|
||||
const selected = new Set(form.publishAccountIds);
|
||||
const selected = new Set(form.publishAccountIds)
|
||||
return Array.from(
|
||||
new Set(
|
||||
schedulePublishAccounts.value
|
||||
.filter((account) => selected.has(account.id))
|
||||
.map((account) => account.platformId),
|
||||
),
|
||||
);
|
||||
});
|
||||
)
|
||||
})
|
||||
|
||||
const scheduleCoverRequired = computed(() => coverUploadRequired(selectedSchedulePublishPlatformIds.value));
|
||||
const effectiveScheduleCoverEnabled = computed(() => scheduleCoverRequired.value || form.coverEnabled);
|
||||
const scheduleCoverRequired = computed(() =>
|
||||
coverUploadRequired(selectedSchedulePublishPlatformIds.value),
|
||||
)
|
||||
const effectiveScheduleCoverEnabled = computed(
|
||||
() => scheduleCoverRequired.value || form.coverEnabled,
|
||||
)
|
||||
|
||||
watch(
|
||||
scheduleCoverRequired,
|
||||
(required) => {
|
||||
if (required) {
|
||||
form.coverEnabled = true;
|
||||
form.coverEnabled = true
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
)
|
||||
|
||||
const drawerTitle = computed(() => {
|
||||
if (isSchedule.value) {
|
||||
return props.task?.id ? t("custom.schedule.editTitle") : t("custom.schedule.createTitle");
|
||||
return props.task?.id ? t('custom.schedule.editTitle') : t('custom.schedule.createTitle')
|
||||
}
|
||||
return t("custom.instant.createTitle");
|
||||
});
|
||||
return t('custom.instant.createTitle')
|
||||
})
|
||||
|
||||
const submitText = computed(() => {
|
||||
if (isSchedule.value) {
|
||||
return props.task?.id ? t("common.save") : t("custom.task.submit");
|
||||
return props.task?.id ? t('common.save') : t('custom.task.submit')
|
||||
}
|
||||
return t("custom.task.submit");
|
||||
});
|
||||
return t('custom.task.submit')
|
||||
})
|
||||
|
||||
watch(
|
||||
() => props.open,
|
||||
(open) => {
|
||||
if (open) {
|
||||
hydrateForm();
|
||||
hydrateForm()
|
||||
}
|
||||
},
|
||||
);
|
||||
)
|
||||
|
||||
const createScheduleMutation = useMutation({
|
||||
mutationFn: () =>
|
||||
schedulesApi.create(buildSchedulePayload()),
|
||||
mutationFn: () => schedulesApi.create(buildSchedulePayload()),
|
||||
onSuccess: async () => {
|
||||
message.success(t("custom.messages.scheduleCreated"));
|
||||
emit("update:open", false);
|
||||
await queryClient.invalidateQueries({ queryKey: ["schedules"] });
|
||||
message.success(t('custom.messages.scheduleCreated'))
|
||||
emit('update:open', false)
|
||||
await queryClient.invalidateQueries({ queryKey: ['schedules'] })
|
||||
},
|
||||
onError: (error) => message.error(formatError(error)),
|
||||
});
|
||||
})
|
||||
|
||||
const updateScheduleMutation = useMutation({
|
||||
mutationFn: () =>
|
||||
schedulesApi.update(props.task!.id, buildSchedulePayload()),
|
||||
mutationFn: () => schedulesApi.update(props.task!.id, buildSchedulePayload()),
|
||||
onSuccess: async () => {
|
||||
message.success(t("custom.messages.scheduleUpdated"));
|
||||
emit("update:open", false);
|
||||
await queryClient.invalidateQueries({ queryKey: ["schedules"] });
|
||||
message.success(t('custom.messages.scheduleUpdated'))
|
||||
emit('update:open', false)
|
||||
await queryClient.invalidateQueries({ queryKey: ['schedules'] })
|
||||
},
|
||||
onError: (error) => message.error(formatError(error)),
|
||||
});
|
||||
})
|
||||
|
||||
const instantGenerateMutation = useMutation({
|
||||
mutationFn: () =>
|
||||
generateApi.fromRule(buildInstantPayload()),
|
||||
mutationFn: () => generateApi.fromRule(buildInstantPayload()),
|
||||
onSuccess: async () => {
|
||||
message.success(t("custom.messages.generateSubmitted"));
|
||||
emit("update:open", false);
|
||||
message.success(t('custom.messages.generateSubmitted'))
|
||||
emit('update:open', false)
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries({ queryKey: ["articles"] }),
|
||||
queryClient.invalidateQueries({ queryKey: ["instantTasks"] }),
|
||||
]);
|
||||
queryClient.invalidateQueries({ queryKey: ['articles'] }),
|
||||
queryClient.invalidateQueries({ queryKey: ['instantTasks'] }),
|
||||
])
|
||||
},
|
||||
onError: (error) => message.error(formatError(error)),
|
||||
});
|
||||
})
|
||||
|
||||
const submitLoading = computed(
|
||||
() =>
|
||||
createScheduleMutation.isPending.value ||
|
||||
updateScheduleMutation.isPending.value ||
|
||||
instantGenerateMutation.isPending.value,
|
||||
);
|
||||
)
|
||||
|
||||
function hydrateForm(): void {
|
||||
form.name = props.task?.name ?? "";
|
||||
form.promptRuleId = props.task?.prompt_rule_id ?? undefined;
|
||||
form.autoPublish = isSchedule.value ? Boolean(props.task?.auto_publish) : false;
|
||||
form.publishAccountIds = isSchedule.value ? [...(props.task?.publish_account_ids ?? [])] : [];
|
||||
form.coverAssetUrl = isSchedule.value ? resolveApiURL(props.task?.cover_asset_url) : "";
|
||||
form.coverFileName = deriveCoverFileName(form.coverAssetUrl);
|
||||
form.coverImageAssetId = isSchedule.value ? props.task?.cover_image_asset_id ?? null : null;
|
||||
form.coverEnabled = Boolean(form.coverAssetUrl);
|
||||
form.enableWebSearch = props.task?.enable_web_search ?? false;
|
||||
form.generateCount = props.task?.generate_count ?? 1;
|
||||
form.scheduleTime = parseCronToDailyTime(props.task?.cron_expr);
|
||||
form.name = props.task?.name ?? ''
|
||||
form.promptRuleId = props.task?.prompt_rule_id ?? undefined
|
||||
form.autoPublish = isSchedule.value ? Boolean(props.task?.auto_publish) : false
|
||||
form.publishAccountIds = isSchedule.value ? [...(props.task?.publish_account_ids ?? [])] : []
|
||||
form.coverAssetUrl = isSchedule.value ? resolveApiURL(props.task?.cover_asset_url) : ''
|
||||
form.coverFileName = deriveCoverFileName(form.coverAssetUrl)
|
||||
form.coverImageAssetId = isSchedule.value ? (props.task?.cover_image_asset_id ?? null) : null
|
||||
form.coverEnabled = Boolean(form.coverAssetUrl)
|
||||
form.enableWebSearch = props.task?.enable_web_search ?? false
|
||||
form.generateCount = props.task?.generate_count ?? 1
|
||||
form.scheduleTime = parseCronToDailyTime(props.task?.cron_expr)
|
||||
}
|
||||
|
||||
function buildSchedulePayload() {
|
||||
const coverEnabled = form.autoPublish && effectiveScheduleCoverEnabled.value;
|
||||
const coverAssetUrl = coverEnabled ? form.coverAssetUrl.trim() : "";
|
||||
const coverEnabled = form.autoPublish && effectiveScheduleCoverEnabled.value
|
||||
const coverAssetUrl = coverEnabled ? form.coverAssetUrl.trim() : ''
|
||||
|
||||
return {
|
||||
name: form.name.trim(),
|
||||
@@ -204,7 +213,7 @@ function buildSchedulePayload() {
|
||||
cover_image_asset_id: coverAssetUrl ? form.coverImageAssetId : null,
|
||||
enable_web_search: form.enableWebSearch,
|
||||
generate_count: form.generateCount,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function buildInstantPayload() {
|
||||
@@ -212,149 +221,155 @@ function buildInstantPayload() {
|
||||
prompt_rule_id: form.promptRuleId!,
|
||||
extra_params: {
|
||||
task_name: form.name.trim(),
|
||||
generation_mode: "instant",
|
||||
generation_mode: 'instant',
|
||||
enable_web_search: form.enableWebSearch,
|
||||
generate_count: form.generateCount,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function handlePromptSaved(ruleId: number): void {
|
||||
form.promptRuleId = ruleId;
|
||||
promptDrawerOpen.value = false;
|
||||
void queryClient.invalidateQueries({ queryKey: ["promptRules", "simple"] });
|
||||
form.promptRuleId = ruleId
|
||||
promptDrawerOpen.value = false
|
||||
void queryClient.invalidateQueries({ queryKey: ['promptRules', 'simple'] })
|
||||
}
|
||||
|
||||
function toggleSchedulePublishAccount(account: PublishAccountCard): void {
|
||||
if (!account.selectable) {
|
||||
return;
|
||||
return
|
||||
}
|
||||
if (form.publishAccountIds.includes(account.id)) {
|
||||
form.publishAccountIds = form.publishAccountIds.filter((id) => id !== account.id);
|
||||
return;
|
||||
form.publishAccountIds = form.publishAccountIds.filter((id) => id !== account.id)
|
||||
return
|
||||
}
|
||||
form.publishAccountIds = [...form.publishAccountIds, account.id];
|
||||
form.publishAccountIds = [...form.publishAccountIds, account.id]
|
||||
}
|
||||
|
||||
function isSchedulePublishAccountSelected(accountId: string): boolean {
|
||||
return form.publishAccountIds.includes(accountId);
|
||||
return form.publishAccountIds.includes(accountId)
|
||||
}
|
||||
|
||||
async function uploadScheduleCover(file: File): Promise<{ url: string; fileName: string; assetId?: number | null }> {
|
||||
const uploaded = await imagesApi.upload(file);
|
||||
async function uploadScheduleCover(
|
||||
file: File,
|
||||
): Promise<{ url: string; fileName: string; assetId?: number | null }> {
|
||||
const uploaded = await imagesApi.upload(file)
|
||||
return {
|
||||
url: uploaded.url,
|
||||
fileName: uploaded.name,
|
||||
assetId: uploaded.id,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function handleScheduleCoverPicked(payload: { url: string; fileName: string; assetId?: number | null }): void {
|
||||
form.coverAssetUrl = payload.url;
|
||||
form.coverFileName = payload.fileName;
|
||||
form.coverImageAssetId = payload.assetId ?? null;
|
||||
form.coverEnabled = true;
|
||||
function handleScheduleCoverPicked(payload: {
|
||||
url: string
|
||||
fileName: string
|
||||
assetId?: number | null
|
||||
}): void {
|
||||
form.coverAssetUrl = payload.url
|
||||
form.coverFileName = payload.fileName
|
||||
form.coverImageAssetId = payload.assetId ?? null
|
||||
form.coverEnabled = true
|
||||
}
|
||||
|
||||
function handleRemoveScheduleCover(): void {
|
||||
form.coverAssetUrl = "";
|
||||
form.coverFileName = "";
|
||||
form.coverImageAssetId = null;
|
||||
form.coverAssetUrl = ''
|
||||
form.coverFileName = ''
|
||||
form.coverImageAssetId = null
|
||||
}
|
||||
|
||||
function handleScheduleCoverToggle(checked: boolean): void {
|
||||
if (scheduleCoverRequired.value) {
|
||||
form.coverEnabled = true;
|
||||
return;
|
||||
form.coverEnabled = true
|
||||
return
|
||||
}
|
||||
form.coverEnabled = checked;
|
||||
form.coverEnabled = checked
|
||||
}
|
||||
|
||||
function validateForm(): boolean {
|
||||
if (!form.name.trim()) {
|
||||
message.warning(t("custom.messages.missingTaskName"));
|
||||
return false;
|
||||
message.warning(t('custom.messages.missingTaskName'))
|
||||
return false
|
||||
}
|
||||
|
||||
if (!form.promptRuleId) {
|
||||
message.warning(t("custom.messages.missingPromptRule"));
|
||||
return false;
|
||||
message.warning(t('custom.messages.missingPromptRule'))
|
||||
return false
|
||||
}
|
||||
|
||||
if (form.generateCount < 1) {
|
||||
message.warning(t("custom.messages.invalidGenerateCount"));
|
||||
return false;
|
||||
message.warning(t('custom.messages.invalidGenerateCount'))
|
||||
return false
|
||||
}
|
||||
|
||||
if (isSchedule.value && !isValidTime(form.scheduleTime)) {
|
||||
message.warning(t("custom.messages.invalidScheduleTime"));
|
||||
return false;
|
||||
message.warning(t('custom.messages.invalidScheduleTime'))
|
||||
return false
|
||||
}
|
||||
|
||||
if (isSchedule.value && form.autoPublish) {
|
||||
if (form.publishAccountIds.length === 0) {
|
||||
message.warning(t("custom.messages.missingPublishAccounts"));
|
||||
return false;
|
||||
message.warning(t('custom.messages.missingPublishAccounts'))
|
||||
return false
|
||||
}
|
||||
if (scheduleCoverRequired.value && !form.coverAssetUrl.trim()) {
|
||||
message.warning(t("custom.messages.missingScheduleCover"));
|
||||
return false;
|
||||
message.warning(t('custom.messages.missingScheduleCover'))
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
|
||||
async function handleSubmit(): Promise<void> {
|
||||
if (!validateForm()) {
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
if (isSchedule.value) {
|
||||
if (props.task?.id) {
|
||||
await updateScheduleMutation.mutateAsync();
|
||||
await updateScheduleMutation.mutateAsync()
|
||||
} else {
|
||||
await createScheduleMutation.mutateAsync();
|
||||
await createScheduleMutation.mutateAsync()
|
||||
}
|
||||
return;
|
||||
return
|
||||
}
|
||||
|
||||
await instantGenerateMutation.mutateAsync();
|
||||
await instantGenerateMutation.mutateAsync()
|
||||
}
|
||||
|
||||
function parseCronToDailyTime(cronExpr?: string | null): string {
|
||||
if (!cronExpr) {
|
||||
return "08:00:00";
|
||||
return '08:00:00'
|
||||
}
|
||||
|
||||
const fiveFieldMatch = cronExpr.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+\*$/);
|
||||
const fiveFieldMatch = cronExpr.match(/^(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+\*$/)
|
||||
if (fiveFieldMatch) {
|
||||
const [, minute, hour] = fiveFieldMatch;
|
||||
return `${padTime(hour)}:${padTime(minute)}:00`;
|
||||
const [, minute, hour] = fiveFieldMatch
|
||||
return `${padTime(hour)}:${padTime(minute)}:00`
|
||||
}
|
||||
|
||||
const sixFieldMatch = cronExpr.match(/^(\d{1,2})\s+(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+\*$/);
|
||||
const sixFieldMatch = cronExpr.match(/^(\d{1,2})\s+(\d{1,2})\s+(\d{1,2})\s+\*\s+\*\s+\*$/)
|
||||
if (sixFieldMatch) {
|
||||
const [, second, minute, hour] = sixFieldMatch;
|
||||
return `${padTime(hour)}:${padTime(minute)}:${padTime(second)}`;
|
||||
const [, second, minute, hour] = sixFieldMatch
|
||||
return `${padTime(hour)}:${padTime(minute)}:${padTime(second)}`
|
||||
}
|
||||
|
||||
return "08:00:00";
|
||||
return '08:00:00'
|
||||
}
|
||||
|
||||
function buildDailyCron(timeValue: string): string {
|
||||
const [hourRaw, minuteRaw] = timeValue.split(":");
|
||||
const hour = Number(hourRaw || 0);
|
||||
const minute = Number(minuteRaw || 0);
|
||||
return `${minute} ${hour} * * *`;
|
||||
const [hourRaw, minuteRaw] = timeValue.split(':')
|
||||
const hour = Number(hourRaw || 0)
|
||||
const minute = Number(minuteRaw || 0)
|
||||
return `${minute} ${hour} * * *`
|
||||
}
|
||||
|
||||
function isValidTime(value: string): boolean {
|
||||
return /^\d{2}:\d{2}(:\d{2})?$/.test(value);
|
||||
return /^\d{2}:\d{2}(:\d{2})?$/.test(value)
|
||||
}
|
||||
|
||||
function padTime(value: string): string {
|
||||
return value.padStart(2, "0");
|
||||
return value.padStart(2, '0')
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -372,12 +387,12 @@ function padTime(value: string): string {
|
||||
<section class="generate-task-drawer__panel">
|
||||
<div class="generate-task-drawer__section-head">
|
||||
<div class="generate-task-drawer__section-marker"></div>
|
||||
<h3>{{ t("custom.task.basicSection") }}</h3>
|
||||
<h3>{{ t('custom.task.basicSection') }}</h3>
|
||||
</div>
|
||||
|
||||
<div class="generate-task-drawer__field">
|
||||
<label class="generate-task-drawer__label generate-task-drawer__label--required">
|
||||
{{ t("custom.task.name") }}:
|
||||
{{ t('custom.task.name') }}:
|
||||
</label>
|
||||
<a-input
|
||||
v-model:value="form.name"
|
||||
@@ -389,7 +404,7 @@ function padTime(value: string): string {
|
||||
|
||||
<div class="generate-task-drawer__field">
|
||||
<label class="generate-task-drawer__label generate-task-drawer__label--required">
|
||||
{{ t("custom.task.prompt") }}:
|
||||
{{ t('custom.task.prompt') }}:
|
||||
</label>
|
||||
|
||||
<div class="generate-task-drawer__prompt-row">
|
||||
@@ -403,26 +418,32 @@ function padTime(value: string): string {
|
||||
class="generate-task-drawer__prompt-select"
|
||||
/>
|
||||
|
||||
<a-button class="generate-task-drawer__prompt-create" size="large" @click="promptDrawerOpen = true">
|
||||
<a-button
|
||||
class="generate-task-drawer__prompt-create"
|
||||
size="large"
|
||||
@click="promptDrawerOpen = true"
|
||||
>
|
||||
<template #icon><PlusOutlined /></template>
|
||||
{{ t("custom.task.createPrompt") }}
|
||||
{{ t('custom.task.createPrompt') }}
|
||||
</a-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
<section v-if="isSchedule" class="generate-task-drawer__panel generate-task-drawer__panel--bordered">
|
||||
<section
|
||||
v-if="isSchedule"
|
||||
class="generate-task-drawer__panel generate-task-drawer__panel--bordered"
|
||||
>
|
||||
<div class="generate-task-drawer__section-head">
|
||||
<div class="generate-task-drawer__section-marker"></div>
|
||||
<h3>{{ t("custom.task.publishSection") }}</h3>
|
||||
<h3>{{ t('custom.task.publishSection') }}</h3>
|
||||
</div>
|
||||
|
||||
<div class="generate-task-drawer__field generate-task-drawer__field--inline">
|
||||
<div>
|
||||
<label class="generate-task-drawer__label">{{ t("custom.task.autoPublish") }}:</label>
|
||||
<label class="generate-task-drawer__label">{{ t('custom.task.autoPublish') }}:</label>
|
||||
<p class="generate-task-drawer__hint generate-task-drawer__hint--compact">
|
||||
{{ t("custom.task.autoPublishHint") }}
|
||||
{{ t('custom.task.autoPublishHint') }}
|
||||
</p>
|
||||
</div>
|
||||
<a-switch v-model:checked="form.autoPublish" />
|
||||
@@ -431,9 +452,9 @@ function padTime(value: string): string {
|
||||
<template v-if="form.autoPublish">
|
||||
<div class="generate-task-drawer__field">
|
||||
<label class="generate-task-drawer__label generate-task-drawer__label--required">
|
||||
{{ t("custom.task.publishAccounts") }}:
|
||||
{{ t('custom.task.publishAccounts') }}:
|
||||
</label>
|
||||
<p class="generate-task-drawer__hint">{{ t("custom.task.publishAccountsHint") }}</p>
|
||||
<p class="generate-task-drawer__hint">{{ t('custom.task.publishAccountsHint') }}</p>
|
||||
|
||||
<a-skeleton
|
||||
v-if="schedulePublishLoading"
|
||||
@@ -441,14 +462,19 @@ function padTime(value: string): string {
|
||||
:title="false"
|
||||
:paragraph="{ rows: 4 }"
|
||||
/>
|
||||
<div v-else-if="schedulePublishAccounts.length" class="generate-task-drawer__account-grid">
|
||||
<div
|
||||
v-else-if="schedulePublishAccounts.length"
|
||||
class="generate-task-drawer__account-grid"
|
||||
>
|
||||
<button
|
||||
v-for="account in schedulePublishAccounts"
|
||||
:key="account.id"
|
||||
type="button"
|
||||
class="generate-task-drawer__account"
|
||||
:class="{
|
||||
'generate-task-drawer__account--active': isSchedulePublishAccountSelected(account.id),
|
||||
'generate-task-drawer__account--active': isSchedulePublishAccountSelected(
|
||||
account.id,
|
||||
),
|
||||
'generate-task-drawer__account--disabled': !account.selectable,
|
||||
}"
|
||||
@click="toggleSchedulePublishAccount(account)"
|
||||
@@ -456,7 +482,10 @@ function padTime(value: string): string {
|
||||
<span class="generate-task-drawer__account-check">
|
||||
<span v-if="isSchedulePublishAccountSelected(account.id)"></span>
|
||||
</span>
|
||||
<span class="generate-task-drawer__account-logo" :style="{ '--account-accent': account.platformAccent }">
|
||||
<span
|
||||
class="generate-task-drawer__account-logo"
|
||||
:style="{ '--account-accent': account.platformAccent }"
|
||||
>
|
||||
<img
|
||||
v-if="account.platformLogoUrl"
|
||||
:src="account.platformLogoUrl"
|
||||
@@ -480,8 +509,8 @@ function padTime(value: string): string {
|
||||
</button>
|
||||
</div>
|
||||
<div v-else class="generate-task-drawer__empty">
|
||||
<strong>{{ t("custom.task.publishAccountEmptyTitle") }}</strong>
|
||||
<p>{{ t("custom.task.publishAccountEmptyHint") }}</p>
|
||||
<strong>{{ t('custom.task.publishAccountEmptyTitle') }}</strong>
|
||||
<p>{{ t('custom.task.publishAccountEmptyHint') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -491,7 +520,7 @@ function padTime(value: string): string {
|
||||
class="generate-task-drawer__label"
|
||||
:class="{ 'generate-task-drawer__label--required': scheduleCoverRequired }"
|
||||
>
|
||||
{{ t("custom.task.cover") }}:
|
||||
{{ t('custom.task.cover') }}:
|
||||
</label>
|
||||
<a-switch
|
||||
:checked="effectiveScheduleCoverEnabled"
|
||||
@@ -500,18 +529,26 @@ function padTime(value: string): string {
|
||||
/>
|
||||
</div>
|
||||
<p class="generate-task-drawer__hint">
|
||||
{{ scheduleCoverRequired ? t("custom.task.scheduleCoverRequiredHint") : t("custom.task.scheduleCoverHint") }}
|
||||
{{
|
||||
scheduleCoverRequired
|
||||
? t('custom.task.scheduleCoverRequiredHint')
|
||||
: t('custom.task.scheduleCoverHint')
|
||||
}}
|
||||
</p>
|
||||
|
||||
<div v-if="effectiveScheduleCoverEnabled" class="generate-task-drawer__cover-body">
|
||||
<div class="generate-task-drawer__cover-preview-wrap">
|
||||
<button type="button" class="generate-task-drawer__cover-preview" @click="coverPickerOpen = true">
|
||||
<button
|
||||
type="button"
|
||||
class="generate-task-drawer__cover-preview"
|
||||
@click="coverPickerOpen = true"
|
||||
>
|
||||
<template v-if="form.coverAssetUrl">
|
||||
<img :src="form.coverAssetUrl" alt="cover preview" />
|
||||
</template>
|
||||
<template v-else>
|
||||
<span class="generate-task-drawer__cover-plus">+</span>
|
||||
<span>{{ t("custom.task.coverUpload") }}</span>
|
||||
<span>{{ t('custom.task.coverUpload') }}</span>
|
||||
</template>
|
||||
</button>
|
||||
|
||||
@@ -534,13 +571,13 @@ function padTime(value: string): string {
|
||||
<section class="generate-task-drawer__panel generate-task-drawer__panel--bordered">
|
||||
<div class="generate-task-drawer__section-head">
|
||||
<div class="generate-task-drawer__section-marker"></div>
|
||||
<h3>{{ t("custom.task.advancedSection") }}</h3>
|
||||
<h3>{{ t('custom.task.advancedSection') }}</h3>
|
||||
</div>
|
||||
|
||||
<div v-if="isSchedule" class="generate-task-drawer__field">
|
||||
<label class="generate-task-drawer__label">{{ t("custom.task.scheduleTime") }}:</label>
|
||||
<label class="generate-task-drawer__label">{{ t('custom.task.scheduleTime') }}:</label>
|
||||
<div class="generate-task-drawer__time-wrapper">
|
||||
<span>{{ t("custom.task.scheduleEveryDay") }}</span>
|
||||
<span>{{ t('custom.task.scheduleEveryDay') }}</span>
|
||||
<a-time-picker
|
||||
v-model:value="form.scheduleTime"
|
||||
value-format="HH:mm:ss"
|
||||
@@ -552,12 +589,14 @@ function padTime(value: string): string {
|
||||
</div>
|
||||
|
||||
<div class="generate-task-drawer__field generate-task-drawer__field--inline">
|
||||
<label class="generate-task-drawer__label">{{ t("custom.task.enableWebSearch") }}:</label>
|
||||
<label class="generate-task-drawer__label">
|
||||
{{ t('custom.task.enableWebSearch') }}:
|
||||
</label>
|
||||
<a-switch v-model:checked="form.enableWebSearch" />
|
||||
</div>
|
||||
|
||||
<div class="generate-task-drawer__field generate-task-drawer__field--narrow">
|
||||
<label class="generate-task-drawer__label">{{ t("custom.task.generateCount") }}:</label>
|
||||
<label class="generate-task-drawer__label">{{ t('custom.task.generateCount') }}:</label>
|
||||
<a-input-number
|
||||
v-model:value="form.generateCount"
|
||||
:min="1"
|
||||
@@ -572,7 +611,7 @@ function padTime(value: string): string {
|
||||
<template #footer>
|
||||
<div class="generate-task-drawer__footer">
|
||||
<a-button size="large" @click="emit('update:open', false)">
|
||||
{{ t("common.cancel") }}
|
||||
{{ t('common.cancel') }}
|
||||
</a-button>
|
||||
<a-button type="primary" size="large" :loading="submitLoading" @click="handleSubmit">
|
||||
{{ submitText }}
|
||||
@@ -619,7 +658,7 @@ function padTime(value: string): string {
|
||||
}
|
||||
|
||||
.generate-task-drawer__body {
|
||||
padding: 0 20px;
|
||||
padding: 0 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
@@ -679,7 +718,7 @@ function padTime(value: string): string {
|
||||
}
|
||||
|
||||
.generate-task-drawer__label--required::before {
|
||||
content: "*";
|
||||
content: '*';
|
||||
margin-right: 4px;
|
||||
color: #ff4d4f;
|
||||
}
|
||||
@@ -729,7 +768,10 @@ function padTime(value: string): string {
|
||||
background: #fff;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
|
||||
transition:
|
||||
border-color 0.2s ease,
|
||||
background 0.2s ease,
|
||||
box-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
.generate-task-drawer__account:hover {
|
||||
|
||||
Reference in New Issue
Block a user