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

fix: Fix several issues​

albertc58b32505a1d
diff --git a/core/frontend/src/views/market/task/components/TemplateSelect.vue b/core/frontend/src/views/market/task/components/TemplateSelect.vue
index c1eb2fb2..0fc31428 100644
--- a/core/frontend/src/views/market/task/components/TemplateSelect.vue
+++ b/core/frontend/src/views/market/task/components/TemplateSelect.vue
@@ -14,6 +14,8 @@ import { isArray, isObject } from '@/utils'
import { getTemplateAll } from '@/api/modules/market/template'
import { Template } from '@/views/market/template/interface'
+
+
const templateId = defineModel<number | null>('value')
const content = defineModel<string>('content')
@@ -29,6 +31,8 @@ const handleUpdateTemplate = (val: number, option: SelectOption) => {
}
}
+const emits = defineEmits(["listReady"])
+
const getList = async () => {
try {
loading.value = true
@@ -48,6 +52,7 @@ const getList = async () => {
content.value = template.html_content
}
}
+ emits("listReady",res)
}
} finally {
loading.value = false
diff --git a/core/frontend/src/views/market/task/edit.vue b/core/frontend/src/views/market/task/edit.vue
index e4e73efc..e115d1d9 100644
--- a/core/frontend/src/views/market/task/edit.vue
+++ b/core/frontend/src/views/market/task/edit.vue
@@ -16,14 +16,12 @@
</from-select>
</n-form-item>
<n-form-item :label="$t('market.task.edit.displayName')" path="full_name">
- <n-input
- v-model:value="form.full_name"
+ <n-input v-model:value="form.full_name"
:placeholder="$t('market.task.edit.displayNamePlaceholder')">
</n-input>
</n-form-item>
<n-form-item :label="$t('market.task.edit.subject')" path="subject">
- <n-input
- v-model:value="form.subject"
+ <n-input v-model:value="form.subject"
:placeholder="$t('market.task.edit.subjectPlaceholder')">
</n-input>
</n-form-item>
@@ -33,9 +31,8 @@
</n-form-item>
<n-form-item :label="$t('market.task.edit.template')" path="template_id">
<div class="flex-1">
- <template-select
- v-model:value="form.template_id"
- v-model:content="templateContent">
+ <template-select v-model:value="form.template_id" v-model:content="templateContent"
+ @list-ready="findTemplateId">
</template-select>
</div>
<n-button text type="primary" class="ml-12px" @click="handleGoTemplate">
@@ -68,10 +65,7 @@
</n-radio>
</n-radio-group>
<div v-show="threadsType === 1" class="w-60px">
- <n-input-number
- v-model:value="form.threads"
- :min="1"
- :max="100"
+ <n-input-number v-model:value="form.threads" :min="1" :max="100"
:show-button="false">
</n-input-number>
</div>
@@ -79,30 +73,23 @@
</n-card>
<n-card>
<n-form-item :label="t('market.task.edit.sendTime')" path="start_time">
- <n-radio-group
- v-model:value="sendTimeType"
- class="flex items-center"
+ <n-radio-group v-model:value="sendTimeType" class="flex items-center"
@update:value="handleUpdateSend">
<n-radio :value="0">{{ t('market.task.edit.sendTimeNow') }}</n-radio>
<n-radio class="items-center" :value="1"> </n-radio>
- <n-date-picker
- v-model:value="form.start_time"
- class="ml-8px"
- type="datetime"
+ <n-date-picker v-model:value="form.start_time" class="ml-8px" type="datetime"
:disabled="sendTimeType === 0">
</n-date-picker>
</n-radio-group>
</n-form-item>
<n-form-item :label="$t('market.task.edit.remark')">
- <n-input
- v-model:value="form.remark"
+ <n-input v-model:value="form.remark"
:placeholder="$t('market.task.edit.remarkPlaceholder')">
</n-input>
</n-form-item>
<n-form-item :label="$t('market.task.edit.testEmail')" :show-feedback="false">
<div class="flex-1 mr-10px">
- <n-input
- v-model:value="testEmail"
+ <n-input v-model:value="testEmail"
:placeholder="$t('market.task.edit.testEmailPlaceholder')">
</n-input>
</div>
@@ -114,8 +101,7 @@
</div>
</bt-form>
<div class="task-preview">
- <n-card
- class="h-full"
+ <n-card class="h-full"
:content-style="{ display: 'flex', flexDirection: 'column', height: '100%' }">
<div class="preview-header">
<div class="preview-header-item">
@@ -154,257 +140,274 @@
</template>
<script lang="ts" setup>
-import { FormRules } from 'naive-ui'
-import { useElementBounding } from '@vueuse/core'
-import { confirm, Message } from '@/utils'
-import { addTask, sendTestEmail } from '@/api/modules/market/task'
-
-import FromSelect from './components/FromSelect.vue'
-import GroupSelect from './components/GroupSelect.vue'
-import TemplateSelect from './components/TemplateSelect.vue'
-
-const { t } = useI18n()
-
-const router = useRouter()
-
-const formRef = useTemplateRef('formRef')
-
-const formContentRef = useTemplateRef('formContentRef')
-
-const { height } = useElementBounding(formContentRef)
-
-// 表单数据
-const form = reactive({
- addresser: null as null | string,
- full_name: '',
- subject: '',
- group_ids: [] as number[],
- template_id: null as null | number,
- is_record: 1,
- unsubscribe: 1,
- warmup: 0,
- threads: 0,
- start_time: null as number | null,
- remark: '',
-})
-
-const rules: FormRules = {
- full_name: {
- trigger: ['blur', 'input'],
- validator: () => {
- if (form.full_name === '') {
- return new Error(t('market.task.edit.validation.displayNameRequired'))
- }
- return true
+ import { FormRules } from 'naive-ui'
+ import { useElementBounding } from '@vueuse/core'
+ import { confirm, Message } from '@/utils'
+ import { addTask, sendTestEmail } from '@/api/modules/market/task'
+
+ import FromSelect from './components/FromSelect.vue'
+ import GroupSelect from './components/GroupSelect.vue'
+ import TemplateSelect from './components/TemplateSelect.vue'
+ import { Template } from '../template/interface'
+
+ const { t } = useI18n()
+
+ const router = useRouter()
+ const route = useRoute()
+
+ const formRef = useTemplateRef('formRef')
+
+ const formContentRef = useTemplateRef('formContentRef')
+
+ const { height } = useElementBounding(formContentRef)
+
+ // 表单数据
+ const form = reactive({
+ addresser: null as null | string,
+ full_name: '',
+ subject: '',
+ group_ids: [] as number[],
+ template_id: null as null | number,
+ is_record: 1,
+ unsubscribe: 1,
+ warmup: 0,
+ threads: 0,
+ start_time: null as number | null,
+ remark: '',
+ })
+
+
+ const rules: FormRules = {
+ full_name: {
+ trigger: ['blur', 'input'],
+ validator: () => {
+ if (form.full_name === '') {
+ return new Error(t('market.task.edit.validation.displayNameRequired'))
+ }
+ return true
+ },
},
- },
- subject: {
- trigger: ['blur', 'input'],
- validator: () => {
- if (form.subject === '') {
- return new Error(t('market.task.edit.validation.subjectRequired'))
- }
- return true
+ subject: {
+ trigger: ['blur', 'input'],
+ validator: () => {
+ if (form.subject === '') {
+ return new Error(t('market.task.edit.validation.subjectRequired'))
+ }
+ return true
+ },
},
- },
- group_ids: {
- trigger: 'change',
- validator: () => {
- if (form.group_ids.length === 0) {
- return new Error(t('market.task.edit.validation.recipientsRequired'))
- }
- return true
+ group_ids: {
+ trigger: 'change',
+ validator: () => {
+ if (form.group_ids.length === 0) {
+ return new Error(t('market.task.edit.validation.recipientsRequired'))
+ }
+ return true
+ },
},
- },
- template_id: {
- trigger: 'change',
- validator: () => {
- if (form.template_id === null) {
- return new Error(t('market.task.edit.validation.templateRequired'))
- }
- return true
+ template_id: {
+ trigger: 'change',
+ validator: () => {
+ if (form.template_id === null) {
+ return new Error(t('market.task.edit.validation.templateRequired'))
+ }
+ return true
+ },
},
- },
- start_time: {
- validator: () => {
- if (sendTimeType.value === 1 && form.start_time === null) {
- return new Error(t('market.task.edit.validation.sendTimeRequired'))
- }
- return true
+ start_time: {
+ validator: () => {
+ if (sendTimeType.value === 1 && form.start_time === null) {
+ return new Error(t('market.task.edit.validation.sendTimeRequired'))
+ }
+ return true
+ },
},
- },
-}
+ }
-// 分组名称
-const groupNames = ref<string[]>([])
+ // 分组名称
+ const groupNames = ref<string[]>([])
-// 线程类型
-const threadsType = ref(0)
+ // 线程类型
+ const threadsType = ref(0)
-// 发送时间类型
-const sendTimeType = ref(0)
+ // 发送时间类型
+ const sendTimeType = ref(0)
-// 测试邮件
-const testEmail = ref('')
+ // 测试邮件
+ const testEmail = ref('')
-// 模板内容
-const templateContent = ref('')
+ // 模板内容
+ const templateContent = ref('')
-// 跳转模板页面
-const handleGoTemplate = () => {
- router.push('/market/template')
-}
+ // 跳转模板页面
+ const handleGoTemplate = () => {
+ router.push('/market/template')
+ }
-// 查看案例
-// const handleViewCase = () => {}
+ // 查看案例
+ // const handleViewCase = () => {}
-// 更新线程类型
-const handleUpdateThread = (val: number) => {
- if (val === 0) {
- form.threads = 0
- } else {
- form.threads = 5
+ // 更新线程类型
+ const handleUpdateThread = (val: number) => {
+ if (val === 0) {
+ form.threads = 0
+ } else {
+ form.threads = 5
+ }
}
-}
-const handleUpdateSend = () => {
- if (sendTimeType.value === 0) {
- form.start_time = null
+ const handleUpdateSend = () => {
+ if (sendTimeType.value === 0) {
+ form.start_time = null
+ }
}
-}
-// 发送测试邮件
-const handleSendTest = async () => {
- if (!testEmail.value) {
- Message.error(t('market.task.edit.validation.testEmailRequired'))
- return
- }
- if (!form.subject) {
- Message.error(t('market.task.edit.validation.subjectRequired'))
- return
- }
- if (!form.template_id) {
- Message.error(t('market.task.edit.validation.templateRequired'))
- return
- }
+ // 发送测试邮件
+ const handleSendTest = async () => {
+ if (!testEmail.value) {
+ Message.error(t('market.task.edit.validation.testEmailRequired'))
+ return
+ }
+ if (!form.subject) {
+ Message.error(t('market.task.edit.validation.subjectRequired'))
+ return
+ }
+ if (!form.template_id) {
+ Message.error(t('market.task.edit.validation.templateRequired'))
+ return
+ }
- await sendTestEmail({
- addresser: form.addresser || '',
- subject: form.subject,
- recipient: testEmail.value,
- template_id: form.template_id || 0,
- })
-}
-
-const handleGoBack = () => {
- if (form.subject || form.group_ids.length > 0) {
- confirm({
- title: t('market.task.edit.discard.title'),
- content: t('market.task.edit.discard.content'),
- onConfirm: () => {
- router.go(-1)
- },
+ await sendTestEmail({
+ addresser: form.addresser || '',
+ subject: form.subject,
+ recipient: testEmail.value,
+ template_id: form.template_id || 0,
})
- } else {
- router.go(-1)
}
-}
-const getParams = () => {
- let startTime = form.start_time
- if (sendTimeType.value === 0 || startTime === null) {
- startTime = Date.now()
- }
- return {
- track_open: 1,
- track_click: 1,
- addresser: form.addresser || '',
- full_name: form.full_name,
- subject: form.subject,
- group_ids: form.group_ids,
- template_id: form.template_id || 0,
- is_record: form.is_record,
- unsubscribe: form.unsubscribe,
- warmup: form.warmup,
- threads: form.threads,
- start_time: startTime / 1000,
- remark: form.remark,
+ const handleGoBack = () => {
+ if (form.subject || form.group_ids.length > 0) {
+ confirm({
+ title: t('market.task.edit.discard.title'),
+ content: t('market.task.edit.discard.content'),
+ onConfirm: () => {
+ router.go(-1)
+ },
+ })
+ } else {
+ router.go(-1)
+ }
}
-}
-
-const handleSubmit = async () => {
- await formRef.value?.validate()
- await addTask(getParams())
- router.push('/market/task')
-}
-</script>
-<style lang="scss" scoped>
-.task-edit-container {
- position: relative;
- display: flex;
- flex-direction: column;
- height: 100%;
- overflow: hidden;
-
- .task-edit-box {
- flex: 1;
- display: flex;
- gap: 24px;
- min-height: 0;
+ const getParams = () => {
+ let startTime = form.start_time
+ if (sendTimeType.value === 0 || startTime === null) {
+ startTime = Date.now()
+ }
+ return {
+ track_open: 1,
+ track_click: 1,
+ addresser: form.addresser || '',
+ full_name: form.full_name,
+ subject: form.subject,
+ group_ids: form.group_ids,
+ template_id: form.template_id || 0,
+ is_record: form.is_record,
+ unsubscribe: form.unsubscribe,
+ warmup: form.warmup,
+ threads: form.threads,
+ start_time: startTime / 1000,
+ remark: form.remark,
+ }
}
- .task-edit-form {
- flex: 1;
+ const handleSubmit = async () => {
+ await formRef.value?.validate()
+ await addTask(getParams())
+ router.push('/market/task')
}
- .task-preview {
- flex: 1;
- overflow: hidden;
- .preview-header {
- width: 420px;
- margin: 0 auto;
- margin-bottom: 16px;
+ /**
+ * @description Find templateId from template list
+ */
+ function findTemplateId(list: Template[]) {
+ if (route.query.chat_id) {
+ const findRes = list.find(item => item.chat_id == route.query.chat_id)
+ if (findRes) {
+ form.template_id = findRes.id
+ templateContent.value = findRes.html_content
+ }
+ }
+ }
+</script>
- .preview-header-item {
- display: flex;
- margin-bottom: 4px;
+<style lang="scss" scoped>
+ .task-edit-container {
+ position: relative;
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+ overflow: hidden;
- .preview-label {
- min-width: 150px;
- text-align: right;
- font-weight: 500;
- margin-right: 8px;
- }
+ .task-edit-box {
+ flex: 1;
+ display: flex;
+ gap: 24px;
+ min-height: 0;
+ }
- .preview-value {
- flex: 1;
- color: #666;
- }
- }
+ .task-edit-form {
+ flex: 1;
}
- .preview-content {
+ .task-preview {
flex: 1;
- min-height: 400px;
overflow: hidden;
- .empty-preview {
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100%;
- color: #999;
+ .preview-header {
+ width: 420px;
+ margin: 0 auto;
+ margin-bottom: 16px;
+
+ .preview-header-item {
+ display: flex;
+ margin-bottom: 4px;
+
+ .preview-label {
+ min-width: 150px;
+ text-align: right;
+ font-weight: 500;
+ margin-right: 8px;
+ }
+
+ .preview-value {
+ flex: 1;
+ color: #666;
+ }
+ }
+ }
+
+ .preview-content {
+ flex: 1;
+ min-height: 400px;
+ overflow: hidden;
+
+ .empty-preview {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ height: 100%;
+ color: #999;
+ }
}
}
}
-}
-
-.action-buttons {
- width: 100%;
- padding: 23px 24px;
- background-color: var(--color-bg-1);
- border-top: 1px solid var(--color-border-1);
-}
+
+ .action-buttons {
+ width: 100%;
+ padding: 23px 24px;
+ background-color: var(--color-bg-1);
+ border-top: 1px solid var(--color-border-1);
+ }
</style>
diff --git a/core/frontend/src/views/market/task/index.vue b/core/frontend/src/views/market/task/index.vue
index 7158a92a..3780c045 100644
--- a/core/frontend/src/views/market/task/index.vue
+++ b/core/frontend/src/views/market/task/index.vue
@@ -38,6 +38,7 @@
</template>
<script lang="tsx" setup>
+
import { DataTableColumns, NButton, NFlex, NProgress, NTag } from 'naive-ui'
import { useModal } from '@/hooks/modal/useModal'
import { useTableData } from '@/hooks/useTableData'
@@ -47,7 +48,6 @@ import type { Task, TaskParams } from './interface'
import TaskDetail from './components/TaskDetail.vue'
import TaskStatus from './components/TaskStatus.vue'
-
const { t } = useI18n()
const { loading, tableParams, tableList, tableTotal, getTableData } = useTableData<
diff --git a/core/frontend/src/views/market/template/interface.ts b/core/frontend/src/views/market/template/interface.ts
index fac1ba1c..3b987ab7 100644
--- a/core/frontend/src/views/market/template/interface.ts
+++ b/core/frontend/src/views/market/template/interface.ts
@@ -6,6 +6,7 @@ export interface Template {
drag_data: string
create_time: number
update_time: number
+ chat_id?:string
}
export interface TemplateParams {
diff --git a/core/frontend/src/views/template/pages/AITemplate/components/MarkdownRender.vue b/core/frontend/src/views/template/pages/AITemplate/components/MarkdownRender.vue
index 1c3e869f..0254ad24 100644
--- a/core/frontend/src/views/template/pages/AITemplate/components/MarkdownRender.vue
+++ b/core/frontend/src/views/template/pages/AITemplate/components/MarkdownRender.vue
@@ -29,7 +29,7 @@
import markdownit from 'markdown-it'
import hljs from 'highlight.js'
import '../highlight.theme.css'
-import { removeHtmlCodeBlockMarkers } from '../controller'
+import { removeHtmlCodeBlockMarkers,removeSignCode } from '../controller'
import { TemplateStore } from '../dto'
import { useClipboard } from '@vueuse/core'
const { copy, copied } = useClipboard()
@@ -62,7 +62,7 @@ const md = markdownit({
return md.utils.escapeHtml(str) // 使用额外的默认转义
},
})
-codeHtml.value = md.render(props.content)
+codeHtml.value = md.render(removeSignCode(props.content))
watch(
() => props.content,
val => {
@@ -73,7 +73,8 @@ watch(
key: props.chatRecordKey,
})
}
- }
+ },
+ {immediate:true}
)
/**
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 671fb8a0..51b237fb 100644
--- a/core/frontend/src/views/template/pages/AITemplate/controller/index.ts
+++ b/core/frontend/src/views/template/pages/AITemplate/controller/index.ts
@@ -145,6 +145,7 @@ export async function sendChat(store: TemplateStore) {
chatScrollRef,
isChat,
} = store
+ if (isChat.value) return
const chatRecordKey = `${questionContent.value}_+_${chatRecord.value.size}`
chatRecord.value.set(chatRecordKey, [])
currentChatRecordKey.value = chatRecordKey
@@ -156,6 +157,8 @@ export async function sendChat(store: TemplateStore) {
let answerText = ''
// Character pointer position
let strPos = 0
+
+
/**
* @description spliced content
*/
@@ -174,7 +177,7 @@ export async function sendChat(store: TemplateStore) {
chatScrollRef.value.scrollTo({ left: 0, top: scrollWrapperRef.value.offsetHeight })
)
await instance.post(
- '/askai/chat/chat', // 接口地址
+ '/askai/chat/chat',
{
chatId: chatId.value,
supplierName: currentModel.value.supplierName,
@@ -218,6 +221,7 @@ export async function sendChat(store: TemplateStore) {
scrollable.value = true
chatScrollRef.value.scrollTo({ left: 0, top: scrollWrapperRef.value.offsetHeight })
isChat.value = false
+ saveCodeChange(store)
} catch (error) {
console.warn(error)
} finally {
@@ -233,17 +237,17 @@ export async function sendChat(store: TemplateStore) {
* @param sseContent @
*/
function parseSSEToObjects(sseContent: string): Array<string> {
- // 1. 按行分割
+ // 1. Split by row
const events = sseContent.split('\n')
let jsonList = []
for (const line of events) {
- // 匹配以"data:"开头的行(忽略前后空格)
+ // Match lines starting with "data:" (ignore the Spaces before and after)
const trimmedLine = line.trim()
if (trimmedLine.startsWith('data:')) {
- // 去除"data:"前缀,得到JSON字符串
+ // Remove the prefix "data:" to obtain the JSON string
const jsonStr = trimmedLine.slice('data:'.length).trim()
if (jsonStr) {
- // 排除空值(如最后一行的空data)
+ // Exclude null values (such as the empty data in the last row)
jsonList.push(jsonStr)
}
}
@@ -252,18 +256,18 @@ function parseSSEToObjects(sseContent: string): Array<string> {
}
/**
- * @description 对字符内容进行分割处理
+ * @description Segment the character content
*/
function sliceContentToArray(content: string) {
- // 匹配所有代码块(闭合或未闭合)
- // 正则逻辑:```开头,匹配到内容结尾或下一个```(取较长的匹配)
+ // Match all code blocks (closed or unclosed)
+ // Regular logic: Start with ' ', match to the end of the content or the next ' '(take the longer match)
const codeBlockRegex = /```[\s\S]*?(?:```|$)/g
const codeBlocks = content.match(codeBlockRegex) || []
- // 分割非代码部分
+ // Separate the non-code part
const textParts = content.split(codeBlockRegex)
- // 合并文本与代码块
+ // Merge text and code blocks
const result = []
const maxLength = Math.max(textParts.length, codeBlocks.length)
@@ -286,16 +290,33 @@ export function removeHtmlCodeBlockMarkers(content: string) {
return content.replace(/```html/g, '').replace(/```$/gm, '')
}
+/**
+ * @description Remove sign code for "<<<<<search" and ">>>>>replace"
+ */
+export function removeSignCode(content: string) {
+ const signCodeRegex = /<<<<<<<\s+SEARCH[\s\S]*?=======([\s\S]*?)>>>>>>>\s+REPLACE/g;
+ return content.replace(signCodeRegex, "$1")
+}
+
+/**
+ * @description Get content from title tags
+ */
+export function getContentFromTitleTags(content: string) {
+ const match = content.match(/<title>(.*?)<\/title>/i);
+ return match ? match[1] : '';
+}
+
/**
* @description Get html template code content
*/
export async function getHtmlTemplateContent(store: TemplateStore) {
- const { chatId, previewCode } = store
+ const { chatId, previewCode, previewTit } = store
try {
const codeContent = (await instance.post('/askai/chat/get_html', {
chatId: chatId.value,
})) as string
previewCode.value = codeContent
+ previewTit.value = getContentFromTitleTags(previewCode.value)
} catch (error) {
console.warn(error)
}
@@ -320,4 +341,4 @@ export async function saveCodeChange(store: TemplateStore) {
/**
* @description Duplicate template
*/
-export async function duplicateTemplate() {}
+export async function duplicateTemplate() { }
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 2557be80..e8c00116 100644
--- a/core/frontend/src/views/template/pages/AITemplate/dto/index.ts
+++ b/core/frontend/src/views/template/pages/AITemplate/dto/index.ts
@@ -71,4 +71,5 @@ export type TemplateStore = {
chatScrollRef:Ref<any>
scrollWrapperRef:Ref<any>
scrollable:Ref<boolean>
+ previewTit:Ref<string>
}
\ 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 2699e272..d70fafa2 100644
--- a/core/frontend/src/views/template/pages/AITemplate/index.vue
+++ b/core/frontend/src/views/template/pages/AITemplate/index.vue
@@ -26,13 +26,6 @@
<n-card class="h-100%">
<n-scrollbar ref="chatScrollRef" style="height: calc(100vh - 522px)">
<div ref="scrollWrapperRef">
- <div class="answer-container">
- <div class="ask-content">
- <div class="text">
- {{ $t('template.ai.welcomeMessage', { domain: chatInfo.domain }) }}
- </div>
- </div>
- </div>
<template v-for="item in chatRecord" :key="item[0]">
<div class="answer-container">
<div class="ask-content">
@@ -55,7 +48,7 @@
<MarkdownRender
v-for="(_item, _index) in item[1]"
:key="_index"
- :content="_item"
+ :content="removeSignCode(_item)"
:chat-record-key="item[0]"
class="mb-4"
@code-render="handleCodeRender">
@@ -84,6 +77,7 @@
<n-input
v-model:value="questionContent"
type="textarea"
+ :placeholder="previewCode?'':$t('template.ai.welcomeMessage', { domain: chatInfo.domain })"
class="question-input"
@keydown.enter="sendChat(store)"></n-input>
<div class="question-tools">
@@ -115,7 +109,7 @@
<div class="view-area">
<n-card style="height: 100%">
<div style="height: calc(100vh - 177px)">
- <div class="h-10 flex justify-start items-center gap-2.5">
+ <div class="h-10 flex justify-between items-center gap-2.5">
<n-button-group size="small">
<n-button
:type="previewStatus == 'view' ? 'primary' : 'default'"
@@ -135,6 +129,13 @@
</n-button>
</n-button-group>
<span v-if="previewStatus == 'edit'">{{ $t('template.ai.tips.saveShortcut') }}</span>
+ <span class="text-4 fw-bold">{{previewTit}}</span>
+ <n-button style="width: 134px;" type="primary" :disabled="!previewCode" @click="goToSendEmail">
+ <template #icon>
+ <i class="i-mingcute:mail-send-fill"></i>
+ </template>
+ Send
+ </n-button>
</div>
<n-scrollbar style="height: calc(100% - 40px)">
<div v-if="previewStatus == 'view'" v-html="previewCode"></div>
@@ -160,11 +161,14 @@ import {
getHtmlTemplateContent,
saveCodeChange,
stopChat,
+ removeSignCode,
+ getContentFromTitleTags
} from './controller'
import MarkdownRender from './components/MarkdownRender.vue'
import { useTemplateStore } from './store'
import { TemplateStore } from './dto'
import BtEditor from '@/components/base/bt-editor/index.vue'
+const router = useRouter()
const store = useTemplateStore()
provide<TemplateStore>('modelStore', store)
const {
@@ -181,6 +185,7 @@ const {
scrollWrapperRef,
scrollable,
chatInfo,
+ previewTit
} = store
const route = useRoute()
@@ -210,8 +215,8 @@ initialTemplateInfo(store)
*/
function handleCodeRender(data: { code: string; key: string }) {
if (data.key == currentChatRecordKey.value) {
- // console.log(data.key, currentChatRecordKey.value)
- previewCode.value = removeHtmlCodeBlockMarkers(data.code)
+ previewCode.value = removeSignCode(removeHtmlCodeBlockMarkers(data.code))
+ previewTit.value = getContentFromTitleTags(previewCode.value)
}
}
@@ -247,13 +252,27 @@ function scrollWrapperHeightChange(timer?: any, index = 0) {
}, 100)
}
}
-
+/**
+ * @description If user scroll then stop n-scrollbar behavior
+ */
function handleScroll(event: WheelEvent) {
if (event.deltaY < 0) {
scrollable.value = false
}
}
+/**
+ * @description Go to send email
+ */
+function goToSendEmail(){
+ router.push({
+ path:"/market/task/edit",
+ query:{
+ chat_id:chatInfo.value.chatId
+ }
+ })
+}
+
onMounted(() => {
scrollWrapperHeightChange()
})
@@ -360,7 +379,7 @@ onMounted(() => {
position: absolute;
padding: 5px 30px;
@include base.row-flex;
- gap: 200px;
+ gap: 100px;
bottom: 22px;
left: 0;
width: 100%;
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 3ff1eb26..21ace04c 100644
--- a/core/frontend/src/views/template/pages/AITemplate/store/index.ts
+++ b/core/frontend/src/views/template/pages/AITemplate/store/index.ts
@@ -36,6 +36,7 @@ export function useTemplateStore(): TemplateStore {
const chatScrollRef = ref()
const scrollWrapperRef = ref()
const scrollable = ref(true)
+ const previewTit = ref("")
return {
domainList,
@@ -55,5 +56,6 @@ export function useTemplateStore(): TemplateStore {
chatScrollRef,
scrollWrapperRef,
scrollable,
+ previewTit
}
}
\ No newline at end of file