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
Added multi-language to the template page
zdm80528c2478ff
diff --git a/core/frontend/src/i18n/lang/en.json b/core/frontend/src/i18n/lang/en.jsonindex dd2730b2..2df62761 100644--- a/core/frontend/src/i18n/lang/en.json+++ b/core/frontend/src/i18n/lang/en.json@@ -366,6 +366,15 @@"type": "Type","createdAt": "Created At"},+ "types": {+ "drag": "Drag",+ "html": "HTML",+ "ai": "AI"+ },+ "edit": {+ "confirm": "Confirm",+ "cancel": "Cancel"+ },"search": {"namePlaceholder": "Search template name"},@@ -402,11 +411,21 @@"createTpl": {"sourceUrl": "Source Url","useAiTools": "Use AI tools to help you automatically generate email content and improve your work efficiency.",- "create": "Create"+ "create": "Create",+ "notices": {+ "domainListEmpty": "Please create the first domain for BillionMail to send emails",+ "aiConfigurationInvalid": "AI large model is not currently configured, you cannot use AI model to create email templates",+ "invalidBrandDomain": "Please create brand information for the domain first"+ },+ "buttons": {+ "createNow": "Create Now",+ "configureNow": "Configure Now"+ }},"ai": {"title": "AI Template","welcomeMessage": "You can say: Create a welcome email for users joining {domain}",+ "greeting": "Let's create a beautiful email template.","brandName": "BillionMail","buttons": {"regenerate": "Regenerate",diff --git a/core/frontend/src/i18n/lang/ja.json b/core/frontend/src/i18n/lang/ja.jsonindex e254afe1..f2e26b02 100644--- a/core/frontend/src/i18n/lang/ja.json+++ b/core/frontend/src/i18n/lang/ja.json@@ -344,6 +344,15 @@"type": "タイプ","createdAt": "作成日"},+ "types": {+ "drag": "ドラッグ",+ "html": "HTML",+ "ai": "AI"+ },+ "edit": {+ "confirm": "確認",+ "cancel": "キャンセル"+ },"search": {"namePlaceholder": "テンプレート名で検索"},@@ -366,9 +375,54 @@},"preview": {"title": "テンプレートプレビュー"+ },+ "loading": {+ "creating": "テンプレート作成中... お待ちください",+ "updating": "テンプレート更新中... お待ちください",+ "copying": "テンプレート複製中... お待ちください",+ "deleting": "テンプレート削除中... お待ちください"}}},+ "template": {+ "template": "テンプレート",+ "createTpl": {+ "sourceUrl": "ソースURL",+ "useAiTools": "AIツールを使用してメールコンテンツを自動生成し、作業効率を向上させます。",+ "create": "作成",+ "notices": {+ "domainListEmpty": "BillionMailでメール送信用の最初のドメインを作成してください",+ "aiConfigurationInvalid": "現在AIモデルが設定されていないため、AIモデルを使用してメールテンプレートを作成できません",+ "invalidBrandDomain": "まずドメインのブランド情報を作成してください"+ },+ "buttons": {+ "createNow": "今すぐ作成",+ "configureNow": "今すぐ設定"+ }+ },+ "ai": {+ "title": "AIテンプレート",+ "welcomeMessage": "例:{domain}に参加するユーザー向けのウェルカムメールを作成してください",+ "greeting": "美しいメールテンプレートを作成しましょう。",+ "brandName": "BillionMail",+ "buttons": {+ "regenerate": "再生成",+ "info": "情報",+ "view": "プレビュー",+ "edit": "編集",+ "copy": "コピー",+ "copied": "コピー済み",+ "apply": "テンプレートを適用"+ },+ "tips": {+ "saveShortcut": "[Ctrl + s] で変更を保存"+ },+ "loading": {+ "message": "読み込み中... お待ちください"+ },+ "send": "送信"+ }+ },"contacts": {"subscribers": {"search": {diff --git a/core/frontend/src/i18n/lang/zh.json b/core/frontend/src/i18n/lang/zh.jsonindex d011ad88..deefcbcf 100644--- a/core/frontend/src/i18n/lang/zh.json+++ b/core/frontend/src/i18n/lang/zh.json@@ -368,6 +368,15 @@"type": "类型","createdAt": "创建时间"},+ "types": {+ "drag": "拖拽",+ "html": "HTML",+ "ai": "AI"+ },+ "edit": {+ "confirm": "确认",+ "cancel": "取消"+ },"search": {"namePlaceholder": "搜索模板名称"},@@ -406,11 +415,21 @@"createTpl": {"sourceUrl": "引用域名","useAiTools": "使用人工智能工具帮您自动生成邮件内容,提升工作您的效率",- "create": "创建"+ "create": "创建",+ "notices": {+ "domainListEmpty": "请先为BillionMail创建第一个用于发件的域名",+ "aiConfigurationInvalid": "当前并未配置AI大模型,您无法使用AI模型创建邮件模板",+ "invalidBrandDomain": "请先为域名创建品牌信息"+ },+ "buttons": {+ "createNow": "立即创建",+ "configureNow": "立即配置"+ }},"ai": {"title": "AI 模板","welcomeMessage": "您可以说:创建一份欢迎用户加入{domain}的欢迎邮件",+ "greeting": "让我们创建一个漂亮的邮件模板。","brandName": "BillionMail","buttons": {"regenerate": "重新生成",diff --git a/core/frontend/src/views/template/components/CreateTplModal.vue b/core/frontend/src/views/template/components/CreateTplModal.vueindex 09a1a7a7..be82b88b 100644--- a/core/frontend/src/views/template/components/CreateTplModal.vue+++ b/core/frontend/src/views/template/components/CreateTplModal.vue@@ -1,40 +1,62 @@<template>- <n-modal v-model:show="show" preset="card" draggable :close-on-esc="false" :mask-closable="false" segmented- class="w-110" title="">+ <n-modal+ v-model:show="show"+ preset="card"+ draggable+ :close-on-esc="false"+ :mask-closable="false"+ segmented+ class="w-110"+ title=""><div class="wrapper"><div class="creation-methods">- <div v-for="(item, index) in computedMethodsList" :key="index"- :class="['choose-item', { active: choosedMethod == item }]" @click="choosedMethod = item">+ <div+ v-for="(item, index) in computedMethodsList"+ :key="index"+ :class="['choose-item', { active: choosedMethod == item }]"+ @click="choosedMethod = item"><span class="item-label">{{ item }}</span></div></div><div :class="['url-source', { hidden: choosedMethod !== 'AI' }]">- <span class="label">{{ $t("template.createTpl.sourceUrl") }}</span>- <n-select v-model:value="sourceDomain" class="flex-1" label-field="domain" value-field="domain"- :options="domainListHasBrandInfo" :disabled="canNotUse" :render-label="renderLabel">+ <span class="label">{{ $t('template.createTpl.sourceUrl') }}</span>+ <n-select+ v-model:value="sourceDomain"+ class="flex-1"+ label-field="domain"+ value-field="domain"+ :options="domainListHasBrandInfo"+ :disabled="canNotUse"+ :render-label="renderLabel"></n-select></div>- <div class="desc" v-if="noticeShowFlag == 'normal'">- {{ $t("template.createTpl.useAiTools") }}+ <div v-if="noticeShowFlag == 'normal'" class="desc">+ {{ $t('template.createTpl.useAiTools') }}</div><div v-else-if="noticeShowFlag == 'domain-list-empty'">- 请先为BillionMail创建第一个用于发件的域名, <n-button text type="primary" @click="jumpToDomainCreate">立即创建</n-button>-+ {{ $t('template.createTpl.notices.domainListEmpty') }},+ <n-button text type="primary" @click="jumpToDomainCreate">{{+ $t('template.createTpl.buttons.createNow')+ }}</n-button></div><div v-else-if="noticeShowFlag == 'ai-configuration-invalid'">- 当前并未配置AI大模型,您无法使用AI模型创建邮件模板,+ {{ $t('template.createTpl.notices.aiConfigurationInvalid') }},<n-popover trigger="hover" placement="right"><template #trigger>- <n-button text type="primary" @click="jumpToAiSettings">立即配置</n-button>+ <n-button text type="primary" @click="jumpToAiSettings">{{+ $t('template.createTpl.buttons.configureNow')+ }}</n-button></template><n-image :src="aiModelNotice" width="600"></n-image></n-popover></div><div v-else-if="noticeShowFlag == 'invalid-brand-domain'">- 请先为域名创建品牌信息,+ {{ $t('template.createTpl.notices.invalidBrandDomain') }},<n-popover trigger="hover" placement="right"><template #trigger>- <n-button text type="primary" @click="jumpToDomainEdit">立即创建</n-button>+ <n-button text type="primary" @click="jumpToDomainEdit">{{+ $t('template.createTpl.buttons.createNow')+ }}</n-button></template><n-image :src="brandInfoNotice" width="600"></n-image></n-popover>@@ -43,10 +65,17 @@<template #footer><div class="flex justify-end">- <n-button type="primary"- :disabled="canNotUse || ['domain-list-empty', 'ai-configuration-invalid', 'invalid-brand-domain'].includes(noticeShowFlag)"- @click="createTemplate">{{- $t("template.createTpl.create") }}</n-button>+ <n-button+ type="primary"+ :disabled="+ canNotUse ||+ ['domain-list-empty', 'ai-configuration-invalid', 'invalid-brand-domain'].includes(+ noticeShowFlag+ )+ "+ @click="createTemplate"+ >{{ $t('template.createTpl.create') }}</n-button+ ></div></template></n-modal>@@ -56,15 +85,15 @@import { instance } from '@/api'import { createAiTemplate } from '../pages/AITemplate/controller'import { useGlobalStore } from '@/store'-import { checkAiConfiguration } from '@/api/modules/domain';-import aiModelNotice from "@/assets/images/template/model-notice.png"-import brandInfoNotice from "@/assets/images/template/create-brand-info.png"-import { SelectOption } from 'naive-ui';+import { checkAiConfiguration } from '@/api/modules/domain'+import aiModelNotice from '@/assets/images/template/model-notice.png'+import brandInfoNotice from '@/assets/images/template/create-brand-info.png'+import { SelectOption } from 'naive-ui'// import { TemplateStore } from '../pages/AITemplate/dto'// const store = inject<TemplateStore>('modelStore')!const props = defineProps<{- onlyAi?: boolean,+ onlyAi?: boolean}>()const globalStore = useGlobalStore()const router = useRouter()@@ -78,7 +107,7 @@ const aiConfigurationStatus = ref(false)const computedMethodsList = computed(() => {if (props.onlyAi) {- return ["AI"]+ return ['AI']} else {return methodsList.value}@@ -89,26 +118,26 @@ const computedMethodsList = computed(() => {*/const noticeShowFlag = computed(() => {if (domainListHasBrandInfo.value.length == 0) {- return "domain-list-empty"+ return 'domain-list-empty'}if (!aiConfigurationStatus.value) {- return "ai-configuration-invalid"+ return 'ai-configuration-invalid'}const domainInfo = domainList.value.find((item: any) => item.domain == sourceDomain.value)if (domainInfo && domainInfo.hasbrandinfo !== 1) {- return "invalid-brand-domain"+ return 'invalid-brand-domain'}- return "normal"+ return 'normal'})/*** @description Calculate the list of domain names for dropdown options*/const domainListHasBrandInfo = computed(() => {- return [...domainList.value].sort((a,b)=>b.hasbrandinfo - a.hasbrandinfo)+ return [...domainList.value].sort((a, b) => b.hasbrandinfo - a.hasbrandinfo)})/**@@ -125,7 +154,7 @@ const canNotUse = computed(() => {* @description open modal*/async function open() {- const res = await checkAiConfiguration() as Record<string, any>+ const res = (await checkAiConfiguration()) as Record<string, any>aiConfigurationStatus.value = res.is_configuredawait getDomainList()@@ -162,10 +191,10 @@ async function createTemplate() {*/function jumpToDomainCreate() {router.push({- name: "Domain",+ name: 'Domain',query: {- init: "init-domain"- }+ init: 'init-domain',+ },})}@@ -174,7 +203,7 @@ function jumpToDomainCreate() {*/function jumpToAiSettings() {router.push({- name: "AiModel"+ name: 'AiModel',})}@@ -183,20 +212,24 @@ function jumpToAiSettings() {*/function jumpToDomainEdit() {router.push({- name: "EditDomain",+ name: 'EditDomain',params: {- domain: sourceDomain.value- }+ domain: sourceDomain.value,+ },})}/*** @description Render select label*/-function renderLabel(option:SelectOption){- if(option.hasbrandinfo){- return <div><i class="i-domain:brand-info w-4 h-4 mr-1.25"></i> <span>{option.domain}</span></div>- }else{+function renderLabel(option: SelectOption) {+ if (option.hasbrandinfo) {+ return (+ <div>+ <i class="i-domain:brand-info w-4 h-4 mr-1.25"></i> <span>{option.domain}</span>+ </div>+ )+ } else {return <span>{option.domain}</span>}}@@ -230,7 +263,6 @@ async function getDomainList() {globalStore.domainSource = domainListHasBrandInfo.value[0].domain}}-</script><style scoped lang="scss">diff --git a/core/frontend/src/views/template/index.vue b/core/frontend/src/views/template/index.vueindex ecf32a2c..80575f5f 100644--- a/core/frontend/src/views/template/index.vue+++ b/core/frontend/src/views/template/index.vue@@ -105,36 +105,36 @@ const columns = ref<DataTableColumns<Template>>([} else {return <div class="flex justify-start gap-1.25 items-center"><n-input class="edit-domain-input" v-model:value={row.edit_name}></n-input>- <n-button text type="info" class="text-12px" onClick={()=>confirmUpdateTemplateName(row)}>Confirm</n-button>+ <n-button text type="info" class="text-12px" onClick={()=>confirmUpdateTemplateName(row)}>{t('market.template.edit.confirm')}</n-button><n-button text type="default" onClick={()=>{row.isEdit = falserow.edit_name = ""- }}>Cancel</n-button>+ }}>{t('market.template.edit.cancel')}</n-button></div>}},},{key: 'add_type',- title: 'Type',+ title: t('market.template.columns.type'),minWidth: 140,render: row => {if (row.add_type === 1) {return (<NTag size="small" bordered={false} type="primary">- Drag+ {t('market.template.types.drag')}</NTag>)} else if (row.add_type === 0) {return (<NTag size="small" bordered={false} type="info">- HTML+ {t('market.template.types.html')}</NTag>)} else if (row.add_type == 2) {return (<NTag size="small" bordered={false} type="success">- AI+ {t('market.template.types.ai')}</NTag>)}diff --git a/core/frontend/src/views/template/pages/AITemplate/index.vue b/core/frontend/src/views/template/pages/AITemplate/index.vueindex 8dd34188..c7bd9756 100644--- a/core/frontend/src/views/template/pages/AITemplate/index.vue+++ b/core/frontend/src/views/template/pages/AITemplate/index.vue@@ -15,19 +15,18 @@</div></n-card></div> -->-<div ref="answerRef" class="answer" @wheel="handleScroll"><n-card class="h-100%"><n-scrollbar ref="chatScrollRef" style="height: calc(100vh - 415px)">- <div class="answer-container" v-if="chatRecord.size == 0">+ <div v-if="chatRecord.size == 0" class="answer-container"><div class="ask-content"><div class="pic"><iclass="i-material-symbols:account-circle text-6 text-[var(--color-primary-hover-1)]"></i></div><div class="text">- Let's create a beautiful email template.+ {{ $t('template.ai.greeting') }}</div></div></div>@@ -51,9 +50,13 @@}}</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">@@ -68,9 +71,11 @@<span>{{ $t('template.ai.buttons.info') }}</span></div></template>- <div v-if="usageRecord.get(item[0])"+ <div+ v-if="usageRecord.get(item[0])"class="flex justify-start items-center gap-2.5">- <div v-for="(info, info_key) in usageRecord.get(item[0])"+ <div+ v-for="(info, info_key) in usageRecord.get(item[0])":key="info_key"><span class="fw-bold">{{ info_key }}: </span><span>{{ info }}</span>@@ -88,21 +93,30 @@</div><div class="question"><n-card style="height: 100%">- <n-input v-model:value="questionContent" type="textarea"+ <n-input+ v-model:value="questionContent"+ type="textarea":placeholder="$t('template.ai.welcomeMessage', { domain: chatInfo.domain })"- class="question-input" @keydown.enter="e => sendChat(store, e)"></n-input>+ class="question-input"+ @keydown.enter="e => sendChat(store, e)"></n-input><div class="question-tools">- <n-select v-model:value="currentModelTitle" :options="modelList" label-field="title"- value-field="title" @update:value="changeModel">+ <n-select+ v-model:value="currentModelTitle"+ :options="modelList"+ label-field="title"+ value-field="title"+ @update:value="changeModel"></n-select><div class="send-btn"><!-- <iclass="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-elseclass="i-svg-spinners:pulse-2 text-8 text-[var(--color-primary-1)] hover-text-[var(--color-primary-hover-1)]"@click="stopChat(store)"></i></div>@@ -116,14 +130,16 @@<div class="h-10 flex justify-between items-center gap-2.5 mb-5"><div class="flex justify-start 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>@@ -131,10 +147,15 @@{{ $t('template.ai.buttons.edit') }}</n-button></n-button-group>- <span v-if="previewStatus == 'edit'">{{ $t('template.ai.tips.saveShortcut') }}</span>+ <span v-if="previewStatus == 'edit'">{{+ $t('template.ai.tips.saveShortcut')+ }}</span></div><span class="text-4 fw-bold">{{ previewTit }}</span>- <n-button style="width: 134px;" type="primary" :disabled="!previewCode"+ <n-button+ style="width: 134px"+ type="primary"+ :disabled="!previewCode"@click="goToSendEmail"><template #icon><i class="i-mingcute:mail-send-fill"></i>@@ -144,9 +165,16 @@</div><n-scrollbar style="height: calc(100% - 40px)"><div v-if="previewStatus == 'view' && isChat" v-html="previewCode"></div>- <iframe v-else-if="previewStatus == 'view' && !isChat" :srcdoc="previewCode" frameborder="0"- class="w-100%" style="height: calc(100vh - 224px)"></iframe>- <BtEditor v-else v-model:value="previewCode" style="height: calc(100vh - 217px)"+ <iframe+ v-else-if="previewStatus == 'view' && !isChat"+ :srcdoc="previewCode"+ frameborder="0"+ class="w-100%"+ style="height: calc(100vh - 224px)"></iframe>+ <BtEditor+ v-else+ v-model:value="previewCode"+ style="height: calc(100vh - 217px)"@save="saveCodeChange(store)"></BtEditor></n-scrollbar>@@ -167,7 +195,7 @@ import {saveCodeChange,stopChat,removeSignCode,- getContentFromTitleTags+ getContentFromTitleTags,} from './controller'import MarkdownRender from './components/MarkdownRender.vue'import { useTemplateStore } from './store'@@ -192,7 +220,7 @@ const {scrollable,chatInfo,previewTit,- usageRecord+ usageRecord,} = storeconst route = useRoute()@@ -275,10 +303,10 @@ async function goToSendEmail() {await saveCodeChange(store)globalStore.temp_subject = previewTit.valuerouter.push({- path: "/market/task/edit",+ path: '/market/task/edit',query: {- chat_id: chatInfo.value.chatId- }+ chat_id: chatInfo.value.chatId,+ },})}