fix: 设置小助手主题色问题修复

This commit is contained in:
wangdan-fit2cloud 2024-10-23 18:17:20 +08:00
parent 3eb944300d
commit 888ba752d3
3 changed files with 75 additions and 34 deletions

View File

@ -25,7 +25,7 @@
<el-col :span="12"> <el-col :span="12">
<div class="setting-preview border border-r-4 mr-16"> <div class="setting-preview border border-r-4 mr-16">
<div class="setting-preview-container"> <div class="setting-preview-container">
<div class="setting-preview-header" :class="!isDefaultTheme ? 'custom-header' : ''"> <div class="setting-preview-header" :style="customStyle">
<div class="flex-between"> <div class="flex-between">
<div class="flex align-center"> <div class="flex align-center">
<div class="mr-12 ml-24 flex"> <div class="mr-12 ml-24 flex">
@ -54,12 +54,21 @@
<el-button link> <el-button link>
<AppIcon <AppIcon
:iconName="'app-magnify'" :iconName="'app-magnify'"
class="color-secondary" :style="{
color: xpackForm.custom_theme?.header_font_color
}"
style="font-size: 20px" style="font-size: 20px"
></AppIcon> ></AppIcon>
</el-button> </el-button>
<el-button link> <el-button link>
<el-icon :size="20" class="color-secondary"><Close /></el-icon> <el-icon
:size="20"
class="color-secondary"
:style="{
color: xpackForm.custom_theme?.header_font_color
}"
><Close
/></el-icon>
</el-button> </el-button>
</div> </div>
</div> </div>
@ -93,15 +102,12 @@
fit="cover" fit="cover"
style="width: 35px; height: 35px; display: block" style="width: 35px; height: 35px; display: block"
/> />
<LogoIcon <AppAvatar v-else>
v-else <img src="@/assets/user-icon.svg" style="width: 54%" alt="" />
height="35px" </AppAvatar>
style="width: 35px; height: 35px; display: block"
/>
</div> </div>
<img src="@/assets/user-icon.svg" width="270" alt="" />
<img src="@/assets/display-bg3.png" alt="" width="270" /> <img src="@/assets/display-bg3.png" alt="" width="270" class="ml-8" />
</div> </div>
</div> </div>
<div style="position: absolute; bottom: 0"> <div style="position: absolute; bottom: 0">
@ -132,8 +138,11 @@
<el-row class="w-full mb-8"> <el-row class="w-full mb-8">
<el-col :span="12"> <el-col :span="12">
<h5 class="mb-8">自定义主题色</h5> <h5 class="mb-8">自定义主题色</h5>
<el-color-picker v-model="form.custom_theme.theme_color" <div>
/></el-col> <el-color-picker v-model="form.custom_theme.theme_color" />
{{ !form.custom_theme.theme_color ? '默认' : '' }}
</div>
</el-col>
<el-col :span="12"> <el-col :span="12">
<h5 class="mb-8">头部标题字体颜色</h5> <h5 class="mb-8">头部标题字体颜色</h5>
<el-color-picker v-model="form.custom_theme.header_font_color" /> <el-color-picker v-model="form.custom_theme.header_font_color" />
@ -260,7 +269,7 @@
</el-dialog> </el-dialog>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, watch } from 'vue' import { computed, ref, watch } from 'vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import type { FormInstance, FormRules, UploadFiles } from 'element-plus' import type { FormInstance, FormRules, UploadFiles } from 'element-plus'
import { isAppIcon } from '@/utils/application' import { isAppIcon } from '@/utils/application'
@ -289,11 +298,11 @@ const defaultSetting = {
disclaimer_value: '「以上内容均由AI生成仅供参考和借鉴」', disclaimer_value: '「以上内容均由AI生成仅供参考和借鉴」',
custom_theme: { custom_theme: {
theme_color: '', theme_color: '',
header_font_color: '' header_font_color: '#1f2329'
}, },
float_location: { float_location: {
x: { type: '', value: '' }, x: { type: '', value: 0 },
y: { type: '', value: '' } y: { type: '', value: 0 }
} }
} }
@ -314,11 +323,11 @@ const xpackForm = ref<any>({
disclaimer_value: '「以上内容均由AI生成仅供参考和借鉴」', disclaimer_value: '「以上内容均由AI生成仅供参考和借鉴」',
custom_theme: { custom_theme: {
theme_color: '', theme_color: '',
header_font_color: '' header_font_color: '#1f2329'
}, },
float_location: { float_location: {
x: { type: '', value: '' }, x: { type: '', value: 0 },
y: { type: '', value: '' } y: { type: '', value: 0 }
} }
}) })
@ -332,6 +341,13 @@ const loading = ref(false)
const detail = ref<any>(null) const detail = ref<any>(null)
const customStyle = computed(() => {
return {
background: xpackForm.value.custom_theme?.theme_color,
color: xpackForm.value.custom_theme?.header_font_color
}
})
watch(dialogVisible, (bool) => { watch(dialogVisible, (bool) => {
if (!bool) { if (!bool) {
form.value = { form.value = {
@ -381,7 +397,9 @@ const open = (data: any, content: any) => {
xpackForm.value.user_avatar = data.user_avatar xpackForm.value.user_avatar = data.user_avatar
xpackForm.value.disclaimer = data.disclaimer xpackForm.value.disclaimer = data.disclaimer
xpackForm.value.disclaimer_value = data.disclaimer_value xpackForm.value.disclaimer_value = data.disclaimer_value
xpackForm.value.custom_theme = data.custom_theme xpackForm.value.custom_theme.theme_color = data.custom_theme?.theme_color
xpackForm.value.custom_theme.header_font_color = data.custom_theme?.header_font_color || '#1f2329'
xpackForm.value.float_location = data.float_location xpackForm.value.float_location = data.float_location
form.value = xpackForm.value form.value = xpackForm.value

View File

@ -1,6 +1,10 @@
<template> <template>
<div class="chat-embed layout-bg" v-loading="loading"> <div
<div class="chat-embed__header" :class="!isDefaultTheme ? 'custom-header' : ''"> class="chat-embed layout-bg"
v-loading="loading"
:style="{ '--el-color-primary': applicationDetail?.custom_theme?.theme_color }"
>
<div class="chat-embed__header" :style="customStyle">
<div class="chat-width flex align-center"> <div class="chat-width flex align-center">
<div class="mr-12 ml-24 flex"> <div class="mr-12 ml-24 flex">
<AppAvatar <AppAvatar
@ -52,7 +56,12 @@
@click.prevent.stop="show = !show" @click.prevent.stop="show = !show"
class="chat-popover-button cursor color-secondary" class="chat-popover-button cursor color-secondary"
> >
<AppIcon iconName="app-history-outlined"></AppIcon> <AppIcon
iconName="app-history-outlined"
:style="{
color: applicationDetail?.custom_theme?.header_font_color
}"
></AppIcon>
</div> </div>
<el-collapse-transition> <el-collapse-transition>
@ -108,14 +117,10 @@ import useStore from '@/stores'
const { user, log } = useStore() const { user, log } = useStore()
const isDefaultTheme = computed(() => {
return user.isDefaultTheme()
})
const AiChatRef = ref() const AiChatRef = ref()
const loading = ref(false) const loading = ref(false)
const left_loading = ref(false) const left_loading = ref(false)
const chatLogeData = ref<any[]>([]) const chatLogData = ref<any[]>([])
const show = ref(false) const show = ref(false)
const props = defineProps<{ const props = defineProps<{
application_profile: any application_profile: any
@ -138,6 +143,13 @@ const currentChatId = ref('new') // 当前历史记录Id 默认为'new'
const mouseId = ref('') const mouseId = ref('')
const customStyle = computed(() => {
return {
background: applicationDetail.value?.custom_theme?.theme_color,
color: applicationDetail.value?.custom_theme?.header_font_color
}
})
function mouseenter(row: any) { function mouseenter(row: any) {
mouseId.value = row.id mouseId.value = row.id
} }

View File

@ -1,6 +1,11 @@
<template> <template>
<div class="chat-pc layout-bg" :class="classObj" v-loading="loading"> <div
<div class="chat-pc__header" :class="!isDefaultTheme ? 'custom-header' : ''"> class="chat-pc layout-bg"
:class="classObj"
v-loading="loading"
:style="{ '--el-color-primary': applicationDetail?.custom_theme?.theme_color }"
>
<div class="chat-pc__header" :style="customStyle">
<div class="flex align-center"> <div class="flex align-center">
<div class="mr-12 ml-24 flex"> <div class="mr-12 ml-24 flex">
<AppAvatar <AppAvatar
@ -66,7 +71,7 @@
</template> </template>
</common-list> </common-list>
</div> </div>
<div v-if="chatLogData.length" class="gradient-divider lighter mt-8"> <div v-if="chatLogData?.length" class="gradient-divider lighter mt-8">
<span>仅显示最近 20 条对话</span> <span>仅显示最近 20 条对话</span>
</div> </div>
</el-scrollbar> </el-scrollbar>
@ -141,6 +146,13 @@ const isDefaultTheme = computed(() => {
const isCollapse = ref(false) const isCollapse = ref(false)
const customStyle = computed(() => {
return {
background: applicationDetail.value?.custom_theme?.theme_color,
color: applicationDetail.value?.custom_theme?.header_font_color
}
})
const classObj = computed(() => { const classObj = computed(() => {
return { return {
mobile: common.isMobile(), mobile: common.isMobile(),
@ -161,7 +173,6 @@ const AiChatRef = ref()
const loading = ref(false) const loading = ref(false)
const left_loading = ref(false) const left_loading = ref(false)
const applicationDetail = computed({ const applicationDetail = computed({
get: () => { get: () => {
return props.application_profile return props.application_profile
@ -169,7 +180,7 @@ const applicationDetail = computed({
set: (v) => {} set: (v) => {}
}) })
const chatLogeData = ref<any[]>([]) const chatLogData = ref<any[]>([])
const paginationConfig = ref({ const paginationConfig = ref({
current_page: 1, current_page: 1,
@ -239,7 +250,7 @@ function getChatLog(id: string, refresh?: boolean) {
log.asyncGetChatLogClient(id, page, left_loading).then((res: any) => { log.asyncGetChatLogClient(id, page, left_loading).then((res: any) => {
chatLogData.value = res.data.records chatLogData.value = res.data.records
if (refresh) { if (refresh) {
currentChatName.value = chatLogData.value[0].abstract currentChatName.value = chatLogData.value?.[0].abstract
} }
}) })
} }