From e753d2c1c301438020350cd205428fe9d9b46bc4 Mon Sep 17 00:00:00 2001 From: dataeaseShu Date: Thu, 28 Aug 2025 15:42:09 +0800 Subject: [PATCH] fix(Appearance Settings): The ratio of the sample image is inconsistent with the actual login logo ratio --- frontend/embedded.html | 2 +- frontend/index.html | 2 +- frontend/src/assets/svg/avatar_personal.svg | 4 +- frontend/src/components/layout/LayoutDsl.vue | 2 +- frontend/src/style.less | 10 ++++ frontend/src/utils/utils.ts | 52 ++++++++++++++-- frontend/src/views/login/index.vue | 2 +- .../src/views/system/appearance/index.vue | 60 +++++++++---------- .../src/views/system/professional/index.vue | 1 + 9 files changed, 93 insertions(+), 42 deletions(-) diff --git a/frontend/embedded.html b/frontend/embedded.html index 12c49178..6938017f 100644 --- a/frontend/embedded.html +++ b/frontend/embedded.html @@ -2,7 +2,7 @@ - + SQLBot diff --git a/frontend/index.html b/frontend/index.html index 12c49178..97c846b8 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -2,7 +2,7 @@ - + SQLBot diff --git a/frontend/src/assets/svg/avatar_personal.svg b/frontend/src/assets/svg/avatar_personal.svg index 34de8b7f..c25f512a 100644 --- a/frontend/src/assets/svg/avatar_personal.svg +++ b/frontend/src/assets/svg/avatar_personal.svg @@ -1,5 +1,5 @@ - - + + diff --git a/frontend/src/components/layout/LayoutDsl.vue b/frontend/src/components/layout/LayoutDsl.vue index 7e82a46c..4691f85d 100644 --- a/frontend/src/components/layout/LayoutDsl.vue +++ b/frontend/src/components/layout/LayoutDsl.vue @@ -70,7 +70,7 @@ const showSysmenu = computed(() => { :class="collapse && 'collapse'" @click="toWorkspace" > - + {{ collapse ? '' : $t('workspace.return_to_workspace') }} diff --git a/frontend/src/style.less b/frontend/src/style.less index 5b7d953f..9969d7dd 100644 --- a/frontend/src/style.less +++ b/frontend/src/style.less @@ -185,6 +185,16 @@ body { } } +.form-content_error_a { + .ed-form-item--default { + margin-bottom: 8px; + + &.is-error { + margin-bottom: 12px; + } + } +} + .ed-dialog { border-radius: 12px !important; } diff --git a/frontend/src/utils/utils.ts b/frontend/src/utils/utils.ts index 5318a712..0d3c0e29 100644 --- a/frontend/src/utils/utils.ts +++ b/frontend/src/utils/utils.ts @@ -107,10 +107,54 @@ export const setTitle = (title?: string) => { document.title = title || 'SQLBot' } -export const setCurrentColor = ( - currentColor: any, - element: HTMLElement = document.documentElement -) => { +function rgbToHex(r: any, g: any, b: any) { + // 确保数值在0-255范围内 + r = Math.max(0, Math.min(255, r)) + g = Math.max(0, Math.min(255, g)) + b = Math.max(0, Math.min(255, b)) + + // 转换为16进制并补零 + const hexR = r.toString(16).padStart(2, '0') + const hexG = g.toString(16).padStart(2, '0') + const hexB = b.toString(16).padStart(2, '0') + + return `#${hexR}${hexG}${hexB}`.toUpperCase() +} +function rgbaToHex(r: any, g: any, b: any, a: any) { + // 处理RGB部分 + const hexR = Math.max(0, Math.min(255, r)).toString(16).padStart(2, '0') + const hexG = Math.max(0, Math.min(255, g)).toString(16).padStart(2, '0') + const hexB = Math.max(0, Math.min(255, b)).toString(16).padStart(2, '0') + + // 处理透明度(可选) + const hexA = + a !== undefined + ? Math.round(Math.max(0, Math.min(1, a)) * 255) + .toString(16) + .padStart(2, '0') + : '' + + return `#${hexR}${hexG}${hexB}${hexA}`.toUpperCase() +} + +export function colorStringToHex(colorStr: any) { + if (colorStr.startsWith('#')) return colorStr + // 提取颜色值 + const rgbRegex = + /^(rgb|rgba)\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)$/ + const match = colorStr.match(rgbRegex) + if (!match) return null + + const r = parseInt(match[2]) + const g = parseInt(match[3]) + const b = parseInt(match[4]) + const a = match[5] ? parseFloat(match[5]) : undefined + + return a !== undefined ? rgbaToHex(r, g, b, a) : rgbToHex(r, g, b) +} + +export const setCurrentColor = (color: any, element: HTMLElement = document.documentElement) => { + const currentColor = colorStringToHex(color) as any element.style.setProperty('--ed-color-primary', currentColor) element.style.setProperty('--van-blue', currentColor) element.style.setProperty( diff --git a/frontend/src/views/login/index.vue b/frontend/src/views/login/index.vue index 402cc48c..6a62efe3 100644 --- a/frontend/src/views/login/index.vue +++ b/frontend/src/views/login/index.vue @@ -5,7 +5,7 @@