Skip to content

BillionMail gives you open-source MailServer, NewsLetter, Email Marketing — fully self-hosted, dev-friendly, and free from monthly fees. Join the discord: https://discord.gg/asfXzBUhZr

Optimize the business logic of AI templates

albert20860bcf7895
diff --git a/core/frontend/src/views/domain/pages/editDomain/components/DomainConfiguration.vue b/core/frontend/src/views/domain/pages/editDomain/components/DomainConfiguration.vue
index 947c1c38..b9ae236a 100644
--- a/core/frontend/src/views/domain/pages/editDomain/components/DomainConfiguration.vue
+++ b/core/frontend/src/views/domain/pages/editDomain/components/DomainConfiguration.vue
@@ -43,7 +43,7 @@
<n-form-item label="Automatically create brand information">
<n-switch v-model:value="initAi"></n-switch>
</n-form-item>
- <n-alert style="margin: 0 0 15px 0;" type="warning" :show-icon="false">
+ <n-alert style="margin: 0 0 15px 0;" type="warning" :show-icon="false" v-if="!configurationStatus">
<div class="w-100% flex justify-between items-center">
<span class="mr-5">To use this feature, you need to integrate an AI model first.</span>
<n-button type="primary">Integrate immediately</n-button>
@@ -125,7 +125,8 @@
mailboxes,
catch_email,
initAi,
- urls
+ urls,
+ configurationStatus
} = getEditDomainStoreData()
const route = useRoute()
const domain = route.params.domain as any
diff --git a/core/frontend/src/views/domain/pages/editDomain/components/ProjectDetails.vue b/core/frontend/src/views/domain/pages/editDomain/components/ProjectDetails.vue
index 1fb11c24..439de3e4 100644
--- a/core/frontend/src/views/domain/pages/editDomain/components/ProjectDetails.vue
+++ b/core/frontend/src/views/domain/pages/editDomain/components/ProjectDetails.vue
@@ -22,10 +22,6 @@
<template #label><span class="form-label">Description</span></template>
<n-input type="textarea" :rows="7" v-model:value="description"></n-input>
</n-form-item>
- <n-form-item>
- <template #label><span class="form-label">Industry</span></template>
- <n-select :options="industryOptions" v-model:value="industry"></n-select>
- </n-form-item>
</n-form>
</n-card>
@@ -50,12 +46,13 @@
<div class="operation-item">
<div class="operation-tit">Primary Logo</div>
<div class="operation-sub-tit">Horizontal version for headers</div>
- <div class="logo-area">
+ <div class="logo-area" @click="choosePrimary">
<div class="upload-logo-placeholder" v-if="!primary_logo">
<i class="i-carbon:cloud-upload text-8"></i>
<span>Primary Logo</span>
</div>
- <n-image :src="primary_logo" class="w-100% h-100%" v-else>
+ <n-image :src="primary_logo" height="100" width="150" object-fit="contain" v-else
+ preview-disabled>
<template #error>
<div class="w-100% h-100% flex justify-center items-center flex-col gap-1.25">
<i class="i-mingcute:pic-line text-15"></i>
@@ -63,17 +60,20 @@
</div>
</template>
</n-image>
+ <input type="file" v-show="false" ref="primaryUpload"
+ @change="(event) => faviconChange(event, 'primary')">
</div>
</div>
<div class="operation-item">
<div class="operation-tit">Secondary Logo</div>
<div class="operation-sub-tit">Vertical/stacked version</div>
- <div class="logo-area">
+ <div class="logo-area" @click="chooseSecondary">
<div class="upload-logo-placeholder" v-if="!secondary_logo">
<i class="i-carbon:cloud-upload text-8"></i>
<span>Primary Logo</span>
</div>
- <n-image :src="secondary_logo" class="w-100% h-100%" v-else>
+ <n-image :src="secondary_logo" height="100" width="150" object-fit="contain" v-else
+ preview-disabled>
<template #error>
<div class="w-100% h-100% flex justify-center items-center flex-col gap-1.25">
<i class="i-mingcute:pic-line text-15"></i>
@@ -81,17 +81,19 @@
</div>
</template>
</n-image>
+ <input type="file" v-show="false" ref="secondaryUpload"
+ @change="(event) => faviconChange(event, 'secondary')">
</div>
</div>
<div class="operation-item">
<div class="operation-tit">Favicon</div>
<div class="operation-sub-tit">Icon for browser tabs</div>
- <div class="logo-area">
+ <div class="logo-area" @click="chooseFavicon">
<div class="upload-logo-placeholder" v-if="!favicon">
<i class="i-carbon:cloud-upload text-8"></i>
<span>Primary Logo</span>
</div>
- <n-image :src="favicon" class="w-100% h-100%" v-else>
+ <n-image :src="favicon" height="40" width="60" object-fit="contain" v-else preview-disabled>
<template #error>
<div class="w-100% h-100% flex justify-center items-center flex-col gap-1.25">
<i class="i-mingcute:pic-line text-15"></i>
@@ -99,6 +101,8 @@
</div>
</template>
</n-image>
+ <input type="file" v-show="false" ref="faviconUpload"
+ @change="(event) => faviconChange(event, 'favicon')">
</div>
<div class="operation-tools">
<div class="tool-item">
@@ -148,7 +152,7 @@
</div>
<div class="operation">
<n-button type="primary" ghost @click="openEditKnowledge(item)">Edit</n-button>
- <n-button type="primary" ghost>Preiview</n-button>
+ <n-button type="primary" ghost @click="previewKnowledgeBaseContent(item)">Preiview</n-button>
</div>
</div>
</n-card>
@@ -176,13 +180,39 @@
</template>
</n-modal>
+ <!-- Pview knowledge base -->
+ <n-modal preset="card" draggable :close-on-esc="false" :mask-closable="false" :title="knowledgeBasePreviewTit"
+ class="w-180" v-model:show="knowledgeBasePreview">
+ <div class="preview-wrapper">
+ <n-scrollbar style="max-height: 700px;">
+ <div v-html="mdRes"></div>
+ </n-scrollbar>
+ </div>
+ <template #footer>
+ <div class="flex justify-end">
+ <n-button>Close</n-button>
+ </div>
+ </template>
+ </n-modal>
+
</template>
<script setup lang="ts">
import { confirm } from '@/utils';
- import { getProjectDetail, updateProjectDetail, createKnowledgeBase, closeKnowledgeModal, openEditKnowledge, updateKnowledgeBase, deleteKnowledgeBase } from '../controller/projectDetail.controller';
+ import {
+ getProjectDetail,
+ updateProjectDetail,
+ createKnowledgeBase,
+ closeKnowledgeModal,
+ openEditKnowledge,
+ updateKnowledgeBase,
+ deleteKnowledgeBase,
+ previewKnowledgeBaseContent,
+ uploadImage
+ } from '../controller/projectDetail.controller';
import { getEditDomainStoreData } from '../store';
import { KnowledgeBase } from '../dto';
+ import mk from "markdown-it"
const {
project_name,
description,
@@ -194,7 +224,10 @@
knowledgeModalShow,
isEditKnowledge,
knowledgeTitle,
- knowledgeContent
+ knowledgeContent,
+ knowledge_base_content,
+ knowledgeBasePreview,
+ knowledgeBasePreviewTit
} = getEditDomainStoreData()
const route = useRoute()
const industryOptions = ref([
@@ -204,7 +237,15 @@
}
])
const domain = route.params.domain as string
+ const md = mk()
+ const mdRes = ref("")
+ const faviconUpload = ref()
+ const secondaryUpload = ref()
+ const primaryUpload = ref()
+ watch(knowledge_base_content, (val) => {
+ mdRes.value = md.render(val)
+ })
getProjectDetail(domain)
/**
@@ -230,6 +271,51 @@
}
})
}
+
+ /**
+ * @description Choose favicon file
+ */
+ function chooseFavicon() {
+ faviconUpload.value.click()
+ }
+
+ /**
+ * @description Choose secondary file
+ */
+ function chooseSecondary(){
+ secondaryUpload.value.click()
+ }
+
+ /**
+ * @description Choose primary file
+ */
+ function choosePrimary(){
+ primaryUpload.value.click()
+ }
+
+ /**
+ * @description Favicon file change
+ */
+ function faviconChange(event: Event, type: string) {
+ const file = (event.target as HTMLInputElement).files![0]
+ if (!file) return
+ const reader = new FileReader();
+ reader.onload = async function (event: ProgressEvent<FileReader>) {
+ const base64String = event.target?.result as string;
+ if (type == "favicon") {
+ uploadImage(domain, base64String, file.name, "favicon", "favicon")
+ }
+
+ if (type == "secondary") {
+ uploadImage(domain, base64String, file.name, "secondary logo", "secondary logo")
+ }
+
+ if (type == "primary") {
+ uploadImage(domain, base64String, file.name, "primary logo", "primary logo")
+ }
+ }
+ reader.readAsDataURL(file)
+ }
</script>
<style scoped lang="scss">
@@ -278,6 +364,9 @@
border: 1px solid var(--color-border-1);
border-radius: 16px;
margin-bottom: 10px;
+ @include base.row-flex;
+ justify-content: center;
+ align-items: center;
.upload-logo-placeholder {
@include base.col-flex-center;
@@ -354,4 +443,17 @@
}
}
}
+
+
+
+</style>
+
+<style>
+ .preview-wrapper {
+ max-height: 700px;
+
+ img {
+ max-width: 100% !important;
+ }
+ }
</style>
\ No newline at end of file
diff --git a/core/frontend/src/views/domain/pages/editDomain/components/Styling.vue b/core/frontend/src/views/domain/pages/editDomain/components/Styling.vue
index c5f1a9a4..699a9c9d 100644
--- a/core/frontend/src/views/domain/pages/editDomain/components/Styling.vue
+++ b/core/frontend/src/views/domain/pages/editDomain/components/Styling.vue
@@ -1,7 +1,7 @@
<template>
<div class="content-wrapper">
<n-card class="mb-5">
- <div class="page-tit">
+ <div class="page-tit mb-5">
<div class="left-tit">
<div class="back-tool">
<i class="i-ri:apps-fill text-6"></i>
@@ -11,8 +11,6 @@
</span>
</div>
</div>
- </n-card>
- <n-card class="mb-5">
<n-form>
<n-form-item>
<template #label><span class="form-label">Accent Color</span></template>
@@ -46,23 +44,77 @@
<n-input v-model:value="container_background"></n-input>
</div>
</n-form-item>
+ <n-form-item>
+ <template #label><span class="form-label">Link footer color</span></template>
+ <div class="flex justify-between gap-2.5 w-100%">
+ <n-color-picker style="width: 50px;" :modes="['hex', 'rgb', 'hsl', 'hsv']"
+ :render-label="colorRenderLabel" v-model:value="link_footer_color"></n-color-picker>
+ <n-input v-model:value="link_footer_color"></n-input>
+ </div>
+ </n-form-item>
+ <n-form-item>
+ <template #label><span class="form-label">Link social color</span></template>
+ <div class="flex justify-between gap-2.5 w-100%">
+ <n-color-picker style="width: 50px;" :modes="['hex', 'rgb', 'hsl', 'hsv']"
+ :render-label="colorRenderLabel" v-model:value="link_social_color"></n-color-picker>
+ <n-input v-model:value="link_social_color"></n-input>
+ </div>
+ </n-form-item>
</n-form>
</n-card>
- <!-- <n-card>
- <div class="page-tit mb-2.5">
+
+ <n-card class="mb-5">
+ <div class="page-tit mb-5">
<div class="left-tit">
<div class="back-tool">
<i class="i-ri:apps-fill text-6"></i>
</div>
<span class="tit-content">
- Custom CSS
+ Typography
</span>
</div>
</div>
- <div class="sub-tit mb-5">Add custom CSS styles to your email template</div>
- <n-input type="textarea" :rows="15"></n-input>
- </n-card> -->
+ <n-form>
+ <n-form-item>
+ <template #label><span class="form-label">Heading Font</span></template>
+ <n-input v-model:value="heading_font"></n-input>
+ </n-form-item>
+
+ <n-card class="form-desc">
+ <div class="container">
+ <div class="form-label">Preview:</div>
+ <div class="desc" :style="{ fontFamily: heading_font }">The quick brown fox jumps over the lazy
+ dog
+ </div>
+ </div>
+ </n-card>
+ </n-form>
+
+ <n-form class="mt-5">
+ <n-form-item>
+ <template #label><span class="form-label">Body Font</span></template>
+ <n-input v-model:value="body_font"></n-input>
+ </n-form-item>
+
+ <n-card class="form-desc">
+ <div class="container">
+ <div class="form-label">Preview:</div>
+ <div class="desc" :style="{ fontFamily: body_font }">The quick brown fox jumps over the lazy dog
+ </div>
+ </div>
+ </n-card>
+ </n-form>
+ </n-card>
+
+
+ <n-card>
+ <div class="attention">
+ <div class="attention-tit">Typography Guidelines:</div>
+ <div class="attention-item">Use web-safe fonts for better compatibility</div>
+ <div class="attention-item">Always include fallback fonts for better performance</div>
+ </div>
+ </n-card>
</div>
</template>
@@ -72,8 +124,12 @@
const {
accent_color,
text_color,
+ link_footer_color,
+ link_social_color,
page_background,
container_background,
+ heading_font,
+ body_font,
} = getEditDomainStoreData()
const route = useRoute()
const domain = route.params.domain as string
@@ -103,5 +159,43 @@
.sub-tit {
color: var(--color-text-1);
}
+
+ .form-desc {
+ border: 1px solid var(--color-border-1);
+
+ .container {
+ @include base.col-flex-start;
+ align-items: flex-start;
+ gap: 10px;
+
+ .desc {
+ color: var(--color-text-1);
+ font-size: 14px;
+ }
+ }
+ }
+
+ .attention {
+ .attention-tit {
+ margin-bottom: 10px;
+ }
+
+ .attention-item {
+ padding-left: 10px;
+ position: relative;
+
+ &::before {
+ content: "";
+ display: block;
+ width: 4px;
+ height: 4px;
+ background: var(--color-text-2);
+ border-radius: 50%;
+ position: absolute;
+ left: 0;
+ top: 7px;
+ }
+ }
+ }
}
</style>
\ No newline at end of file
diff --git a/core/frontend/src/views/domain/pages/editDomain/controller/domainConfiguration.controller.ts b/core/frontend/src/views/domain/pages/editDomain/controller/domainConfiguration.controller.ts
index 877dd25d..8bdc1bae 100644
--- a/core/frontend/src/views/domain/pages/editDomain/controller/domainConfiguration.controller.ts
+++ b/core/frontend/src/views/domain/pages/editDomain/controller/domainConfiguration.controller.ts
@@ -2,6 +2,8 @@ import { instance } from "@/api"
import { instanceOptions } from "./companyProfile.controller"
import { getEditDomainStoreData } from "../store"
import { getByteUnit } from '@/utils'
+
+
/**
* @description Get domain detail
*/
@@ -21,6 +23,20 @@ export async function getDomainDetail(domain: string) {
unit.value = quotaAndUnit[1]
mailboxes.value = list[0].mailboxes
catch_email.value = list[0].email
+ await configurationStatus()
+ } catch (error) {
+ console.warn(error)
+ }
+}
+
+/**
+ * @description Configuration status
+ */
+export async function configurationStatus() {
+ const { configurationStatus } = getEditDomainStoreData()
+ try {
+ const res = await instance.post("/askai/supplier/status") as Record<string, boolean>
+ configurationStatus.value = res.is_configured
} catch (error) {
console.warn(error)
}
diff --git a/core/frontend/src/views/domain/pages/editDomain/controller/projectDetail.controller.ts b/core/frontend/src/views/domain/pages/editDomain/controller/projectDetail.controller.ts
index 15f3c751..c1ee812c 100644
--- a/core/frontend/src/views/domain/pages/editDomain/controller/projectDetail.controller.ts
+++ b/core/frontend/src/views/domain/pages/editDomain/controller/projectDetail.controller.ts
@@ -124,4 +124,33 @@ export async function deleteKnowledgeBase(domain: string, knowledge: KnowledgeBa
} catch (error) {
console.warn(error)
}
+}
+
+/**
+ * @description Preview knowledge base content
+ */
+export function previewKnowledgeBaseContent(knowledge_base: KnowledgeBase) {
+ const { knowledge_base_content, knowledgeBasePreview, knowledgeBasePreviewTit } = getEditDomainStoreData()
+ knowledgeBasePreview.value = true
+ knowledge_base_content.value = knowledge_base.content
+ knowledgeBasePreviewTit.value = knowledge_base.title
+}
+
+/**
+ * @description Upload image
+ */
+export async function uploadImage(domain: string, image: string, filename: string, alt_text: string, image_tag: string) {
+ try {
+ const res = await instance.post("/askai/project/upload_image", {
+ domain,
+ image,
+ filename,
+ alt_text,
+ image_tag
+ }, instanceOptions)
+ console.log(res)
+ } catch (error) {
+ console.warn((error))
+ return ""
+ }
}
\ No newline at end of file
diff --git a/core/frontend/src/views/domain/pages/editDomain/controller/styleing.controller.ts b/core/frontend/src/views/domain/pages/editDomain/controller/styleing.controller.ts
index b67bdefc..461c2b9c 100644
--- a/core/frontend/src/views/domain/pages/editDomain/controller/styleing.controller.ts
+++ b/core/frontend/src/views/domain/pages/editDomain/controller/styleing.controller.ts
@@ -29,7 +29,6 @@ export async function getStylingInfo(domain: string) {
link_footer_color.value = res.link_footer_color
heading_font.value = res.heading_font
body_font.value = res.body_font
-
hasGotStyleing.value = true
} catch (error) {
console.warn(error)
@@ -45,6 +44,10 @@ export async function updateStyleingInfo(domain: string) {
text_color,
page_background,
container_background,
+ link_social_color,
+ link_footer_color,
+ heading_font,
+ body_font,
} = getEditDomainStoreData()
try {
await instance.post("/askai/project/modify_style_config", {
@@ -53,6 +56,10 @@ export async function updateStyleingInfo(domain: string) {
text_color: text_color.value,
page_background: page_background.value,
container_background: container_background.value,
+ link_social_color:link_social_color.value,
+ link_footer_color:link_footer_color.value,
+ heading_font:heading_font.value,
+ body_font:body_font.value
}, instanceOptions) as Record<string, any>
} catch (error) {
console.warn(error)
diff --git a/core/frontend/src/views/domain/pages/editDomain/index.vue b/core/frontend/src/views/domain/pages/editDomain/index.vue
index 32e7ccdf..25a23556 100644
--- a/core/frontend/src/views/domain/pages/editDomain/index.vue
+++ b/core/frontend/src/views/domain/pages/editDomain/index.vue
@@ -56,22 +56,20 @@
"Project Details",
"Company Profile",
"Styling",
- "Typography",
"Sitemap",
"Footer Settings",
"AI Settings"
])
const activeTab = ref("Domain Configuration")
- const contentMap = ref(new Map([
+ const contentMap = new Map([
["Domain Configuration", DomainConfiguration],
["Project Details", ProjectDetails],
["Company Profile", CompanyProile],
["Styling", Styling],
- ["Typography", Typography],
["Sitemap", Sitemap],
["Footer Settings", FooterSettings],
["AI Settings", AISettings],
- ]))
+ ])
const route = useRoute()
const domain = route.params.domain as string
diff --git a/core/frontend/src/views/domain/pages/editDomain/store/index.ts b/core/frontend/src/views/domain/pages/editDomain/store/index.ts
index 9969e2b3..2e93ac9e 100644
--- a/core/frontend/src/views/domain/pages/editDomain/store/index.ts
+++ b/core/frontend/src/views/domain/pages/editDomain/store/index.ts
@@ -10,6 +10,8 @@ const editDomainStore = defineStore("editDomainStoroe", () => {
const catch_email = ref("")
const initAi = ref(false)
const urls = ref([""])
+ const configurationStatus = ref(false)
+
// Project detail
const hasGotProjectDetail = ref(false)
@@ -31,6 +33,9 @@ const editDomainStore = defineStore("editDomainStoroe", () => {
const knowledgeContent = ref("")
const knowledgeModalShow = ref(false)
const isEditKnowledge = ref(false)
+ const knowledge_base_content = ref("")
+ const knowledgeBasePreview = ref(false)
+ const knowledgeBasePreviewTit = ref("")
// Company profile
const hasGotCompanyProfile = ref(false)
@@ -78,6 +83,7 @@ const editDomainStore = defineStore("editDomainStoroe", () => {
catch_email,
initAi,
urls,
+ configurationStatus,
hasGotProjectDetail,
domain,
@@ -93,6 +99,9 @@ const editDomainStore = defineStore("editDomainStoroe", () => {
knowledgeContent,
knowledgeModalShow,
isEditKnowledge,
+ knowledge_base_content,
+ knowledgeBasePreview,
+ knowledgeBasePreviewTit,
hasGotCompanyProfile,
legal_company_name,
diff --git a/core/frontend/src/views/template/pages/AITemplate/controller/index.ts b/core/frontend/src/views/template/pages/AITemplate/controller/index.ts
index bc84c674..79017cc0 100644
--- a/core/frontend/src/views/template/pages/AITemplate/controller/index.ts
+++ b/core/frontend/src/views/template/pages/AITemplate/controller/index.ts
@@ -112,9 +112,10 @@ export async function getChatInfo(store: TemplateStore) {
* @description Stop chat
*/
export async function stopChat(store: TemplateStore) {
- const { chatId } = store
+ const { chatId, isChat } = store
try {
await instance.post("/askai/chat/stop", { chatId: chatId.value }, instanceOptions)
+ isChat.value = false
} catch (error) {
console.warn(error)
}
@@ -126,10 +127,23 @@ export async function stopChat(store: TemplateStore) {
* Send chat and generate markdown
*/
export async function sendChat(store: TemplateStore) {
- const { answerContent, generateShow, chatId, currentModel, questionContent, chatRecord, currentChatRecordKey } = store
+ const {
+ scrollable,
+ generateShow,
+ chatId,
+ currentModel,
+ questionContent,
+ chatRecord,
+ currentChatRecordKey,
+ scrollWrapperRef,
+ chatScrollRef,
+ isChat
+ } = store
const chatRecordKey = `${questionContent.value}_+_${chatRecord.value.size}`
chatRecord.value.set(chatRecordKey, [])
currentChatRecordKey.value = chatRecordKey
+ const chatContent = questionContent.value
+ questionContent.value = ""
// Split string array
let resultArray: string[] = [];
// Answer text
@@ -147,14 +161,17 @@ export async function sendChat(store: TemplateStore) {
}
}
try {
+ scrollable.value = true
generateShow.value = true
+ isChat.value = true
+ nextTick(() => chatScrollRef.value.scrollTo({ left: 0, top: scrollWrapperRef.value.offsetHeight }))
await instance.post(
'/askai/chat/chat', // 接口地址
{
chatId: chatId.value,
supplierName: currentModel.value.supplierName,
modelId: currentModel.value.modelId,
- content: questionContent.value,
+ content: chatContent,
is_text: "false"
},
{
@@ -174,12 +191,18 @@ export async function sendChat(store: TemplateStore) {
resultArray = parseSSEToObjects(newContent) as string[];
answerTextDeal(resultArray)
chatRecord.value.set(chatRecordKey, sliceContentToArray(answerText))
+ if (scrollable.value) {
+ setTimeout(() => chatScrollRef.value.scrollTo({ left: 0, top: scrollWrapperRef.value.offsetHeight }), 200)
+ }
} catch (error) {
console.warn(error);
}
}
}
)
+ scrollable.value = true
+ chatScrollRef.value.scrollTo({ left: 0, top: scrollWrapperRef.value.offsetHeight })
+ isChat.value = false
} catch (error) {
console.warn(error)
} finally {
@@ -278,6 +301,6 @@ export async function saveCodeChange(store: TemplateStore) {
/**
* @description Duplicate template
*/
-export async function duplicateTemplate(){
-
+export async function duplicateTemplate() {
+
}
\ No newline at end of file
diff --git a/core/frontend/src/views/template/pages/AITemplate/dto/index.ts b/core/frontend/src/views/template/pages/AITemplate/dto/index.ts
index f22a34b3..931e1faa 100644
--- a/core/frontend/src/views/template/pages/AITemplate/dto/index.ts
+++ b/core/frontend/src/views/template/pages/AITemplate/dto/index.ts
@@ -65,4 +65,8 @@ export type TemplateStore = {
previewCode: Ref<string>
generateShow: Ref<boolean>
chatRecord: Ref<Map<string, string[]>>
+ isChat:Ref<boolean>
+ chatScrollRef:Ref<any>
+ scrollWrapperRef:Ref<any>
+ scrollable:Ref<boolean>
}
\ No newline at end of file
diff --git a/core/frontend/src/views/template/pages/AITemplate/index.vue b/core/frontend/src/views/template/pages/AITemplate/index.vue
index 8c26e27d..c131c64c 100644
--- a/core/frontend/src/views/template/pages/AITemplate/index.vue
+++ b/core/frontend/src/views/template/pages/AITemplate/index.vue
@@ -22,7 +22,7 @@
</n-card>
</div>
- <div ref="answerRef" class="answer">
+ <div ref="answerRef" class="answer" @wheel="handleScroll">
<n-card class="h-100%">
<n-scrollbar style="height: calc(100vh - 522px);" ref="chatScrollRef">
<div ref="scrollWrapperRef">
@@ -68,12 +68,14 @@
</div>
<div class="question">
<n-card style="height: 100%;">
- <n-input type="textarea" class="question-input" v-model:value="questionContent"></n-input>
+ <n-input type="textarea" class="question-input" v-model:value="questionContent" @keydown.enter="sendChat(store)"></n-input>
<div class="send-btn">
- <i
- class="i-icon-park-twotone:new-picture text-8 text-[var(--color-primary-1)] hover-text-[var(--color-primary-hover-1)]"></i>
+ <!-- <i
+ class="i-icon-park-twotone:new-picture text-8 text-[var(--color-primary-1)] hover-text-[var(--color-primary-hover-1)]"></i> -->
<i class="i-icon-park-twotone:arrow-circle-up text-8 text-[var(--color-primary-1)] hover-text-[var(--color-primary-hover-1)]"
- @click="sendChat(store)"></i>
+ @click="sendChat(store)" v-if="!isChat"></i>
+ <i class="i-svg-spinners:pulse-2 text-8 text-[var(--color-primary-1)] hover-text-[var(--color-primary-hover-1)]"
+ @click="stopChat(store)" v-else></i>
</div>
</n-card>
</div>
@@ -113,7 +115,7 @@
</template>
<script setup lang="ts">
- import { initialTemplateInfo, sendChat, removeHtmlCodeBlockMarkers, getHtmlTemplateContent, saveCodeChange } from "./controller";
+ import { initialTemplateInfo, sendChat, removeHtmlCodeBlockMarkers, getHtmlTemplateContent, saveCodeChange,stopChat } from "./controller";
import MarkdownRender from "./components/MarkdownRender.vue";
import { useTemplateStore } from "./store";
import { TemplateStore } from "./dto";
@@ -128,11 +130,14 @@
questionContent,
chatRecord,
currentChatRecordKey,
- currentModel
+ currentModel,
+ isChat,
+ chatScrollRef,
+ scrollWrapperRef,
+ scrollable
} = store
const route = useRoute()
- const chatScrollRef = ref()
- const scrollWrapperRef = ref()
+
const previewStatus = ref("view")
chatId.value = route.params.chatId as string
@@ -198,6 +203,12 @@
}
}
+ function handleScroll(event: WheelEvent) {
+ if (event.deltaY < 0) {
+ scrollable.value = false
+ }
+ }
+
onMounted(() => {
scrollwrapperHeightChange()
})
@@ -221,7 +232,7 @@
.ai-container {
display: grid;
- grid-template-columns: 500px 1fr;
+ grid-template-columns: 900px 1fr;
gap: 15px;
.chat-area {
@@ -230,7 +241,7 @@
gap: 15px;
.answer {
- width: 500px;
+ width: 100%;
height: calc(100vh - 472px);
.answer-container {
diff --git a/core/frontend/src/views/template/pages/AITemplate/store/index.ts b/core/frontend/src/views/template/pages/AITemplate/store/index.ts
index 974a06ed..736d9140 100644
--- a/core/frontend/src/views/template/pages/AITemplate/store/index.ts
+++ b/core/frontend/src/views/template/pages/AITemplate/store/index.ts
@@ -30,6 +30,10 @@ export function useTemplateStore(): TemplateStore {
const previewCode = ref<string>("")
const generateShow = ref<boolean>(false)
const chatRecord = ref<Map<string, string[]>>(new Map())
+ const isChat = ref(false)
+ const chatScrollRef = ref()
+ const scrollWrapperRef = ref()
+ const scrollable = ref(true)
return {
sourceDomain,
@@ -43,6 +47,10 @@ export function useTemplateStore(): TemplateStore {
answerContent,
previewCode,
generateShow,
- chatRecord
+ chatRecord,
+ isChat,
+ chatScrollRef,
+ scrollWrapperRef,
+ scrollable
}
}
\ No newline at end of file