feat(kol): add SSE streaming for prompt assist
- Extract assist runtime (prompt building, response parsing, finalize) from the worker into kol_assist_runtime so the sync streaming path and the async task path share the same logic. - Add POST /kol/manage/assist/stream as a Server-Sent Events endpoint emitting start/delta/completed/error events, and wire it to a streamAssist helper on kolManageApi that reports ApiClientError with the server's error envelope. - Stream generated content live in KolPromptEditor and KolGenerateView, switching KolPromptEditArea to a boolean aiBusy flag and refining the generator page layout. - Add KolAssistStreamEvent to shared types. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, h, ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { ExperimentOutlined, ThunderboltOutlined, LoadingOutlined } from "@ant-design/icons-vue";
|
||||
import { ExperimentOutlined, ThunderboltOutlined } from "@ant-design/icons-vue";
|
||||
import type { KolVariableDefinition, KolVariableType } from "@geo/shared-types";
|
||||
import { Modal } from "ant-design-vue";
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
const props = defineProps<{
|
||||
content: string;
|
||||
variables: KolVariableDefinition[];
|
||||
aiTaskId: string | null;
|
||||
aiBusy: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -37,6 +37,12 @@ type PointerSelectionState = {
|
||||
startY: number;
|
||||
};
|
||||
|
||||
type OverlaySelectionRange = {
|
||||
start: number;
|
||||
end: number;
|
||||
direction: "forward" | "backward";
|
||||
};
|
||||
|
||||
let pointerSelectionState: PointerSelectionState | null = null;
|
||||
|
||||
const editorPlaceholder = "在这里输入提示词内容,可以使用 {{变量名}} 引用左侧定义的变量";
|
||||
@@ -160,7 +166,18 @@ function handleHighlightPointerUp(event: PointerEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasOverlaySelection(highlight)) {
|
||||
const overlaySelection = getOverlaySelectionRange(highlight);
|
||||
if (overlaySelection) {
|
||||
const scrollTop = textarea.scrollTop;
|
||||
const scrollLeft = textarea.scrollLeft;
|
||||
|
||||
textarea.setSelectionRange(
|
||||
overlaySelection.start,
|
||||
overlaySelection.end,
|
||||
overlaySelection.direction,
|
||||
);
|
||||
focusTextareaWithoutScroll(textarea);
|
||||
restoreTextareaScroll(textarea, scrollTop, scrollLeft);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -210,6 +227,29 @@ function hasOverlaySelection(container: HTMLElement): boolean {
|
||||
return !!anchorNode && !!focusNode && container.contains(anchorNode) && container.contains(focusNode);
|
||||
}
|
||||
|
||||
function getOverlaySelectionRange(container: HTMLElement): OverlaySelectionRange | null {
|
||||
if (!hasOverlaySelection(container)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const selection = window.getSelection();
|
||||
if (!selection) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const anchorIndex = resolveCaretIndex(container, selection.anchorNode, selection.anchorOffset);
|
||||
const focusIndex = resolveCaretIndex(container, selection.focusNode, selection.focusOffset);
|
||||
if (anchorIndex === null || focusIndex === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
start: Math.min(anchorIndex, focusIndex),
|
||||
end: Math.max(anchorIndex, focusIndex),
|
||||
direction: anchorIndex <= focusIndex ? "forward" : "backward",
|
||||
};
|
||||
}
|
||||
|
||||
function getCaretIndexFromPoint(container: HTMLElement, event: PointerEvent): number {
|
||||
const browserIndex = getBrowserCaretIndex(container, event);
|
||||
if (browserIndex !== null) {
|
||||
@@ -433,7 +473,7 @@ function escapeAttribute(value: string): string {
|
||||
v-model:value="aiDescription"
|
||||
class="ai-input"
|
||||
:placeholder="t('kol.manage.editor.aiPlaceholder')"
|
||||
:disabled="!!aiTaskId"
|
||||
:disabled="aiBusy"
|
||||
@press-enter="handleAiGenerate"
|
||||
>
|
||||
<template #prefix>
|
||||
@@ -443,7 +483,7 @@ function escapeAttribute(value: string): string {
|
||||
<a-button
|
||||
type="primary"
|
||||
class="ai-btn"
|
||||
:loading="!!aiTaskId"
|
||||
:loading="aiBusy"
|
||||
@click="handleAiGenerate"
|
||||
>
|
||||
<template #icon><ThunderboltOutlined /></template>
|
||||
@@ -451,20 +491,15 @@ function escapeAttribute(value: string): string {
|
||||
</a-button>
|
||||
<a-button
|
||||
class="ai-btn"
|
||||
:disabled="!content || !!aiTaskId"
|
||||
:disabled="!content || aiBusy"
|
||||
@click="emit('ai-optimize')"
|
||||
>
|
||||
{{ t('kol.manage.editor.aiOptimize') }}
|
||||
</a-button>
|
||||
<span v-if="aiBusy" class="ai-status-text">AI 正在处理中...</span>
|
||||
</div>
|
||||
|
||||
<div class="editor-container">
|
||||
<div v-if="aiTaskId" class="ai-loading-overlay">
|
||||
<div class="loading-content">
|
||||
<LoadingOutlined class="loading-icon" />
|
||||
<span>AI 正在思考中...</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
ref="highlightRef"
|
||||
class="prompt-highlight"
|
||||
@@ -512,6 +547,14 @@ function escapeAttribute(value: string): string {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.ai-status-text {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
color: #722ed1;
|
||||
font-size: 13px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.editor-container {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
@@ -576,28 +619,4 @@ function escapeAttribute(value: string): string {
|
||||
color: #bfbfbf;
|
||||
}
|
||||
|
||||
.ai-loading-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(255, 255, 255, 0.7);
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.loading-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
color: #722ed1;
|
||||
}
|
||||
|
||||
.loading-icon {
|
||||
font-size: 32px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, reactive, ref, watch } from "vue";
|
||||
import { computed, nextTick, onBeforeUnmount, reactive, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/vue-query";
|
||||
import { message } from "ant-design-vue";
|
||||
@@ -10,7 +10,7 @@ import KolVariableConfig from "./KolVariableConfig.vue";
|
||||
import KolPromptEditArea from "./KolPromptEditArea.vue";
|
||||
import KolDynamicForm from "./KolDynamicForm.vue";
|
||||
import { kolManageApi } from "@/lib/api";
|
||||
import type { KolCardConfig, KolVariableDefinition } from "@geo/shared-types";
|
||||
import type { KolAssistRequest, KolAssistStreamEvent, KolCardConfig, KolVariableDefinition } from "@geo/shared-types";
|
||||
import { formatError } from "@/lib/errors";
|
||||
import { buildKolPlatformOptions } from "@/lib/kol-platform-options";
|
||||
import { mergeKolCardConfig, parseKolCardConfig } from "@/lib/kol-card-config";
|
||||
@@ -35,7 +35,7 @@ const content = ref("");
|
||||
const variables = ref<KolVariableDefinition[]>([]);
|
||||
const previewOpen = ref(false);
|
||||
const previewValues = ref<Record<string, any>>({});
|
||||
const aiTaskId = ref<string | null>(null);
|
||||
const aiBusy = ref(false);
|
||||
const cardConfig = ref<KolCardConfig>({});
|
||||
const variableConfigRef = ref<{
|
||||
focusVariable: (key: string, options?: { focusInput?: boolean }) => void;
|
||||
@@ -106,57 +106,120 @@ const saveMutation = useMutation({
|
||||
},
|
||||
});
|
||||
|
||||
const { data: assistTask } = useQuery({
|
||||
queryKey: computed(() => ["kol", "assist", aiTaskId.value]),
|
||||
queryFn: () => kolManageApi.getAssist(aiTaskId.value!),
|
||||
enabled: computed(() => !!aiTaskId.value),
|
||||
refetchInterval: (query) => {
|
||||
const status = query.state.data?.status;
|
||||
return status === "completed" || status === "failed" ? false : 2000;
|
||||
},
|
||||
});
|
||||
let aiAssistAbortController: AbortController | null = null;
|
||||
|
||||
watch(
|
||||
() => assistTask.value,
|
||||
(task) => {
|
||||
if (task?.status === "completed" && task.result) {
|
||||
content.value = task.result.content;
|
||||
variables.value = syncKolVariablesWithContent(task.result.content, task.result.schema.variables);
|
||||
aiTaskId.value = null;
|
||||
message.success("AI 处理完成");
|
||||
} else if (task?.status === "failed") {
|
||||
aiTaskId.value = null;
|
||||
message.error(task.error_message || "AI 处理失败");
|
||||
}
|
||||
function applyAssistResult(event: KolAssistStreamEvent) {
|
||||
const nextContent = (event.content ?? "").trim();
|
||||
if (!nextContent) {
|
||||
return;
|
||||
}
|
||||
);
|
||||
|
||||
async function handleAiGenerate(description: string) {
|
||||
content.value = nextContent;
|
||||
variables.value = syncKolVariablesWithContent(
|
||||
nextContent,
|
||||
event.schema?.variables ?? variables.value,
|
||||
);
|
||||
}
|
||||
|
||||
function handleAssistStreamEvent(event: KolAssistStreamEvent): "completed" | "error" | null {
|
||||
if (event.type === "start") {
|
||||
aiBusy.value = true;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (event.type === "delta") {
|
||||
aiBusy.value = true;
|
||||
if (typeof event.content === "string") {
|
||||
content.value = event.content;
|
||||
} else if (typeof event.delta === "string" && event.delta) {
|
||||
content.value += event.delta;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (event.type === "completed") {
|
||||
aiBusy.value = false;
|
||||
applyAssistResult(event);
|
||||
message.success("AI 处理完成");
|
||||
return "completed";
|
||||
}
|
||||
|
||||
if (event.type === "error") {
|
||||
aiBusy.value = false;
|
||||
if (typeof event.content === "string" && event.content.trim()) {
|
||||
content.value = event.content;
|
||||
}
|
||||
message.error(event.error || "AI 处理失败");
|
||||
return "error";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function stopAiAssistStream() {
|
||||
aiAssistAbortController?.abort();
|
||||
aiAssistAbortController = null;
|
||||
aiBusy.value = false;
|
||||
}
|
||||
|
||||
async function runAiAssistStream(payload: KolAssistRequest) {
|
||||
stopAiAssistStream();
|
||||
|
||||
const controller = new AbortController();
|
||||
aiAssistAbortController = controller;
|
||||
aiBusy.value = true;
|
||||
let terminalState: "completed" | "error" | null = null;
|
||||
|
||||
try {
|
||||
const res = await kolManageApi.submitAssist({
|
||||
mode: "generate",
|
||||
description,
|
||||
prompt_id: props.promptId,
|
||||
});
|
||||
aiTaskId.value = res.task_id;
|
||||
await kolManageApi.streamAssist(
|
||||
payload,
|
||||
{
|
||||
onEvent(event) {
|
||||
terminalState = handleAssistStreamEvent(event);
|
||||
},
|
||||
onClose() {
|
||||
if (aiAssistAbortController === controller && terminalState === null) {
|
||||
aiBusy.value = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
controller.signal,
|
||||
);
|
||||
|
||||
if (!controller.signal.aborted && terminalState === null) {
|
||||
aiBusy.value = false;
|
||||
message.error("AI 处理失败");
|
||||
}
|
||||
} catch (error) {
|
||||
if (controller.signal.aborted) {
|
||||
return;
|
||||
}
|
||||
|
||||
aiBusy.value = false;
|
||||
message.error(formatError(error));
|
||||
} finally {
|
||||
if (aiAssistAbortController === controller) {
|
||||
aiAssistAbortController = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function handleAiGenerate(description: string) {
|
||||
await runAiAssistStream({
|
||||
mode: "generate",
|
||||
description,
|
||||
prompt_id: props.promptId,
|
||||
});
|
||||
}
|
||||
|
||||
async function handleAiOptimize() {
|
||||
try {
|
||||
const syncedVariables = syncVariablesFromContent();
|
||||
const res = await kolManageApi.submitAssist({
|
||||
mode: "optimize",
|
||||
current_content: content.value,
|
||||
schema: { variables: syncedVariables },
|
||||
prompt_id: props.promptId,
|
||||
});
|
||||
aiTaskId.value = res.task_id;
|
||||
} catch (error) {
|
||||
message.error(formatError(error));
|
||||
}
|
||||
const syncedVariables = syncVariablesFromContent();
|
||||
await runAiAssistStream({
|
||||
mode: "optimize",
|
||||
current_content: content.value,
|
||||
schema: { variables: syncedVariables },
|
||||
prompt_id: props.promptId,
|
||||
});
|
||||
}
|
||||
|
||||
function buildPromptPayload(nextVariables: KolVariableDefinition[] = variables.value) {
|
||||
@@ -253,6 +316,10 @@ function statusLabel(status?: string): string {
|
||||
if (status === "archived") return t("kol.manage.status.archived");
|
||||
return t("kol.manage.status.draft");
|
||||
}
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
stopAiAssistStream();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -331,7 +398,7 @@ function statusLabel(status?: string): string {
|
||||
<KolPromptEditArea
|
||||
v-model:content="content"
|
||||
v-model:variables="variables"
|
||||
:ai-task-id="aiTaskId"
|
||||
:ai-busy="aiBusy"
|
||||
@ai-generate="handleAiGenerate"
|
||||
@ai-optimize="handleAiOptimize"
|
||||
@focus-variable="handleFocusVariable"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createApiClient } from "@geo/http-client";
|
||||
import { ApiClientError, createApiClient } from "@geo/http-client";
|
||||
import type {
|
||||
ApiEnvelope,
|
||||
ArticleDetail,
|
||||
@@ -29,6 +29,7 @@ import type {
|
||||
KnowledgeTextItemRequest,
|
||||
KnowledgeURLItemRequest,
|
||||
KolAssistRequest,
|
||||
KolAssistStreamEvent,
|
||||
KolAssistSubmitResponse,
|
||||
KolAssistTask,
|
||||
KolPackageSummary,
|
||||
@@ -384,6 +385,27 @@ export const kolManageApi = {
|
||||
body,
|
||||
);
|
||||
},
|
||||
streamAssist(
|
||||
body: KolAssistRequest,
|
||||
handlers: {
|
||||
onEvent: (event: KolAssistStreamEvent) => void;
|
||||
onClose?: () => void;
|
||||
},
|
||||
signal: AbortSignal,
|
||||
) {
|
||||
return subscribeSSE<KolAssistStreamEvent>(
|
||||
"/api/tenant/kol/manage/assist/stream",
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
},
|
||||
handlers,
|
||||
signal,
|
||||
);
|
||||
},
|
||||
getAssist(id: string) {
|
||||
return apiClient.get<KolAssistTask>(`/api/tenant/kol/manage/assist/${id}`);
|
||||
},
|
||||
@@ -701,7 +723,7 @@ async function subscribeSSE<TEvent extends SSEEventShape>(
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`stream request failed with status ${response.status}`);
|
||||
throw await buildSSERequestError(response);
|
||||
}
|
||||
if (!response.body) {
|
||||
throw new Error("stream response body is empty");
|
||||
@@ -730,6 +752,44 @@ async function subscribeSSE<TEvent extends SSEEventShape>(
|
||||
}
|
||||
}
|
||||
|
||||
type SSEErrorEnvelope = {
|
||||
code?: number;
|
||||
message?: string;
|
||||
detail?: string;
|
||||
request_id?: string;
|
||||
};
|
||||
|
||||
async function buildSSERequestError(response: Response): Promise<ApiClientError> {
|
||||
try {
|
||||
const payload = (await response.clone().json()) as SSEErrorEnvelope | null;
|
||||
if (payload && typeof payload === "object" && !Array.isArray(payload)) {
|
||||
return new ApiClientError({
|
||||
message: payload.message ?? "unknown_error",
|
||||
code: payload.code,
|
||||
status: response.status,
|
||||
detail: payload.detail,
|
||||
requestId: payload.request_id,
|
||||
});
|
||||
}
|
||||
} catch {
|
||||
// Ignore JSON parse errors and fall back to a generic error below.
|
||||
}
|
||||
|
||||
let detail: string | undefined;
|
||||
try {
|
||||
const text = (await response.text()).trim();
|
||||
detail = text || undefined;
|
||||
} catch {
|
||||
detail = undefined;
|
||||
}
|
||||
|
||||
return new ApiClientError({
|
||||
message: "unknown_error",
|
||||
status: response.status,
|
||||
detail: detail ?? `stream request failed with status ${response.status}`,
|
||||
});
|
||||
}
|
||||
|
||||
export const brandsApi = {
|
||||
list() {
|
||||
return apiClient.get<Brand[]>("/api/tenant/brands");
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useRoute, useRouter } from "vue-router";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useMutation, useQuery } from "@tanstack/vue-query";
|
||||
import { message } from "ant-design-vue";
|
||||
import { ArrowLeftOutlined, ThunderboltOutlined } from "@ant-design/icons-vue";
|
||||
import { LeftOutlined } from "@ant-design/icons-vue";
|
||||
import { kolGenerateApi } from "@/lib/api";
|
||||
import KolDynamicForm from "@/components/kol/KolDynamicForm.vue";
|
||||
import KnowledgeGroupSelect from "@/components/KnowledgeGroupSelect.vue";
|
||||
@@ -78,11 +78,11 @@ function handleBack() {
|
||||
}
|
||||
|
||||
function handleSubmit() {
|
||||
const schema = schemaQuery.data.value;
|
||||
if (!schema?.schema_json?.variables) return;
|
||||
const schemaValue = schemaQuery.data.value;
|
||||
if (!schemaValue?.schema_json?.variables) return;
|
||||
|
||||
const missingLabels: string[] = [];
|
||||
schema.schema_json.variables.forEach((v) => {
|
||||
schemaValue.schema_json.variables.forEach((v) => {
|
||||
const normalizedVariable = normalizeKolVariableDefinition(v);
|
||||
if (normalizedVariable.required && isKolVariableValueEmpty(normalizedVariable, values.value[fieldKey(v.key, v.id)])) {
|
||||
missingLabels.push(v.label);
|
||||
@@ -99,36 +99,39 @@ function handleSubmit() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="kol-generate-view">
|
||||
<div class="view-header">
|
||||
<a-button type="link" @click="handleBack" class="back-btn">
|
||||
<template #icon><ArrowLeftOutlined /></template>
|
||||
{{ t("common.back") }}
|
||||
</a-button>
|
||||
</div>
|
||||
|
||||
<div class="wizard-page">
|
||||
<div v-if="schemaQuery.isPending.value" class="loading-state">
|
||||
<a-spin size="large" />
|
||||
</div>
|
||||
|
||||
<div v-else-if="schema" class="view-content">
|
||||
<a-row :gutter="24" justify="center">
|
||||
<a-col :xs="24" :lg="16" :xl="12">
|
||||
<a-card class="generate-card">
|
||||
<template #title>
|
||||
<div class="card-header">
|
||||
<span class="package-name">{{ schema.package_name }}</span>
|
||||
<span class="divider">/</span>
|
||||
<span class="prompt-name">{{ schema.prompt_name }}</span>
|
||||
<a-tag v-if="schema.platform_hint" color="cyan" class="platform-badge">
|
||||
{{ schema.platform_hint }}
|
||||
</a-tag>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="schema">
|
||||
<header class="wizard-page__header">
|
||||
<div class="header-left">
|
||||
<a-button type="text" shape="circle" @click="handleBack">
|
||||
<template #icon><LeftOutlined /></template>
|
||||
</a-button>
|
||||
<div class="header-title-box">
|
||||
<h2 class="header-title">
|
||||
{{ schema.package_name }}
|
||||
<span class="divider">/</span>
|
||||
{{ schema.prompt_name }}
|
||||
<a-tag v-if="schema.platform_hint" color="cyan" class="platform-badge">
|
||||
{{ schema.platform_hint }}
|
||||
</a-tag>
|
||||
</h2>
|
||||
<p class="header-eyebrow">{{ t("kol.generate.fillVariables") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="hint-text">
|
||||
<ThunderboltOutlined class="hint-icon" />
|
||||
{{ t("kol.generate.fillVariables") }}
|
||||
<main class="wizard-page__main">
|
||||
<section class="wizard-section">
|
||||
<div class="wizard-card">
|
||||
<div class="wizard-card__header" style="margin-bottom: 24px;">
|
||||
<div>
|
||||
<h3>{{ t("kol.generate.fillVariables") }}</h3>
|
||||
<p>根据设定提供相关信息</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="allowWebSearch || allowUserKnowledge" class="capability-card">
|
||||
@@ -150,7 +153,6 @@ function handleSubmit() {
|
||||
:disabled="generateMutation.isPending.value"
|
||||
placeholder="可选,选择你自己的知识库分组辅助生成"
|
||||
/>
|
||||
<div class="capability-hint">只会使用你当前租户下可访问的知识库分组。</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -159,37 +161,32 @@ function handleSubmit() {
|
||||
:variables="schema.schema_json.variables"
|
||||
class="form-body"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<div class="form-actions">
|
||||
<a-button
|
||||
type="primary"
|
||||
size="large"
|
||||
block
|
||||
:loading="generateMutation.isPending.value"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
{{ t("kol.generate.submit") }}
|
||||
</a-button>
|
||||
</div>
|
||||
</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
<footer class="wizard-page__footer">
|
||||
<div></div>
|
||||
<div class="footer-actions">
|
||||
<a-button
|
||||
type="primary"
|
||||
:loading="generateMutation.isPending.value"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
{{ t("kol.generate.submit") }}
|
||||
</a-button>
|
||||
</div>
|
||||
</footer>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.kol-generate-view {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.view-header {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.back-btn {
|
||||
padding: 0;
|
||||
color: #595959;
|
||||
.wizard-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: calc(100vh - 120px);
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.loading-state {
|
||||
@@ -198,60 +195,107 @@ function handleSubmit() {
|
||||
padding: 100px;
|
||||
}
|
||||
|
||||
.generate-card {
|
||||
border-radius: 12px;
|
||||
border: 1px solid #e6edf5;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
|
||||
}
|
||||
|
||||
.card-header {
|
||||
.wizard-page__header {
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
padding: 16px 32px;
|
||||
border-bottom: 1px solid #edf2f7;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.package-name {
|
||||
color: #8c8c8c;
|
||||
font-weight: 400;
|
||||
.header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.header-title-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.header-title {
|
||||
margin: 0;
|
||||
color: #111827;
|
||||
font-size: 20px;
|
||||
font-weight: 800;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.divider {
|
||||
margin: 0 8px;
|
||||
color: #d9d9d9;
|
||||
}
|
||||
|
||||
.prompt-name {
|
||||
color: #1a1a1a;
|
||||
font-weight: 600;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.platform-badge {
|
||||
margin-left: 4px;
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.hint-text {
|
||||
margin-bottom: 24px;
|
||||
padding: 12px 16px;
|
||||
background: #f0f7ff;
|
||||
border-radius: 8px;
|
||||
color: #003a8c;
|
||||
font-size: 14px;
|
||||
.header-eyebrow {
|
||||
margin: 0;
|
||||
color: #6d7c94;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.wizard-page__main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
max-width: 860px;
|
||||
padding: 24px 32px 64px;
|
||||
}
|
||||
|
||||
.wizard-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.wizard-card {
|
||||
padding: 32px 0;
|
||||
}
|
||||
|
||||
.wizard-card__header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.wizard-card__header h3 {
|
||||
margin: 0;
|
||||
color: #111827;
|
||||
font-size: 16px;
|
||||
font-weight: 800;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.hint-icon {
|
||||
color: #1890ff;
|
||||
.wizard-card__header h3::before {
|
||||
content: "";
|
||||
display: inline-block;
|
||||
width: 4px;
|
||||
height: 16px;
|
||||
border-radius: 2px;
|
||||
background: #111827;
|
||||
margin-right: 12px;
|
||||
}
|
||||
|
||||
.form-body {
|
||||
margin-bottom: 24px;
|
||||
.wizard-card__header p {
|
||||
margin: 6px 0 0 16px;
|
||||
color: #667085;
|
||||
font-size: 13px;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.capability-card {
|
||||
margin-bottom: 24px;
|
||||
padding: 16px;
|
||||
margin-bottom: 32px;
|
||||
padding: 20px;
|
||||
border: 1px solid #e6edf5;
|
||||
border-radius: 12px;
|
||||
background: #fafcff;
|
||||
@@ -265,7 +309,7 @@ function handleSubmit() {
|
||||
}
|
||||
|
||||
.capability-knowledge {
|
||||
margin-top: 16px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.capability-copy {
|
||||
@@ -286,7 +330,43 @@ function handleSubmit() {
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
margin-top: 32px;
|
||||
.wizard-page__footer {
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
z-index: 100;
|
||||
margin-top: auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 16px 24px;
|
||||
border-top: 1px solid rgba(20, 44, 88, 0.08);
|
||||
backdrop-filter: blur(14px);
|
||||
background: rgba(255, 255, 255, 0.88);
|
||||
}
|
||||
|
||||
.footer-actions {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.wizard-page__main {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.wizard-card {
|
||||
padding: 18px 0;
|
||||
}
|
||||
|
||||
.wizard-page__footer {
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.footer-actions {
|
||||
width: 100%;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -2545,7 +2545,7 @@ function onStructureDragEnd(): void {
|
||||
.wizard-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: calc(100vh - 64px);
|
||||
min-height: calc(100vh - 120px);
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import { articlesApi, templatesApi, workspaceApi } from "@/lib/api";
|
||||
import { buildArticleClipboardContent, resolveArticleActionState } from "@/lib/article-list-actions";
|
||||
import { formatError } from "@/lib/errors";
|
||||
import {
|
||||
formatDateTime,
|
||||
getGenerateStatusMeta,
|
||||
getPublishStatusMeta,
|
||||
getTemplateMeta,
|
||||
@@ -689,6 +690,9 @@ function refreshRecords(): void {
|
||||
<h4 class="templates-view__kol-title" :title="card.prompt_name">{{ card.prompt_name }}</h4>
|
||||
<div class="templates-view__kol-meta-row">
|
||||
<span class="templates-view__kol-prompt" :title="card.package_name">{{ card.package_name }}</span>
|
||||
<span class="templates-view__kol-updated-at">
|
||||
{{ t("common.updatedAt") }}: {{ formatDateTime(card.updated_at) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="templates-view__kol-footer">
|
||||
@@ -1171,9 +1175,9 @@ function refreshRecords(): void {
|
||||
|
||||
.templates-view__kol-meta-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
@@ -1188,6 +1192,12 @@ function refreshRecords(): void {
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.templates-view__kol-updated-at {
|
||||
font-size: 12px;
|
||||
color: #9ca3af;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.templates-view__kol-footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
@@ -27,8 +27,8 @@ import ArticleSourceMeta from "@/components/ArticleSourceMeta.vue";
|
||||
import ArticleDetailDrawer from "@/components/ArticleDetailDrawer.vue";
|
||||
import PublishArticleModal from "@/components/PublishArticleModal.vue";
|
||||
import { articlesApi, workspaceApi } from "@/lib/api";
|
||||
import { getTemplateMeta } from "@/lib/display";
|
||||
import { buildArticleClipboardContent, resolveArticleActionState } from "@/lib/article-list-actions";
|
||||
import { formatDateTime, getTemplateMeta } from "@/lib/display";
|
||||
import { formatError } from "@/lib/errors";
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
@@ -303,6 +303,9 @@ function refreshDashboard(): void {
|
||||
<h4 class="kol-card-title" :title="card.prompt_name">{{ card.prompt_name }}</h4>
|
||||
<div class="kol-card-meta-row">
|
||||
<span class="kol-card-prompt" :title="card.package_name">{{ card.package_name }}</span>
|
||||
<span class="kol-card-updated-at">
|
||||
{{ t("common.updatedAt") }}: {{ formatDateTime(card.updated_at) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="kol-card-footer">
|
||||
@@ -747,9 +750,9 @@ function refreshDashboard(): void {
|
||||
|
||||
.kol-card-meta-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
@@ -764,6 +767,12 @@ function refreshDashboard(): void {
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.kol-card-updated-at {
|
||||
font-size: 12px;
|
||||
color: #9ca3af;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.kol-card-footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
Reference in New Issue
Block a user