From d760e8f6ccac4eeb720dc46d18d4b69471c94876 Mon Sep 17 00:00:00 2001 From: ygx Date: Tue, 23 Dec 2025 01:06:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A4=A7=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.ts | 7 +++---- src/router/router-guards.ts | 7 +++---- src/store/modules/designStore/designStore.ts | 6 ++++++ src/views/chart/ContentHeader/headerTitle/index.vue | 5 +++++ src/views/chart/hooks/useSync.hook.ts | 7 ++++--- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/main.ts b/src/main.ts index d1f903d..57f57e4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -65,11 +65,10 @@ async function appInit() { const isDark = urlParams.mode === 'dark' const themeName = isDark ? ThemeEnum.DARK : ThemeEnum.LIGHT - // 如果主题不同,则切换 + // 如果主题不同,则设置并持久化到localStorage if (designStore.themeName !== themeName) { - designStore.darkTheme = isDark - designStore.themeName = themeName - console.log(`[GoView] iframe 模式:已设置主题为 ${urlParams.mode}`) + designStore.setTheme(isDark) + console.log(`[GoView] iframe 模式:已设置主题为 ${urlParams.mode} 并存储到本地`) } } diff --git a/src/router/router-guards.ts b/src/router/router-guards.ts index 5e4fbf9..ba4be11 100644 --- a/src/router/router-guards.ts +++ b/src/router/router-guards.ts @@ -37,12 +37,11 @@ function autoSwitchThemeFromUrlMode(query: any) { const isDark = mode === 'dark' const themeName = isDark ? ThemeEnum.DARK : ThemeEnum.LIGHT - // 如果主题不同,则切换 + // 如果主题不同,则设置并持久化到localStorage if (designStore.themeName !== themeName) { - designStore.darkTheme = isDark - designStore.themeName = themeName + designStore.setTheme(isDark) setHtmlTheme(themeName) - console.log(`[GoView] 已切换主题为 ${mode}`) + console.log(`[GoView] 已切换主题为 ${mode} 并存储到本地`) } } } diff --git a/src/store/modules/designStore/designStore.ts b/src/store/modules/designStore/designStore.ts index d6a54bf..e7a01c6 100644 --- a/src/store/modules/designStore/designStore.ts +++ b/src/store/modules/designStore/designStore.ts @@ -46,6 +46,12 @@ export const useDesignStore = defineStore({ this.appTheme = color.hex this.appThemeDetail = color setLocalStorage(GO_DESIGN_STORE, this.$state) + }, + // 设置主题(不切换,直接设置) + setTheme(isDark: boolean): void { + this.darkTheme = isDark + this.themeName = isDark ? ThemeEnum.DARK : ThemeEnum.LIGHT + setLocalStorage(GO_DESIGN_STORE, this.$state) } } }) \ No newline at end of file diff --git a/src/views/chart/ContentHeader/headerTitle/index.vue b/src/views/chart/ContentHeader/headerTitle/index.vue index 1ed56eb..21d7872 100644 --- a/src/views/chart/ContentHeader/headerTitle/index.vue +++ b/src/views/chart/ContentHeader/headerTitle/index.vue @@ -68,6 +68,11 @@ const handleFocus = () => { const handleBlur = async () => { focus.value = false + // 如果项目名称为空,不提交 + if (!title.value || !title.value.trim()) { + title.value = chartEditStore.getProjectInfo.projectName || '' + return + } chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_NAME, title.value || '') const res = (await updateProjectApi({ id: fetchRouteParamsLocation(), diff --git a/src/views/chart/hooks/useSync.hook.ts b/src/views/chart/hooks/useSync.hook.ts index c5a76f7..f18e5f2 100644 --- a/src/views/chart/hooks/useSync.hook.ts +++ b/src/views/chart/hooks/useSync.hook.ts @@ -2,7 +2,7 @@ import { onUnmounted } from 'vue'; import html2canvas from 'html2canvas' import { getUUID, httpErrorHandle, fetchRouteParamsLocation, base64toFile, JSONStringify, JSONParse } from '@/utils' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' -import { EditCanvasTypeEnum, ChartEditStoreEnum, ProjectInfoEnum, ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d' +import { EditCanvasTypeEnum, ChartEditStoreEnum, ProjectInfoEnum, ChartEditStorage, EditCanvasConfigEnum } from '@/store/modules/chartEditStore/chartEditStore.d' import { useChartHistoryStore } from '@/store/modules/chartHistoryStore/chartHistoryStore' import { StylesSetting } from '@/components/Pages/ChartItemSetting' import { useSystemStore } from '@/store/modules/systemStore/systemStore' @@ -290,7 +290,7 @@ export const useSync = () => { if (updateImg) { // 获取缩略图片 const range = document.querySelector('.go-edit-range') as HTMLElement - // 生成图片 + // 生成图片(透明底) const canvasImage: HTMLCanvasElement = await html2canvas(range, { backgroundColor: null, allowTaint: true, @@ -312,7 +312,8 @@ export const useSync = () => { if (uploadRes.data.result_url) { await updateProjectApi({ id: fetchRouteParamsLocation(), - indexImage: uploadRes.data.result_url + indexImage: uploadRes.data.result_url, + backgroundImage: chartEditStore.getEditCanvasConfig.backgroundImage }) } }