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: Partially fixed issues

albertc1b0df940f27
diff --git a/core/frontend/src/api/modules/domain.ts b/core/frontend/src/api/modules/domain.ts
index 104626e8..87924bea 100644
--- a/core/frontend/src/api/modules/domain.ts
+++ b/core/frontend/src/api/modules/domain.ts
@@ -16,6 +16,7 @@ type DomainParams = {
quota: number
mailboxes: number
email: string
+ urls: string[]
}
export const createDomain = (params: DomainParams) => {
@@ -93,4 +94,8 @@ export const initAiConfiguration = (params: { domain: string, urls: string[] })
successMessage: true,
}
})
+}
+
+export const checkAiConfiguration = () => {
+ return instance.post("/askai/supplier/status")
}
\ No newline at end of file
diff --git a/core/frontend/src/router/modules/settings.ts b/core/frontend/src/router/modules/settings.ts
index 46a6c3bf..f16e0be8 100644
--- a/core/frontend/src/router/modules/settings.ts
+++ b/core/frontend/src/router/modules/settings.ts
@@ -42,7 +42,7 @@ const route: RouteRecordRaw = {
{
path: "ai-model",
name: "AiModel",
- meta: { title: "ai-model", titleKey: "ai-model" },
+ meta: { title: "AI Model", titleKey: "AI Model" },
component: () => import("@/views/settings/ai-model/index.vue")
}
],
diff --git a/core/frontend/src/store/modules/global.ts b/core/frontend/src/store/modules/global.ts
index 1d05e836..95236cd3 100644
--- a/core/frontend/src/store/modules/global.ts
+++ b/core/frontend/src/store/modules/global.ts
@@ -8,6 +8,7 @@ interface LangResponse {
}
export default defineStore('GlobalStore', () => {
+ const domainSource = ref("")
const lang = ref('en')
const langList = ref<Array<{ cn: string; name: string }>>([])
@@ -33,6 +34,7 @@ export default defineStore('GlobalStore', () => {
}
return {
+ domainSource,
lang,
langList,
isCollapse,
@@ -40,4 +42,11 @@ export default defineStore('GlobalStore', () => {
setLang,
setCollapse,
}
+}, {
+ persist: [
+ {
+ pick: ["domainSource"],
+ storage: localStorage
+ }
+ ]
})
diff --git a/core/frontend/src/views/domain/components/DomainForm.vue b/core/frontend/src/views/domain/components/DomainForm.vue
index f0b8ce37..dd39904c 100644
--- a/core/frontend/src/views/domain/components/DomainForm.vue
+++ b/core/frontend/src/views/domain/components/DomainForm.vue
@@ -18,17 +18,12 @@
</n-popover>
</div>
</template>
- <n-input
- v-model:value="form.domain"
- :disabled="isEdit"
- :placeholder="t('domain.form.domainPlaceholder')">
+ <n-input v-model:value="form.domain" :disabled="isEdit"
+ :placeholder="t('domain.form.domainPlaceholder')" @update:value="syncToUrls">
</n-input>
</n-form-item>
<n-form-item v-if="false" label="A记录">
- <n-input
- v-model:value="form.a_record"
- :disabled="isEdit"
- placeholder="请输入A记录,例如:mail.aapanel.com">
+ <n-input v-model:value="form.a_record" :disabled="isEdit" placeholder="请输入A记录,例如:mail.aapanel.com">
</n-input>
</n-form-item>
<n-form-item :label="t('domain.form.quota')">
@@ -39,24 +34,18 @@
</div>
</n-form-item>
<n-form-item :label="t('domain.form.mailboxCount')">
- <n-input-number
- v-model:value="form.mailboxes"
- class="flex-1"
- :min="0"
- :show-button="false">
+ <n-input-number v-model:value="form.mailboxes" class="flex-1" :min="0" :show-button="false">
</n-input-number>
</n-form-item>
<n-form-item :label="t('domain.form.globalCatch')">
- <n-input
- v-model:value="form.email"
- :placeholder="t('domain.form.globalCatchPlaceholder')">
+ <n-input v-model:value="form.email" :placeholder="t('domain.form.globalCatchPlaceholder')">
</n-input>
</n-form-item>
<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 v-if="!aiConfigurationStatus" style="margin: 0 0 15px 0" type="warning" :show-icon="false">
<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>
@@ -74,12 +63,16 @@
</bt-tips>
<n-form-item label="Specify a domain name">
<div class="w-100% flex flex-col gap-2.5">
- <n-input
- v-for="(item, index) in urls"
- :key="index"
- v-model:value="urls[index]"
- placeholder="">
- </n-input>
+ <!-- <n-input v-for="(item, index) in urls" :key="index" v-model:value="urls[index]" placeholder="">
+ </n-input> -->
+ <div v-for="(_, index) in urls" :key="index" class="flex justify-start items-center gap-2.5">
+ <n-input v-model:value="urls[index]" placeholder="">
+ </n-input>
+ <div v-if="index != 0" class="close" @click="removeUrl(index)">
+ <i class="i-material-symbols:close-rounded text-5"></i>
+ </div>
+ <!-- <div v-else class="w-34px h-34px"></div> -->
+ </div>
<n-button type="primary" ghost @click="addUrl">
<template #icon>
@@ -95,122 +88,148 @@
</template>
<script lang="ts" setup>
-import { FormRules } from 'naive-ui'
-import { getByteUnit, getNumber } from '@/utils'
-import { useModal } from '@/hooks/modal/useModal'
-import { createDomain, initAiConfiguration, updateDomain } from '@/api/modules/domain'
-import type { MailDomain } from '../interface'
+ import { FormRules } from 'naive-ui'
+ import { getByteUnit, getNumber } from '@/utils'
+ import { useModal } from '@/hooks/modal/useModal'
+ import { createDomain, initAiConfiguration, updateDomain, checkAiConfiguration } from '@/api/modules/domain'
+ import type { MailDomain } from '../interface'
-const { t } = useI18n()
+ const { t } = useI18n()
+ const isEdit = ref(false)
+ const title = computed(() => {
+ return isEdit.value ? t('domain.form.editTitle') : t('domain.form.addTitle')
+ })
+ const aiConfigurationStatus = ref(false)
-const isEdit = ref(false)
+ const formRef = useTemplateRef('formRef')
+ const initAi = ref(false)
+ const urls = ref([''])
+ const form = reactive({
+ domain: '',
+ a_record: '',
+ quota: 5,
+ quota_unit: 'GB',
+ mailboxes: 50,
+ email: '',
+ })
-const title = computed(() => {
- return isEdit.value ? t('domain.form.editTitle') : t('domain.form.addTitle')
-})
+ const unitOptions = [
+ { label: 'GB', value: 'GB' },
+ { label: 'MB', value: 'MB' },
+ ]
-const formRef = useTemplateRef('formRef')
-const initAi = ref(false)
-const urls = ref([''])
-const form = reactive({
- domain: '',
- a_record: '',
- quota: 5,
- quota_unit: 'GB',
- mailboxes: 50,
- email: '',
-})
+ const rules: FormRules = {
+ domain: {
+ trigger: ['blur', 'input'],
+ validator: () => {
+ if (form.domain.trim() === '') {
+ return new Error(t('domain.form.validation.domainRequired'))
+ }
+ return true
+ },
+ },
+ }
-const unitOptions = [
- { label: 'GB', value: 'GB' },
- { label: 'MB', value: 'MB' },
-]
+ /**
+ * @description Calculate the byte number based on the domain quota and unit
+ * @param quota
+ * @param quota_unit
+ */
+ const getQuotaByte = (quota: number, quota_unit: string) => {
+ switch (quota_unit) {
+ case 'GB':
+ return quota * 1024 * 1024 * 1024
+ case 'MB':
+ return quota * 1024 * 1024
+ default:
+ return quota
+ }
+ }
-const rules: FormRules = {
- domain: {
- trigger: ['blur', 'input'],
- validator: () => {
- if (form.domain.trim() === '') {
- return new Error(t('domain.form.validation.domainRequired'))
- }
- return true
- },
- },
-}
+ /**
+ * @description Sync domain to urls
+ */
+ const syncToUrls = (domainVal: string) => {
+ urls.value[0] = domainVal
+ }
-/**
- * @description Calculate the byte number based on the domain quota and unit
- * @param quota
- * @param quota_unit
- */
-const getQuotaByte = (quota: number, quota_unit: string) => {
- switch (quota_unit) {
- case 'GB':
- return quota * 1024 * 1024 * 1024
- case 'MB':
- return quota * 1024 * 1024
- default:
- return quota
+ /**
+ * @description Remove url
+ */
+ const removeUrl = (index: number) => {
+ urls.value.splice(index, 1)
}
-}
-const [Modal, modalApi] = useModal({
- onChangeState: isOpen => {
- if (isOpen) {
- const state = modalApi.getState<{ isEdit: boolean; row: MailDomain | null }>()
- isEdit.value = state.isEdit
- if (state.row) {
- const { row } = state
- form.domain = row.domain
- form.a_record = row.a_record
- const quota = getByteUnit(row.quota)
- form.quota = getNumber(quota.split(' ')[0])
- form.quota_unit = quota.split(' ')[1]
- form.mailboxes = row.mailboxes
- form.email = row.email
+ const [Modal, modalApi] = useModal({
+ onChangeState: async isOpen => {
+ if (isOpen) {
+ const state = modalApi.getState<{ isEdit: boolean; row: MailDomain | null }>()
+ isEdit.value = state.isEdit
+ const res = await checkAiConfiguration() as Record<string, any>
+ aiConfigurationStatus.value = res.is_configured
+ if (state.row) {
+ const { row } = state
+ form.domain = row.domain
+ form.a_record = row.a_record
+ const quota = getByteUnit(row.quota)
+ form.quota = getNumber(quota.split(' ')[0])
+ form.quota_unit = quota.split(' ')[1]
+ form.mailboxes = row.mailboxes
+ form.email = row.email
+ }
+ } else {
+ form.domain = ''
+ form.a_record = ''
+ form.quota = 5
+ form.quota_unit = 'GB'
+ form.mailboxes = 50
+ form.email = ''
+ urls.value = ['']
}
- } else {
- form.domain = ''
- form.a_record = ''
- form.quota = 5
- form.quota_unit = 'GB'
- form.mailboxes = 50
- form.email = ''
- }
- },
- onConfirm: async () => {
- await formRef.value?.validate()
- if (isEdit.value) {
- await updateDomain({
- domain: form.domain,
- quota: getQuotaByte(form.quota, form.quota_unit),
- mailboxes: form.mailboxes,
- email: form.email,
- })
- } else {
- await createDomain({
- domain: form.domain,
- quota: getQuotaByte(form.quota, form.quota_unit),
- mailboxes: form.mailboxes,
- email: form.email,
- })
- // Init Ai configuration (via. src\api\modules\domain.ts)
- if (initAi.value) {
- await initAiConfiguration({
+ },
+ onConfirm: async () => {
+ await formRef.value?.validate()
+ if (isEdit.value) {
+ await updateDomain({
+ domain: form.domain,
+ quota: getQuotaByte(form.quota, form.quota_unit),
+ mailboxes: form.mailboxes,
+ email: form.email,
+ urls: urls.value
+ })
+ } else {
+ await createDomain({
domain: form.domain,
- urls: urls.value,
+ quota: getQuotaByte(form.quota, form.quota_unit),
+ mailboxes: form.mailboxes,
+ email: form.email,
+ urls: urls.value
})
+ // Init Ai configuration (via. src\api\modules\domain.ts)
+ if (initAi.value) {
+ await initAiConfiguration({
+ domain: form.domain,
+ urls: urls.value,
+ })
+ }
}
- }
- const state = modalApi.getState<{ refresh: Function }>()
- state.refresh()
- },
-})
+ const state = modalApi.getState<{ refresh: Function }>()
+ state.refresh()
+ },
+ })
-/**
- * @description Add url to urls
- */
-function addUrl() {
- urls.value.push('')
-}
+ /**
+ * @description Add url to urls
+ */
+ function addUrl() {
+ urls.value.push('')
+ }
</script>
+
+<style lang="scss" scoped>
+ @use "@/views/domain/pages/editDomain/components/mixin.scss";
+
+ .close {
+ @include mixin.operation-close
+ }
+</style>
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 a27ca276..ffeea9f5 100644
--- a/core/frontend/src/views/domain/pages/editDomain/components/DomainConfiguration.vue
+++ b/core/frontend/src/views/domain/pages/editDomain/components/DomainConfiguration.vue
@@ -17,7 +17,7 @@
<n-form>
<n-form-item>
<template #label><span class="form-label">Domain</span></template>
- <n-input v-model:value="domainTit"></n-input>
+ <n-input v-model:value="domainTit" @input="syncToUrl"></n-input>
</n-form-item>
<n-form-item label="">
<template #label><span class="form-label">Domain Quota</span></template>
@@ -39,7 +39,7 @@
<n-card class="mt-5">
<n-form-item label="Automatically create brand information">
- <n-switch v-model:value="initAi"></n-switch>
+ <n-switch v-model:value="configurationStatus"></n-switch>
</n-form-item>
<n-alert v-if="!configurationStatus" type="warning" class="mb-15px" :show-icon="false">
<div class="w-100% flex justify-between items-center">
@@ -59,12 +59,14 @@
</bt-tips>
<n-form-item label="Specify a domain name">
<div class="w-100% flex flex-col gap-2.5">
- <n-input
- v-for="(_, index) in urls"
- :key="index"
- v-model:value="urls[index]"
- placeholder="">
- </n-input>
+ <div v-for="(_, index) in urls" :key="index" class="flex justify-start items-center gap-2.5">
+ <n-input v-model:value="urls[index]" placeholder="">
+ </n-input>
+ <div v-if="index != 0" class="close" @click="removeUrl(index)">
+ <i class="i-material-symbols:close-rounded text-5"></i>
+ </div>
+ <!-- <div v-else class="w-34px h-34px"></div> -->
+ </div>
<n-button type="primary" ghost @click="addUrl">
<template #icon>
<i class="i-material-symbols:add-circle-outline"></i>
@@ -116,78 +118,89 @@
</template>
<script setup lang="ts">
-import { getDomainDetail } from '../controller/domainConfiguration.controller'
-import { getEditDomainStoreData } from '../store'
-const { domainTit, quota, unit, mailboxes, catch_email, initAi, urls, configurationStatus } =
- getEditDomainStoreData()
-const route = useRoute()
-const domain = route.params.domain as any
-const uinitOptions = ref([
- {
- label: 'B',
- value: 'B',
- },
- {
- label: 'KB',
- value: 'KB',
- },
- {
- label: 'MB',
- value: 'MB',
- },
- {
- label: 'GB',
- value: 'GB',
- },
- {
- label: 'TB',
- value: 'TB',
- },
-])
+ import { getDomainDetail, syncToUrl, removeUrl } from '../controller/domainConfiguration.controller'
+ import { getEditDomainStoreData } from '../store'
+ const {
+ domainTit,
+ quota,
+ unit,
+ mailboxes,
+ catch_email,
+ urls,
+ configurationStatus
+ } = getEditDomainStoreData()
+ const route = useRoute()
+ const domain = route.params.domain as any
+ const uinitOptions = ref([
+ {
+ label: 'B',
+ value: 'B',
+ },
+ {
+ label: 'KB',
+ value: 'KB',
+ },
+ {
+ label: 'MB',
+ value: 'MB',
+ },
+ {
+ label: 'GB',
+ value: 'GB',
+ },
+ {
+ label: 'TB',
+ value: 'TB',
+ },
+ ])
-getDomainDetail(domain)
+ getDomainDetail(domain)
-/**
- * @description Add url to urls
- */
-function addUrl() {
- urls.value.push('')
-}
+ /**
+ * @description Add url to urls
+ */
+ function addUrl() {
+ urls.value.push('')
+ }
</script>
<style scoped lang="scss">
-@use '@/styles/index' as base;
-@use './mixin.scss' as mixin;
+ @use '@/styles/index' as base;
+ @use './mixin.scss' as mixin;
-.content-wrapper {
- @include mixin.content-wrapper;
+ .content-wrapper {
+ @include mixin.content-wrapper;
- // title
- .page-tit {
- @include mixin.page-tit;
- }
-
- .form-label {
- @include mixin.form-label;
- }
+ // title
+ .page-tit {
+ @include mixin.page-tit;
+ }
- // Switch settings
- .switch-settings {
- @mixin settings-label {
- font-size: 14px;
- font-weight: bold;
+ .form-label {
+ @include mixin.form-label;
}
- .switch-item {
- @include base.row-flex;
- justify-content: space-between;
- margin-bottom: 15px;
+ // Switch settings
+ .switch-settings {
+ @mixin settings-label {
+ font-size: 14px;
+ font-weight: bold;
+ }
+
+ .switch-item {
+ @include base.row-flex;
+ justify-content: space-between;
+ margin-bottom: 15px;
- .label {
- color: var(--color-text-2);
- @include settings-label();
+ .label {
+ color: var(--color-text-2);
+ @include settings-label();
+ }
}
}
+
+ .close {
+ @include mixin.operation-close
+ }
}
-}
</style>
diff --git a/core/frontend/src/views/domain/pages/editDomain/components/FooterSettings.vue b/core/frontend/src/views/domain/pages/editDomain/components/FooterSettings.vue
index 1fe72145..614237f3 100644
--- a/core/frontend/src/views/domain/pages/editDomain/components/FooterSettings.vue
+++ b/core/frontend/src/views/domain/pages/editDomain/components/FooterSettings.vue
@@ -23,10 +23,10 @@
<template #label><span class="form-label">Copyright Text</span></template>
<n-input v-model:value="copyright_text"></n-input>
</n-form-item>
- <n-form-item>
+ <!-- <n-form-item>
<template #label><span class="form-label">Disclaimer</span></template>
<n-input v-model:value="disclaimer" type="textarea" :rows="8"></n-input>
- </n-form-item>
+ </n-form-item> -->
</n-form>
</n-card>
</div>
diff --git a/core/frontend/src/views/domain/pages/editDomain/components/Sitemap.vue b/core/frontend/src/views/domain/pages/editDomain/components/Sitemap.vue
index 44868fb3..27f152c6 100644
--- a/core/frontend/src/views/domain/pages/editDomain/components/Sitemap.vue
+++ b/core/frontend/src/views/domain/pages/editDomain/components/Sitemap.vue
@@ -108,25 +108,8 @@ function handleAdd() {
}
.operation {
- width: 34px;
- height: 34px;
- @include base.row-flex-center;
- background: var(--color-bg-1);
- border: 1px solid var(--color-border-1);
- border-radius: 5px;
- color: var(--color-text-2);
- transition: 0.2s all ease-in-out;
- cursor: pointer;
-
- &.close {
- border-color: var(--color-error-1);
- color: var(--color-error-1);
- }
-
- &.close:hover {
- color: #fff;
- background: var(--color-error-1);
- }
+
+ @include mixin.operation-close();
&.save {
color: var(--color-primary-1);
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 169a64ee..65c58537 100644
--- a/core/frontend/src/views/domain/pages/editDomain/components/Styling.vue
+++ b/core/frontend/src/views/domain/pages/editDomain/components/Styling.vue
@@ -132,7 +132,7 @@
</template>
<script setup lang="tsx">
-import { getStylingInfo } from '../controller/styleing.controller'
+import { getStylingInfo } from '../controller/styling.controller'
import { getEditDomainStoreData } from '../store'
const {
accent_color,
diff --git a/core/frontend/src/views/domain/pages/editDomain/components/mixin.scss b/core/frontend/src/views/domain/pages/editDomain/components/mixin.scss
index b7f0d3b8..6a3a4cec 100644
--- a/core/frontend/src/views/domain/pages/editDomain/components/mixin.scss
+++ b/core/frontend/src/views/domain/pages/editDomain/components/mixin.scss
@@ -1,44 +1,66 @@
-@use "@/styles/index" as base;
+@use '@/styles/index' as base;
@mixin content-wrapper {
- width: 866px;
- margin: 0 auto;
- padding-top: 32px;
+ width: 866px;
+ margin: 0 auto;
+ padding-top: 32px;
}
@mixin page-tit {
- @include base.row-flex;
- justify-content: space-between;
- gap: 5px;
-
- .left-tit {
- @include base.row-flex-start;
- gap: 8px;
-
- .back-tool {
- color: var(--color-primary-1);
- @include base.row-flex-start;
- gap: 5px;
- cursor: pointer;
- @include base.transition-all;
-
- .back-btn {
- font-size: 18px;
- }
- }
-
- .tit-content {
- font-size: 16px;
- color: var(--color-text-1);
- font-weight: bold;
- }
- }
-
- .right-tit {}
+ @include base.row-flex;
+ justify-content: space-between;
+ gap: 5px;
+ .left-tit {
+ @include base.row-flex-start;
+ gap: 8px;
+
+ .back-tool {
+ color: var(--color-primary-1);
+ @include base.row-flex-start;
+ gap: 5px;
+ cursor: pointer;
+ @include base.transition-all;
+
+ .back-btn {
+ font-size: 18px;
+ }
+ }
+
+ .tit-content {
+ font-size: 16px;
+ color: var(--color-text-1);
+ font-weight: bold;
+ }
+ }
+
+ .right-tit {
+ }
}
@mixin form-label {
- font-size: 14px;
- color: var(--color-text-2);
-}
\ No newline at end of file
+ font-size: 14px;
+ color: var(--color-text-2);
+}
+
+@mixin operation-close {
+ width: 34px;
+ height: 34px;
+ @include base.row-flex-center;
+ background: var(--color-bg-1);
+ border: 1px solid var(--color-border-1);
+ border-radius: 5px;
+ color: var(--color-text-2);
+ transition: 0.2s all ease-in-out;
+ cursor: pointer;
+
+ &.close {
+ border-color: var(--color-error-1);
+ color: var(--color-error-1);
+ }
+
+ &.close:hover {
+ color: #fff;
+ background: var(--color-error-1);
+ }
+}
diff --git a/core/frontend/src/views/domain/pages/editDomain/controller/aiSettings.controller.ts b/core/frontend/src/views/domain/pages/editDomain/controller/aiSettings.controller.ts
index ee3b4dd1..62eb8386 100644
--- a/core/frontend/src/views/domain/pages/editDomain/controller/aiSettings.controller.ts
+++ b/core/frontend/src/views/domain/pages/editDomain/controller/aiSettings.controller.ts
@@ -22,7 +22,7 @@ export async function getAisettingsInfo(domain: string) {
/**
* @description Update ai settings info
*/
-export async function updateAisettingsInfo(domain: string) {
+export async function updateAiSettingsInfo(domain: string) {
const { prompt } = getEditDomainStoreData()
try {
const res = await instance.post("/askai/project/modify_prompt", {
diff --git a/core/frontend/src/views/domain/pages/editDomain/controller/companyProfile.controller.ts b/core/frontend/src/views/domain/pages/editDomain/controller/companyProfile.controller.ts
index 9d6f73bf..a2baf16a 100644
--- a/core/frontend/src/views/domain/pages/editDomain/controller/companyProfile.controller.ts
+++ b/core/frontend/src/views/domain/pages/editDomain/controller/companyProfile.controller.ts
@@ -62,4 +62,5 @@ export async function updateCompanyProfile(domain: string) {
} catch (error) {
console.warn(error)
}
-}
\ 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 8bdc1bae..7fd32cff 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
@@ -13,8 +13,11 @@ export async function getDomainDetail(domain: string) {
quota,
unit,
mailboxes,
- catch_email
+ catch_email,
+ hasGotDomainConfiguration,
+ urls
} = getEditDomainStoreData()
+ if (hasGotDomainConfiguration.value) return
try {
const { list } = await instance.get("/domains/list", { params: { keyword: domain, page: 1, page_size: 1 }, ...instanceOptions }) as { total: number, list: Record<string, any>[] }
const quotaAndUnit = getByteUnit(list[0].quota, true, 2).split(" ")
@@ -23,7 +26,9 @@ export async function getDomainDetail(domain: string) {
unit.value = quotaAndUnit[1]
mailboxes.value = list[0].mailboxes
catch_email.value = list[0].email
+ urls.value = list[0].urls
await configurationStatus()
+ hasGotDomainConfiguration.value = true
} catch (error) {
console.warn(error)
}
@@ -50,6 +55,7 @@ export async function updateDomain() {
domainTit,
quota,
unit,
+ urls,
mailboxes,
catch_email
} = getEditDomainStoreData()
@@ -62,7 +68,8 @@ export async function updateDomain() {
quota: quotaParam,
rateLimit: 1,
active: 1,
- email: catch_email.value
+ email: catch_email.value,
+ urls: urls.value
}, instanceOptions)
} catch (error) {
console.warn(error)
@@ -86,4 +93,34 @@ function calcBaseUnits(quota: number, unit: string) {
default:
return quota
}
+}
+
+/**
+ * @description Sync domain to url
+ */
+export function syncToUrl(domainVal: string) {
+ const { urls } = getEditDomainStoreData()
+ urls.value[0] = domainVal
+}
+
+/**
+ * @description Remove url
+ */
+export function removeUrl(index: number) {
+ const { urls } = getEditDomainStoreData()
+ urls.value.splice(index, 1)
+}
+
+/**
+ * @description Reset all api status
+ */
+export function resetAllApiStatus() {
+ const { hasGotAisettings, hasGotCompanyProfile, hasGotDomainConfiguration, hasGotFootersettings, hasGotProjectDetail, hasGotSitemap, hasGotStyling } = getEditDomainStoreData()
+ hasGotAisettings.value = false
+ hasGotCompanyProfile.value = false
+ hasGotDomainConfiguration.value = false
+ hasGotFootersettings.value = false
+ hasGotProjectDetail.value = false
+ hasGotSitemap.value = false
+ hasGotStyling.value = false
}
\ No newline at end of file
diff --git a/core/frontend/src/views/domain/pages/editDomain/controller/footerSettings.controller.ts b/core/frontend/src/views/domain/pages/editDomain/controller/footerSettings.controller.ts
index 87bb87a1..7d8edb60 100644
--- a/core/frontend/src/views/domain/pages/editDomain/controller/footerSettings.controller.ts
+++ b/core/frontend/src/views/domain/pages/editDomain/controller/footerSettings.controller.ts
@@ -27,7 +27,7 @@ export async function getFootersettingsInfo(domain: string) {
* @description Update footer settings info
*
*/
-export async function updateFootersettingsInfo(domain: string) {
+export async function updateFooterSettingsInfo(domain: string) {
const {
copyright_text,
disclaimer
diff --git a/core/frontend/src/views/domain/pages/editDomain/controller/styleing.controller.ts b/core/frontend/src/views/domain/pages/editDomain/controller/styling.controller.ts
similarity index 89%
rename from core/frontend/src/views/domain/pages/editDomain/controller/styleing.controller.ts
rename to core/frontend/src/views/domain/pages/editDomain/controller/styling.controller.ts
index 461c2b9c..7cf2e1da 100644
--- a/core/frontend/src/views/domain/pages/editDomain/controller/styleing.controller.ts
+++ b/core/frontend/src/views/domain/pages/editDomain/controller/styling.controller.ts
@@ -2,7 +2,7 @@ import { instance } from "@/api";
import { getEditDomainStoreData } from "../store";
import { instanceOptions } from "./companyProfile.controller"
/**
- * @description Get styleing info
+ * @description Get styling info
*
* @param { string } domain
*/
@@ -16,9 +16,9 @@ export async function getStylingInfo(domain: string) {
link_footer_color,
heading_font,
body_font,
- hasGotStyleing
+ hasGotStyling
} = getEditDomainStoreData()
- if (hasGotStyleing.value) return
+ if (hasGotStyling.value) return
try {
const res = await instance.post("/askai/project/get_style_config", { domain }, instanceOptions) as Record<string, any>
accent_color.value = res.accent_color
@@ -29,16 +29,16 @@ 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
+ hasGotStyling.value = true
} catch (error) {
console.warn(error)
}
}
/**
- * @description Update styleing info
+ * @description Update styling info
*/
-export async function updateStyleingInfo(domain: string) {
+export async function updateStylingInfo(domain: string) {
const {
accent_color,
text_color,
diff --git a/core/frontend/src/views/domain/pages/editDomain/dto/index.ts b/core/frontend/src/views/domain/pages/editDomain/dto/index.ts
index b47cfdc7..53a7d74c 100644
--- a/core/frontend/src/views/domain/pages/editDomain/dto/index.ts
+++ b/core/frontend/src/views/domain/pages/editDomain/dto/index.ts
@@ -10,5 +10,5 @@ export type KnowledgeBase = {
title: string
content: string
kid: string
- update_timme: number
+ update_time: number
}
\ No newline at end of file
diff --git a/core/frontend/src/views/domain/pages/editDomain/index.vue b/core/frontend/src/views/domain/pages/editDomain/index.vue
index e6d09e60..de0407f5 100644
--- a/core/frontend/src/views/domain/pages/editDomain/index.vue
+++ b/core/frontend/src/views/domain/pages/editDomain/index.vue
@@ -2,10 +2,6 @@
<div class="wrapper">
<!-- Page tit -->
<div class="page-tit">
- <div class="back-tool">
- <i class="i-ci:arrow-left-lg text-4"></i>
- <div class="back-btn">back</div>
- </div>
<span class="tit-content"> Domain / Edit domain </span>
</div>
@@ -37,14 +33,15 @@
</template>
<script setup lang="ts">
-import { updateDomain } from './controller/domainConfiguration.controller'
+import { onBeforeRouteLeave } from 'vue-router'
+import { updateDomain,resetAllApiStatus } from './controller/domainConfiguration.controller'
import { updateProjectDetail } from './controller/projectDetail.controller'
import { updateCompanyProfile } from './controller/companyProfile.controller'
-import { updateStyleingInfo } from './controller/styleing.controller'
+import { updateStylingInfo } from './controller/styling.controller'
import { updateTypography } from './controller/typography.controller'
// import {} from "./controller/sitemap.controller"
-import { updateFootersettingsInfo } from './controller/footerSettings.controller'
-import { updateAisettingsInfo } from './controller/aiSettings.controller'
+import { updateFooterSettingsInfo } from './controller/footerSettings.controller'
+import { updateAiSettingsInfo } from './controller/aiSettings.controller'
const DomainConfiguration = defineAsyncComponent(
() => import('./components/DomainConfiguration.vue')
@@ -55,7 +52,7 @@ const Styling = defineAsyncComponent(() => import('./components/Styling.vue'))
// const Typography = defineAsyncComponent(() => import('./components/Typography.vue'))
const Sitemap = defineAsyncComponent(() => import('./components/Sitemap.vue'))
const FooterSettings = defineAsyncComponent(() => import('./components/FooterSettings.vue'))
-const AISettings = defineAsyncComponent(() => import('./components/AISettings.vue'))
+// const AISettings = defineAsyncComponent(() => import('./components/AISettings.vue'))
const menuList = ref([
'Domain Configuration',
@@ -64,7 +61,7 @@ const menuList = ref([
'Styling',
'Sitemap',
'Footer Settings',
- 'AI Settings',
+ // 'AI Settings',
])
const activeTab = ref('Domain Configuration')
const contentMap = new Map([
@@ -74,7 +71,7 @@ const contentMap = new Map([
['Styling', Styling],
['Sitemap', Sitemap],
['Footer Settings', FooterSettings],
- ['AI Settings', AISettings],
+ // ['AI Settings', AISettings],
])
const route = useRoute()
const domain = route.params.domain as string
@@ -94,7 +91,7 @@ function switchHanldeSave() {
updateCompanyProfile(domain)
break
case 'Styling':
- updateStyleingInfo(domain)
+ updateStylingInfo(domain)
break
case 'Typography':
updateTypography(domain)
@@ -102,13 +99,18 @@ function switchHanldeSave() {
case 'Sitemap':
break
case 'Footer Settings':
- updateFootersettingsInfo(domain)
+ updateFooterSettingsInfo(domain)
break
case 'AI Settings':
- updateAisettingsInfo(domain)
+ updateAiSettingsInfo(domain)
break
}
}
+
+/**
+ * Reset all api status when router leave
+ */
+ onBeforeRouteLeave(resetAllApiStatus)
</script>
<style scoped lang="scss">
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 2e93ac9e..f1ecd6b0 100644
--- a/core/frontend/src/views/domain/pages/editDomain/store/index.ts
+++ b/core/frontend/src/views/domain/pages/editDomain/store/index.ts
@@ -1,16 +1,17 @@
import { defineStore, storeToRefs } from "pinia";
import { KnowledgeBase, SiteInfo } from "../dto";
-const editDomainStore = defineStore("editDomainStoroe", () => {
+const editDomainStore = defineStore("editDomainStore", () => {
// domain configuration
+ const hasGotDomainConfiguration = ref(false)
const domainTit = ref("")
const quota = ref("0")
const unit = ref("B")
const mailboxes = ref(0)
const catch_email = ref("")
- const initAi = ref(false)
const urls = ref([""])
const configurationStatus = ref(false)
+
// Project detail
@@ -27,7 +28,7 @@ const editDomainStore = defineStore("editDomainStoroe", () => {
title: "",
content: "",
kid: "",
- update_timme: 0
+ update_time: 0
})
const knowledgeTitle = ref("")
const knowledgeContent = ref("")
@@ -46,8 +47,8 @@ const editDomainStore = defineStore("editDomainStoroe", () => {
const phone = ref("")
const support_url = ref("")
- // Styleing
- const hasGotStyleing = ref(false)
+ // Styling
+ const hasGotStyling = ref(false)
const accent_color = ref("")
const text_color = ref("")
const page_background = ref("")
@@ -76,12 +77,12 @@ const editDomainStore = defineStore("editDomainStoroe", () => {
const prompt = ref("")
return {
+ hasGotDomainConfiguration,
domainTit,
quota,
unit,
mailboxes,
catch_email,
- initAi,
urls,
configurationStatus,
@@ -111,7 +112,7 @@ const editDomainStore = defineStore("editDomainStoroe", () => {
phone,
support_url,
- hasGotStyleing,
+ hasGotStyling,
accent_color,
text_color,
page_background,
diff --git a/core/frontend/src/views/settings/ai-model/components/ModelManager.vue b/core/frontend/src/views/settings/ai-model/components/ModelManager.vue
index 168502f2..0fc536b5 100644
--- a/core/frontend/src/views/settings/ai-model/components/ModelManager.vue
+++ b/core/frontend/src/views/settings/ai-model/components/ModelManager.vue
@@ -5,9 +5,7 @@
<!-- Provider list -->
<div class="left-provider">
<div class="provider-list">
- <div
- v-for="item in providerList"
- :key="item.supplierName"
+ <div v-for="item in providerList" :key="item.supplierName"
:class="['provider-item', { active: item.supplierName == currentProvider?.supplierName }]"
@click="getModelListBySupplier(item)">
<div class="item-icon">
@@ -15,6 +13,7 @@
<i v-else class="i-ai:big-model w-6.5 h-6.5"></i>
</div>
<span class="tit">{{ item.supplierTitle }}</span>
+ <span :class="['status', { active: item.status }]"></span>
</div>
</div>
<div class="add-privider">
@@ -33,13 +32,11 @@
<div class="top-switch">
<div class="switch-info">
<i class="i-ic:baseline-error text-5"></i>
- <span class="tit">DeepSeek</span>
- <n-switch
- v-model:value="currentProvider.status"
+ <span class="tit">{{ currentProvider.supplierName }}</span>
+ <n-switch v-model:value="currentProvider.status"
@update:value="status => changeProviderStatus(status, modelStore)"></n-switch>
</div>
- <i
- class="i-ri:delete-bin-3-line text-5.5 hover:text-red-5 cursor-pointer"
+ <i class="i-ri:delete-bin-3-line text-5.5 hover:text-red-5 cursor-pointer"
@click="removeProvider(modelStore)"></i>
</div>
<div class="center-api">
@@ -50,21 +47,14 @@
<n-input v-model:value="currentProvider.apiKey"></n-input>
<n-button @click="checkProviderApiConfiguration(modelStore)">检查</n-button>
</n-input-group>
- <n-button
- text
- type="info"
- class="mt-5px"
- @click="getProviderConfiguration(modelStore)"
- >点击获取密钥</n-button
- >
+ <n-button text type="info" class="mt-5px"
+ @click="getProviderConfiguration(modelStore)">点击获取密钥</n-button>
</div>
</n-form-item>
<n-form-item label="API地址">
<div class="w-100%">
<n-input v-model:value="currentProvider.baseUrl"></n-input>
- <span class="text-[var(--color-text-3)] mt-5"
- >示例: https://api.deepseek.com/v1</span
- >
+ <span class="text-[var(--color-text-3)] mt-5">示例: https://api.deepseek.com/v1</span>
</div>
</n-form-item>
</n-form>
@@ -86,11 +76,9 @@
<!-- <i class="i-ic:round-check-circle-outline text-5"></i> -->
<span class="model-name">{{ item.title }}</span>
<div class="operation">
- <n-switch
- v-model:value="item.status"
- @update:value="
- status => setModelStatus(item.modelId, status, modelStore)
- "></n-switch>
+ <n-switch v-model:value="item.status" @update:value="
+ status => setModelStatus(item.modelId, status, modelStore)
+ "></n-switch>
</div>
</div>
</div>
@@ -107,208 +95,220 @@
</template>
<script setup lang="ts">
-import AddProvider from './AddProvider.vue'
-import AddModel from './AddModel.vue'
-import { ModelStore, Provider } from '../dto'
-import {
- getModelList,
- getProviderList,
- getProviderConfiguration,
- changeProviderStatus,
- checkProviderApiConfiguration,
- setProviderConfiguration,
- setModelStatus,
- removeProvider,
-} from '../controller'
-const modelStore = inject<ModelStore>('modelStore')!
-const {
- providerList,
- modelList,
- currentProvider,
- configurationLoading,
- addProviderRef,
- addModelRef,
-} = modelStore
-getProviderList(modelStore)
-
-/**
- * @description Get model list
- */
-function getModelListBySupplier(provider: Provider) {
- currentProvider.value = provider
- getModelList(provider.supplierName, modelStore)
-}
-
-/**
- * @description Handle add provider
- */
-function handleAddProvider() {
- addProviderRef.value.open()
-}
-
-/**
- * @description Handle add model
- */
-// function handleAddModel() {
-// addModelRef.value.open()
-// }
+ import AddProvider from './AddProvider.vue'
+ import AddModel from './AddModel.vue'
+ import { ModelStore, Provider } from '../dto'
+ import {
+ getModelList,
+ getProviderList,
+ getProviderConfiguration,
+ changeProviderStatus,
+ checkProviderApiConfiguration,
+ setProviderConfiguration,
+ setModelStatus,
+ removeProvider,
+ } from '../controller'
+ const modelStore = inject<ModelStore>('modelStore')!
+ const {
+ providerList,
+ modelList,
+ currentProvider,
+ configurationLoading,
+ addProviderRef,
+ addModelRef,
+ } = modelStore
+ getProviderList(modelStore)
+
+ /**
+ * @description Get model list
+ */
+ function getModelListBySupplier(provider: Provider) {
+ currentProvider.value = provider
+ getModelList(provider.supplierName, modelStore)
+ }
+
+ /**
+ * @description Handle add provider
+ */
+ function handleAddProvider() {
+ addProviderRef.value.open()
+ }
+
+ /**
+ * @description Handle add model
+ */
+ // function handleAddModel() {
+ // addModelRef.value.open()
+ // }
</script>
<style scoped lang="scss">
-@use '@/styles/index.scss' as base;
+ @use '@/styles/index.scss' as base;
-.manager-wrapper {
- // height: 480px;
- display: grid;
- grid-template-columns: 230px 1fr;
- /* border-top: 1px solid var(--color-border-2);
- border-bottom: 1px solid var(--color-border-2); */
-
- .left-provider {
- height: 100%;
+ .manager-wrapper {
+ // height: 480px;
display: grid;
- grid-template-rows: 1fr 60px;
- border-right: 1px solid var(--color-border-2);
-
- .provider-list {
- @include base.col-flex;
- gap: 0;
-
- .provider-item {
- height: 50px;
- width: 100%;
- box-sizing: border-box;
- padding-left: 10px;
- border-bottom: 1px solid var(--color-border-1);
- @include base.row-flex-start;
- gap: 5px;
- align-items: center;
- transition: 0.15s all ease-in-out;
- cursor: pointer;
+ grid-template-columns: 230px 1fr;
+ /* border-top: 1px solid var(--color-border-2);
+ border-bottom: 1px solid var(--color-border-2); */
- .tit {
- font-size: 14px;
- font-weight: bold;
- }
+ .left-provider {
+ height: 100%;
+ display: grid;
+ grid-template-rows: 1fr 60px;
+ border-right: 1px solid var(--color-border-2);
- &:hover {
- background: #eef9ee;
- }
+ .provider-list {
+ @include base.col-flex;
+ gap: 0;
- &.active {
- background: #eef9ee;
- }
+ .provider-item {
+ height: 50px;
+ width: 100%;
+ box-sizing: border-box;
+ padding-left: 10px;
+ border-bottom: 1px solid var(--color-border-1);
+ @include base.row-flex-start;
+ gap: 5px;
+ align-items: center;
+ transition: 0.15s all ease-in-out;
+ cursor: pointer;
- .item-icon {
- width: 32px;
- @include base.row-flex-center;
- }
- }
- }
+ .tit {
+ font-size: 14px;
+ font-weight: bold;
+ }
- .add-privider {
- @include base.row-flex-center;
- }
- }
+ &:hover {
+ background: #eef9ee;
+ }
- .right-configuration {
- padding: 0 15px 15px;
+ &.active {
+ background: #eef9ee;
+ }
- .top-switch {
- height: 50px;
- @include base.row-flex;
- align-items: center;
- justify-content: space-between;
- border-bottom: 1px solid var(--color-border-2);
+ .item-icon {
+ width: 32px;
+ @include base.row-flex-center;
+ }
- .switch-info {
- @include base.row-flex-start;
- align-items: center;
- gap: 5px;
+ .status {
+ display: block;
+ width: 5px;
+ height: 5px;
+ background: var(--color-text-3);
+ border-radius: 50%;
- .tit {
- font-size: 14px;
- font-weight: bold;
+ &.active {
+ background: var(--color-primary-1)
+ }
+ }
}
}
- }
- .center-api {
- padding-bottom: 15px;
- border-bottom: 1px solid var(--color-border-2);
+ .add-privider {
+ @include base.row-flex-center;
+ }
}
- .bottom-model-list {
- margin-top: 15px;
+ .right-configuration {
+ padding: 0 15px 15px;
- .header-tit {
+ .top-switch {
+ height: 50px;
@include base.row-flex;
+ align-items: center;
justify-content: space-between;
- margin-bottom: 15px;
+ border-bottom: 1px solid var(--color-border-2);
- .tit {
- font-weight: bold;
- font-size: 14px;
- margin-right: 5px;
- }
-
- .sub-tit {
- color: var(--color-text-3);
- }
-
- .add-model {
+ .switch-info {
@include base.row-flex-start;
- gap: 5px;
align-items: center;
- cursor: pointer;
+ gap: 5px;
.tit {
font-size: 14px;
+ font-weight: bold;
}
}
}
- .model-list {
- @include base.col-flex;
- justify-content: flex-start;
+ .center-api {
+ padding-bottom: 15px;
+ border-bottom: 1px solid var(--color-border-2);
+ }
+
+ .bottom-model-list {
+ margin-top: 15px;
- .model-item {
+ .header-tit {
@include base.row-flex;
justify-content: space-between;
- width: 100%;
- align-items: center;
- padding: 10px 5px;
- transition: 0.15s all ease-in-out;
- cursor: pointer;
-
- i.active {
- color: var(--color-primary-1);
- }
+ margin-bottom: 15px;
- .model-name {
+ .tit {
font-weight: bold;
font-size: 14px;
+ margin-right: 5px;
}
- &:hover {
- background: #eef9ee;
+ .sub-tit {
+ color: var(--color-text-3);
}
- .operation {
+ .add-model {
@include base.row-flex-start;
- gap: 10px;
+ gap: 5px;
+ align-items: center;
+ cursor: pointer;
+
+ .tit {
+ font-size: 14px;
+ }
+ }
+ }
+
+ .model-list {
+ @include base.col-flex;
+ justify-content: flex-start;
+
+ .model-item {
+ @include base.row-flex;
+ justify-content: space-between;
+ width: 100%;
+ align-items: center;
+ padding: 10px 5px;
+ transition: 0.15s all ease-in-out;
+ cursor: pointer;
+
+ i.active {
+ color: var(--color-primary-1);
+ }
+
+ .model-name {
+ font-weight: bold;
+ font-size: 14px;
+ }
+
+ &:hover {
+ background: #eef9ee;
+ }
+
+ .operation {
+ @include base.row-flex-start;
+ gap: 10px;
+ }
}
}
}
}
}
-}
</style>
<style>
-.customer-modal {
- .n-card__content {
- padding: 0 !important;
+ .customer-modal {
+ .n-card__content {
+ padding: 0 !important;
+ }
}
-}
</style>
diff --git a/core/frontend/src/views/template/components/CreateTplModal.vue b/core/frontend/src/views/template/components/CreateTplModal.vue
index 57daadb9..e55ee9c9 100644
--- a/core/frontend/src/views/template/components/CreateTplModal.vue
+++ b/core/frontend/src/views/template/components/CreateTplModal.vue
@@ -1,31 +1,16 @@
<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 methodsList"
- :key="index"
- :class="['choose-item', { active: choosedMethod == item }]"
- @click="choosedMethod = item">
+ <div v-for="(item, index) in methodsList" :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">Source Url</span>
- <n-select
- v-model:value="sourceDomain"
- :options="domainList"
- class="flex-1"
- label-field="domain"
- value-field="domain">
+ <n-select v-model:value="sourceDomain" class="flex-1" label-field="domain" value-field="domain" :options="domainList" >
</n-select>
</div>
<div class="desc">
@@ -43,124 +28,132 @@
</template>
<script setup lang="ts">
-import { instance } from '@/api'
-import { createAiTemplate } from '../pages/AITemplate/controller'
-// import { TemplateStore } from '../pages/AITemplate/dto'
-
-// const store = inject<TemplateStore>('modelStore')!
-const router = useRouter()
-const methodsList = ref(['Drag', 'AI', 'HTML'])
-const choosedMethod = ref('AI')
-const sourceDomain = ref('')
-const show = ref(false)
-const emits = defineEmits(['confirmType'])
-const domainList = ref([])
-
-/**
- * @description open modal
- */
-function open() {
- show.value = true
-}
-
-/**
- * @description close modal
- */
-function close() {
- show.value = false
-}
-
-/**
- * @description jump
- */
-async function createTemplate() {
- if (choosedMethod.value == 'AI') {
- const chatId = await createAiTemplate(sourceDomain.value)
- if (chatId) {
- router.push({ name: 'ai-template', params: { chatId } })
- }
- } else {
- emits('confirmType', choosedMethod.value)
+ import { instance } from '@/api'
+ import { createAiTemplate } from '../pages/AITemplate/controller'
+ import { useGlobalStore } from '@/store'
+ // import { TemplateStore } from '../pages/AITemplate/dto'
+
+ // const store = inject<TemplateStore>('modelStore')!
+ const globalStore = useGlobalStore()
+ const router = useRouter()
+ const methodsList = ref(['Drag', 'AI', 'HTML'])
+ const choosedMethod = ref('AI')
+ const sourceDomain = ref('')
+ const show = ref(false)
+ const emits = defineEmits(['confirmType'])
+ const domainList = ref<any>([])
+
+ /**
+ * @description open modal
+ */
+ function open() {
+ show.value = true
}
-}
-defineExpose({
- open,
- close,
-})
-
-/**
- * @description Get domain list
- */
-async function getDomainList() {
- const res = (await instance.get('/domains/list', {
- params: {
- page: 1,
- page_size: 100,
- },
- })) as Record<string, any>
- domainList.value = res.list
-}
-
-getDomainList()
-</script>
-
-<style scoped lang="scss">
-@use '@/styles/index' as base;
-
-.wrapper {
- @include base.col-flex-center;
- height: 153px;
- gap: 20px;
- .creation-methods {
- @include base.row-flex-center;
- border-bottom: 1px solid var(--color-border-1);
- width: 90%;
- gap: 25px;
+ /**
+ * @description close modal
+ */
+ function close() {
+ show.value = false
+ }
- .choose-item {
- @include base.row-flex-start;
- gap: 5px;
- padding: 6px 15px;
- align-items: center;
- cursor: pointer;
- color: var(--color-text-2);
- transition: 0.1s all ease-in-out;
- box-sizing: border-box;
-
- .item-label {
- font-size: 16px;
- transition: 0.2s all ease-in-out;
+ /**
+ * @description jump
+ */
+ async function createTemplate() {
+ if (choosedMethod.value == 'AI') {
+ const chatId = await createAiTemplate(sourceDomain.value)
+ if (chatId) {
+ globalStore.domainSource = sourceDomain.value
+ router.push({ name: 'ai-template', params: { chatId } })
}
+ } else {
+ emits('confirmType', choosedMethod.value)
+ }
+ }
+ defineExpose({
+ open,
+ close,
+ })
+
+ /**
+ * @description Get domain list
+ */
+ async function getDomainList() {
+ const res = (await instance.get('/domains/list', {
+ params: {
+ page: 1,
+ page_size: 100,
+ },
+ })) as Record<string, any>
+ domainList.value = res.list
+ if (globalStore.domainSource) {
+ sourceDomain.value = globalStore.domainSource
+ } else {
+ sourceDomain.value = domainList.value[0].domain
+ }
+ }
- &:hover {
- color: var(--color-primary-1);
- // transform: scale(1.3) translate(0, -5px);
- }
+ getDomainList()
+</script>
- &.active {
- color: var(--color-primary-1);
- transform: scale(1.3) translate(0, -5px);
- font-weight: bold;
- border-bottom: 2px solid var(--color-primary-1);
+<style scoped lang="scss">
+ @use '@/styles/index' as base;
+
+ .wrapper {
+ @include base.col-flex-center;
+ height: 153px;
+ gap: 20px;
+
+ .creation-methods {
+ @include base.row-flex-center;
+ border-bottom: 1px solid var(--color-border-1);
+ width: 90%;
+ gap: 25px;
+
+ .choose-item {
+ @include base.row-flex-start;
+ gap: 5px;
+ padding: 6px 15px;
+ align-items: center;
+ cursor: pointer;
+ color: var(--color-text-2);
+ transition: 0.1s all ease-in-out;
+ box-sizing: border-box;
+
+ .item-label {
+ font-size: 16px;
+ transition: 0.2s all ease-in-out;
+ }
+
+ &:hover {
+ color: var(--color-primary-1);
+ // transform: scale(1.3) translate(0, -5px);
+ }
+
+ &.active {
+ color: var(--color-primary-1);
+ transform: scale(1.3) translate(0, -5px);
+ font-weight: bold;
+ border-bottom: 2px solid var(--color-primary-1);
+ }
}
}
- }
- .url-source {
- width: 90%;
- @include base.row-flex-start;
- gap: 10px;
+ .url-source {
+ width: 90%;
+ @include base.row-flex-start;
+ gap: 10px;
- &.hidden {
- visibility: hidden;
+ &.hidden {
+ visibility: hidden;
+ }
}
- }
- .desc {
- width: 90%;
- font-size: 14px;
- color: var(--color-text-3);
+ .desc {
+ width: 90%;
+ font-size: 14px;
+ color: var(--color-text-3);
+ }
}
-}
</style>
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 0dfa73c7..2557be80 100644
--- a/core/frontend/src/views/template/pages/AITemplate/dto/index.ts
+++ b/core/frontend/src/views/template/pages/AITemplate/dto/index.ts
@@ -8,6 +8,7 @@ export type ChatInfo = {
supplierName: string
title: string
update_time: number
+ domain:string
}
export type ChatMessage = {
diff --git a/core/frontend/src/views/template/pages/AITemplate/index.vue b/core/frontend/src/views/template/pages/AITemplate/index.vue
index 69cc0746..0efcdf6a 100644
--- a/core/frontend/src/views/template/pages/AITemplate/index.vue
+++ b/core/frontend/src/views/template/pages/AITemplate/index.vue
@@ -1,10 +1,7 @@
<template>
<div class="wrapper">
<div class="page-tit">
- <div class="back-tool">
- <i class="i-ci:arrow-left-lg text-4"></i>
- <div class="back-btn">back</div>
- </div>
+
<span class="tit-content"> AI Template </span>
</div>
@@ -14,13 +11,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>
@@ -30,6 +22,13 @@
<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">
+ 您可以说:创建一份欢迎用户加入{{ chatInfo.domain }}的欢迎邮件
+ </div>
+ </div>
+ </div>
<template v-for="item in chatRecord" :key="item[0]">
<div class="answer-container">
<div class="ask-content">
@@ -44,15 +43,12 @@
<!-- <n-spin description="Loading please wait..." :show="generateShow"> -->
<div class="answer-content">
<div class="pic">
- <span class="text-4 text-[var(--color-primary-hover-1)]">BillionMail</span>
+ <span
+ class="text-4 text-[var(--color-primary-hover-1)]">BillionMail</span>
</div>
<div class="text">
- <MarkdownRender
- v-for="(_item, _index) in item[1]"
- :key="_index"
- :content="_item"
- :chat-record-key="item[0]"
- class="mb-4"
+ <MarkdownRender v-for="(_item, _index) in item[1]" :key="_index"
+ :content="_item" :chat-record-key="item[0]" class="mb-4"
@code-render="handleCodeRender">
</MarkdownRender>
</div>
@@ -76,22 +72,23 @@
</div>
<div class="question">
<n-card style="height: 100%">
- <n-input
- v-model:value="questionContent"
- type="textarea"
- class="question-input"
+ <n-input v-model:value="questionContent" type="textarea" class="question-input"
@keydown.enter="sendChat(store)"></n-input>
- <div class="send-btn">
- <!-- <i
+ <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>
+
+ <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"
- 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
- class="i-svg-spinners:pulse-2 text-8 text-[var(--color-primary-1)] hover-text-[var(--color-primary-hover-1)]"
- @click="stopChat(store)"></i>
+ <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
+ 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>
</div>
</n-card>
</div>
@@ -101,16 +98,14 @@
<div style="height: calc(100vh - 177px)">
<div class="h-10 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>
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>
@@ -122,10 +117,7 @@
</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)"
+ <BtEditor v-else :value="previewCode" style="height: calc(100vh - 217px)"
@save="saveCodeChange(store)">
</BtEditor>
</n-scrollbar>
@@ -137,223 +129,234 @@
</template>
<script setup lang="ts">
-import {
- initialTemplateInfo,
- sendChat,
- removeHtmlCodeBlockMarkers,
- getHtmlTemplateContent,
- saveCodeChange,
- stopChat,
-} 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 store = useTemplateStore()
-provide<TemplateStore>('modelStore', store)
-const {
- chatId,
- modelList,
- currentModelTitle,
- previewCode,
- questionContent,
- chatRecord,
- currentChatRecordKey,
- currentModel,
- isChat,
- chatScrollRef,
- scrollWrapperRef,
- scrollable,
-} = 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) {
- // console.log(data.key, currentChatRecordKey.value)
- previewCode.value = removeHtmlCodeBlockMarkers(data.code)
+ import {
+ initialTemplateInfo,
+ sendChat,
+ removeHtmlCodeBlockMarkers,
+ getHtmlTemplateContent,
+ saveCodeChange,
+ stopChat,
+ } 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 store = useTemplateStore()
+ provide<TemplateStore>('modelStore', store)
+ const {
+ chatId,
+ modelList,
+ currentModelTitle,
+ previewCode,
+ questionContent,
+ chatRecord,
+ currentChatRecordKey,
+ currentModel,
+ isChat,
+ chatScrollRef,
+ scrollWrapperRef,
+ scrollable,
+ chatInfo
+ } = 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
+
+ /**
+ * @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) {
+ // console.log(data.key, currentChatRecordKey.value)
+ previewCode.value = removeHtmlCodeBlockMarkers(data.code)
+ }
}
- if (timeoutTimer) {
- clearTimeout(timer)
- timeoutTimer = null
+
+ /**
+ * @description Regenerate
+ */
+ function handleRegenerate(key: string) {
+ questionContent.value = key.split('_+_')[0]
+ sendChat(store)
}
- if (scrollWrapperRef.value.offsetHeight) {
- chatScrollRef.value.scrollTo({ left: 0, top: scrollWrapperRef.value.offsetHeight })
- startIndex++
- return
- } else {
- startIndex++
- timeoutTimer = setTimeout(() => {
- scrollWrapperHeightChange(timeoutTimer, startIndex)
- }, 100)
+
+ /**
+ * @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)
+ }
}
-}
-function handleScroll(event: WheelEvent) {
- if (event.deltaY < 0) {
- scrollable.value = false
+ function handleScroll(event: WheelEvent) {
+ if (event.deltaY < 0) {
+ scrollable.value = false
+ }
}
-}
-onMounted(() => {
- scrollWrapperHeightChange()
-})
+ onMounted(() => {
+ scrollWrapperHeightChange()
+ })
</script>
<style scoped lang="scss">
-@use '@/styles/index' as base;
-@use '../../mixin.scss';
+ @use '@/styles/index' as base;
+ @use '../../mixin.scss';
-.wrapper {
- @mixin content-card {
- border-radius: 5px;
- padding: 20px;
- }
+ .wrapper {
+ @mixin content-card {
+ border-radius: 5px;
+ padding: 20px;
+ }
- @include mixin.wrapper;
+ @include mixin.wrapper;
- .page-tit {
- @include mixin.page-tit;
- }
-
- .ai-container {
- display: grid;
- grid-template-columns: 900px 1fr;
- 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;
- }
-
- @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;
+ .chat-area {
+ display: grid;
+ grid-template-rows: 76px 1fr 230px;
+ 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;
}
- &: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: 200px;
+ bottom: 22px;
+ left: 0;
+ width: 100%;
- .send-btn {
- position: absolute;
- right: 30px;
- bottom: 30px;
- @include base.row-flex-start;
- gap: 10px;
+ justify-content: space-between;
- i {
- cursor: pointer;
+ .send-btn {
+ @include base.row-flex-start;
+ gap: 10px;
+
+ 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;
@@ -372,6 +375,6 @@ onMounted(() => {
}
}
} */
+ }
}
-}
</style>
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 02c3a660..3ff1eb26 100644
--- a/core/frontend/src/views/template/pages/AITemplate/store/index.ts
+++ b/core/frontend/src/views/template/pages/AITemplate/store/index.ts
@@ -6,6 +6,7 @@ export function useTemplateStore(): TemplateStore {
const chatId = ref("")
const questionContent = ref("")
const chatInfo = ref<ChatInfo>({
+ domain:"",
chatId: "",
create_time: 0,
files: [],
@@ -53,6 +54,6 @@ export function useTemplateStore(): TemplateStore {
isChat,
chatScrollRef,
scrollWrapperRef,
- scrollable
+ scrollable,
}
}
\ No newline at end of file