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​

albertd48501afd926
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 51b237fb..eec4de83 100644
--- a/core/frontend/src/views/template/pages/AITemplate/controller/index.ts
+++ b/core/frontend/src/views/template/pages/AITemplate/controller/index.ts
@@ -157,7 +157,7 @@ export async function sendChat(store: TemplateStore) {
let answerText = ''
// Character pointer position
let strPos = 0
-
+
/**
* @description spliced content
@@ -221,7 +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)
+ getHtmlTemplateContent(store)
} catch (error) {
console.warn(error)
} finally {
diff --git a/core/frontend/src/views/template/pages/AITemplate/index.vue b/core/frontend/src/views/template/pages/AITemplate/index.vue
index d70fafa2..5a7fd573 100644
--- a/core/frontend/src/views/template/pages/AITemplate/index.vue
+++ b/core/frontend/src/views/template/pages/AITemplate/index.vue
@@ -10,13 +10,8 @@
<n-card>
<div class="flex justify-start items-center gap-15px">
<!-- <span>Choose Model</span> -->
- <n-select
- v-model:value="currentModelTitle"
- class="flex-1"
- :options="modelList"
- label-field="title"
- value-field="title"
- @update:value="changeModel">
+ <n-select v-model:value="currentModelTitle" class="flex-1" :options="modelList"
+ label-field="title" value-field="title" @update:value="changeModel">
</n-select>
</div>
</n-card>
@@ -45,13 +40,9 @@
}}</span>
</div>
<div class="text">
- <MarkdownRender
- v-for="(_item, _index) in item[1]"
- :key="_index"
- :content="removeSignCode(_item)"
- :chat-record-key="item[0]"
- class="mb-4"
- @code-render="handleCodeRender">
+ <MarkdownRender v-for="(_item, _index) in item[1]" :key="_index"
+ :content="removeSignCode(_item)" :chat-record-key="item[0]"
+ class="mb-4" @code-render="handleCodeRender">
</MarkdownRender>
</div>
<div class="answer-tool" @click="handleRegenerate(item[0].toString())">
@@ -74,31 +65,21 @@
</div>
<div class="question">
<n-card style="height: 100%">
- <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>
+ <n-input v-model:value="questionContent" type="textarea"
+ :placeholder="$t('template.ai.welcomeMessage', { domain: chatInfo.domain })"
+ class="question-input" @keydown.enter="sendChat(store)"></n-input>
<div class="question-tools">
- <n-select
- v-model:value="currentModelTitle"
- class="flex-1"
- :options="modelList"
- label-field="title"
- value-field="title"
- @update:value="changeModel">
+ <n-select v-model:value="currentModelTitle" class="flex-1" :options="modelList"
+ label-field="title" value-field="title" @update:value="changeModel">
</n-select>
<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
- v-if="!isChat"
+ <i v-if="!isChat"
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>
- <i
- v-else
+ <i v-else
class="i-svg-spinners:pulse-2 text-8 text-[var(--color-primary-1)] hover-text-[var(--color-primary-hover-1)]"
@click="stopChat(store)"></i>
</div>
@@ -111,16 +92,14 @@
<div style="height: calc(100vh - 177px)">
<div class="h-10 flex justify-between items-center gap-2.5">
<n-button-group size="small">
- <n-button
- :type="previewStatus == 'view' ? 'primary' : 'default'"
+ <n-button :type="previewStatus == 'view' ? 'primary' : 'default'"
@click="previewStatus = 'view'">
<template #icon>
<i class="i-mingcute:eye-2-fill text-5"></i>
</template>
{{ $t('template.ai.buttons.view') }}
</n-button>
- <n-button
- :type="previewStatus == 'edit' ? 'primary' : 'default'"
+ <n-button :type="previewStatus == 'edit' ? 'primary' : 'default'"
@click="previewStatus = 'edit'">
<template #icon>
<i class="i-tdesign:code text-5"></i>
@@ -129,8 +108,9 @@
</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">
+ <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>
@@ -138,11 +118,9 @@
</n-button>
</div>
<n-scrollbar style="height: calc(100% - 40px)">
- <div v-if="previewStatus == 'view'" v-html="previewCode"></div>
- <BtEditor
- v-else
- :value="previewCode"
- style="height: calc(100vh - 217px)"
+ <!-- <div v-if="previewStatus == 'view'" v-html="previewCode"></div> -->
+ <iframe v-if="previewStatus == 'view'" :srcdoc="previewCode" frameborder="0" class="w-100%" style="height: calc(100vh - 224px)"></iframe>
+ <BtEditor v-else :value="previewCode" style="height: calc(100vh - 217px)"
@save="saveCodeChange(store)">
</BtEditor>
</n-scrollbar>
@@ -154,251 +132,253 @@
</template>
<script setup lang="ts">
-import {
- initialTemplateInfo,
- sendChat,
- removeHtmlCodeBlockMarkers,
- 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 {
- chatId,
- modelList,
- currentModelTitle,
- previewCode,
- questionContent,
- chatRecord,
- currentChatRecordKey,
- currentModel,
- isChat,
- chatScrollRef,
- scrollWrapperRef,
- scrollable,
- chatInfo,
- previewTit
-} = store
-const route = useRoute()
-
-const previewStatus = ref('view')
-
-chatId.value = route.params.chatId as string
-
-/**
- * @description Handle model select
- */
-function changeModel(_: string, options: any) {
- currentModel.value = options
-}
-
-/**
- * @description Get html template code content
- */
-getHtmlTemplateContent(store)
-
-/**
- * @description Initial chatInfo and modelList
- */
-initialTemplateInfo(store)
-
-/**
- * @description Render page code
- */
-function handleCodeRender(data: { code: string; key: string }) {
- if (data.key == currentChatRecordKey.value) {
- previewCode.value = removeSignCode(removeHtmlCodeBlockMarkers(data.code))
- previewTit.value = getContentFromTitleTags(previewCode.value)
+ import {
+ initialTemplateInfo,
+ sendChat,
+ removeHtmlCodeBlockMarkers,
+ 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 {
+ chatId,
+ modelList,
+ currentModelTitle,
+ previewCode,
+ questionContent,
+ chatRecord,
+ currentChatRecordKey,
+ currentModel,
+ isChat,
+ chatScrollRef,
+ scrollWrapperRef,
+ scrollable,
+ chatInfo,
+ previewTit
+ } = store
+ const route = useRoute()
+
+ const previewStatus = ref('view')
+
+ chatId.value = route.params.chatId as string
+
+ /**
+ * @description Handle model select
+ */
+ function changeModel(_: string, options: any) {
+ currentModel.value = options
}
-}
-
-/**
- * @description Regenerate
- */
-function handleRegenerate(key: string) {
- questionContent.value = key.split('_+_')[0]
- sendChat(store)
-}
-
-/**
- * @description Listen scroll wrapper for height-change
- */
-function scrollWrapperHeightChange(timer?: any, index = 0) {
- let timeoutTimer = timer || null
- let startIndex = index
- if (startIndex >= 6) {
- return
- }
- if (timeoutTimer) {
- clearTimeout(timer)
- timeoutTimer = null
+
+ /**
+ * @description Get html template code content
+ */
+ getHtmlTemplateContent(store)
+
+ /**
+ * @description Initial chatInfo and modelList
+ */
+ initialTemplateInfo(store)
+
+ /**
+ * @description Render page code
+ */
+ function handleCodeRender(data: { code: string; key: string }) {
+ if (data.key == currentChatRecordKey.value) {
+ previewCode.value = removeSignCode(removeHtmlCodeBlockMarkers(data.code))
+ previewTit.value = getContentFromTitleTags(previewCode.value)
+ }
}
- if (scrollWrapperRef.value.offsetHeight) {
- chatScrollRef.value.scrollTo({ left: 0, top: scrollWrapperRef.value.offsetHeight })
- startIndex++
- return
- } else {
- startIndex++
- timeoutTimer = setTimeout(() => {
- scrollWrapperHeightChange(timeoutTimer, startIndex)
- }, 100)
+
+ /**
+ * @description Regenerate
+ */
+ function handleRegenerate(key: string) {
+ questionContent.value = key.split('_+_')[0]
+ sendChat(store)
}
-}
-/**
- * @description If user scroll then stop n-scrollbar behavior
- */
-function handleScroll(event: WheelEvent) {
- if (event.deltaY < 0) {
- scrollable.value = false
+
+ /**
+ * @description Listen scroll wrapper for height-change
+ */
+ function scrollWrapperHeightChange(timer?: any, index = 0) {
+ let timeoutTimer = timer || null
+ let startIndex = index
+ if (startIndex >= 6) {
+ return
+ }
+ if (timeoutTimer) {
+ clearTimeout(timer)
+ timeoutTimer = null
+ }
+ if (scrollWrapperRef.value.offsetHeight) {
+ chatScrollRef.value.scrollTo({ left: 0, top: scrollWrapperRef.value.offsetHeight })
+ startIndex++
+ return
+ } else {
+ startIndex++
+ timeoutTimer = setTimeout(() => {
+ scrollWrapperHeightChange(timeoutTimer, startIndex)
+ }, 100)
+ }
}
-}
-
-/**
- * @description Go to send email
- */
-function goToSendEmail(){
- router.push({
- path:"/market/task/edit",
- query:{
- chat_id:chatInfo.value.chatId
+ /**
+ * @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
+ */
+ async function goToSendEmail() {
+ await saveCodeChange(store)
+
+ router.push({
+ path: "/market/task/edit",
+ query: {
+ chat_id: chatInfo.value.chatId
+ }
+ })
+ }
-onMounted(() => {
- scrollWrapperHeightChange()
-})
+ onMounted(() => {
+ scrollWrapperHeightChange()
+ })
</script>
<style scoped lang="scss">
-@use '@/styles/index' as base;
-@use '../../mixin.scss';
-
-.wrapper {
- @mixin content-card {
- border-radius: 5px;
- padding: 20px;
- }
+ @use '@/styles/index' as base;
+ @use '../../mixin.scss';
- @include mixin.wrapper;
+ .wrapper {
+ @mixin content-card {
+ border-radius: 5px;
+ padding: 20px;
+ }
- .page-tit {
- @include mixin.page-tit;
- }
+ @include mixin.wrapper;
- .ai-container {
- display: grid;
- grid-template-columns: 2fr 5fr;
- gap: 15px;
+ .page-tit {
+ @include mixin.page-tit;
+ }
- .chat-area {
+ .ai-container {
display: grid;
- grid-template-rows: 76px 1fr 230px;
+ grid-template-columns: 2fr 5fr;
gap: 15px;
- .answer {
- width: 100%;
- height: calc(100vh - 472px);
-
- .answer-container {
- padding: 30px 10px;
-
- .ask-content,
- .answer-content {
- @include content-card();
- background: var(--color-bg-3);
- display: grid;
- grid-template-rows: 30px 1fr;
- gap: 10px;
- margin-bottom: 20px;
-
- .pic {
- @include base.row-flex;
- align-items: center;
- }
+ .chat-area {
+ display: grid;
+ grid-template-rows: 76px 1fr 230px;
+ gap: 15px;
- @mixin item-tool {
- @include base.row-flex-start;
- cursor: pointer;
- gap: 5px;
- padding: 5px 10px;
- align-items: center;
- font-size: 12px;
- border-radius: 3px;
- transition: 0.1s all ease-in-out;
-
- &:hover {
- background: var(--color-primary-1);
- color: #fff;
+ .answer {
+ width: 100%;
+ height: calc(100vh - 472px);
+
+ .answer-container {
+ padding: 30px 10px;
+
+ .ask-content,
+ .answer-content {
+ @include content-card();
+ background: var(--color-bg-3);
+ display: grid;
+ grid-template-rows: 30px 1fr;
+ gap: 10px;
+ margin-bottom: 20px;
+
+ .pic {
+ @include base.row-flex;
+ align-items: center;
}
- &:active {
- background: var(--color-primary-3);
+ @mixin item-tool {
+ @include base.row-flex-start;
+ cursor: pointer;
+ gap: 5px;
+ padding: 5px 10px;
+ align-items: center;
+ font-size: 12px;
+ border-radius: 3px;
+ transition: 0.1s all ease-in-out;
+
+ &:hover {
+ background: var(--color-primary-1);
+ color: #fff;
+ }
+
+ &:active {
+ background: var(--color-primary-3);
+ }
}
- }
- .text {
- font-size: 14px;
- }
+ .text {
+ font-size: 14px;
+ }
- .answer-tool {
- @include base.row-flex-end;
- border-top: 1px solid var(--color-border-1);
- height: 30px;
- padding-top: 20px;
+ .answer-tool {
+ @include base.row-flex-end;
+ border-top: 1px solid var(--color-border-1);
+ height: 30px;
+ padding-top: 20px;
- .tool-item {
- @include item-tool();
+ .tool-item {
+ @include item-tool();
+ }
}
}
- }
- .answer-content {
- background: var(--color-bg-2);
+ .answer-content {
+ background: var(--color-bg-2);
+ }
}
}
- }
- .question {
- position: relative;
+ .question {
+ position: relative;
- .question-input {
- height: 100%;
- font-size: 14px;
- }
+ .question-input {
+ height: 100%;
+ font-size: 14px;
+ }
- .question-tools {
- position: absolute;
- padding: 5px 30px;
- @include base.row-flex;
- gap: 100px;
- bottom: 22px;
- left: 0;
- width: 100%;
+ .question-tools {
+ position: absolute;
+ padding: 5px 30px;
+ @include base.row-flex;
+ gap: 100px;
+ bottom: 22px;
+ left: 0;
+ width: 100%;
- justify-content: space-between;
+ justify-content: space-between;
- .send-btn {
- @include base.row-flex-start;
- gap: 10px;
+ .send-btn {
+ @include base.row-flex-start;
+ gap: 10px;
- i {
- cursor: pointer;
+ i {
+ cursor: pointer;
+ }
}
}
}
}
- }
- /* .view-area {
+ /* .view-area {
background: linear-gradient(-45deg, rgba(238, 152, 82, 0.3),rgba(35, 166, 213,.3), rgba(231, 60, 60, 0.3), rgba(35, 213, 171,.3));
background-size: 400% 400%;
animation: gradient 15s ease infinite;
@@ -417,6 +397,6 @@ onMounted(() => {
}
}
} */
+ }
}
-}
</style>