feat: 大屏

This commit is contained in:
ygx
2025-12-23 01:06:06 +08:00
parent 593e7d90e5
commit d760e8f6cc
5 changed files with 21 additions and 11 deletions

View File

@@ -65,11 +65,10 @@ async function appInit() {
const isDark = urlParams.mode === 'dark' const isDark = urlParams.mode === 'dark'
const themeName = isDark ? ThemeEnum.DARK : ThemeEnum.LIGHT const themeName = isDark ? ThemeEnum.DARK : ThemeEnum.LIGHT
// 如果主题不同,则切换 // 如果主题不同,则设置并持久化到localStorage
if (designStore.themeName !== themeName) { if (designStore.themeName !== themeName) {
designStore.darkTheme = isDark designStore.setTheme(isDark)
designStore.themeName = themeName console.log(`[GoView] iframe 模式:已设置主题为 ${urlParams.mode} 并存储到本地`)
console.log(`[GoView] iframe 模式:已设置主题为 ${urlParams.mode}`)
} }
} }

View File

@@ -37,12 +37,11 @@ function autoSwitchThemeFromUrlMode(query: any) {
const isDark = mode === 'dark' const isDark = mode === 'dark'
const themeName = isDark ? ThemeEnum.DARK : ThemeEnum.LIGHT const themeName = isDark ? ThemeEnum.DARK : ThemeEnum.LIGHT
// 如果主题不同,则切换 // 如果主题不同,则设置并持久化到localStorage
if (designStore.themeName !== themeName) { if (designStore.themeName !== themeName) {
designStore.darkTheme = isDark designStore.setTheme(isDark)
designStore.themeName = themeName
setHtmlTheme(themeName) setHtmlTheme(themeName)
console.log(`[GoView] 已切换主题为 ${mode}`) console.log(`[GoView] 已切换主题为 ${mode} 并存储到本地`)
} }
} }
} }

View File

@@ -46,6 +46,12 @@ export const useDesignStore = defineStore({
this.appTheme = color.hex this.appTheme = color.hex
this.appThemeDetail = color this.appThemeDetail = color
setLocalStorage(GO_DESIGN_STORE, this.$state) 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)
} }
} }
}) })

View File

@@ -68,6 +68,11 @@ const handleFocus = () => {
const handleBlur = async () => { const handleBlur = async () => {
focus.value = false focus.value = false
// 如果项目名称为空,不提交
if (!title.value || !title.value.trim()) {
title.value = chartEditStore.getProjectInfo.projectName || ''
return
}
chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_NAME, title.value || '') chartEditStore.setProjectInfo(ProjectInfoEnum.PROJECT_NAME, title.value || '')
const res = (await updateProjectApi({ const res = (await updateProjectApi({
id: fetchRouteParamsLocation(), id: fetchRouteParamsLocation(),

View File

@@ -2,7 +2,7 @@ import { onUnmounted } from 'vue';
import html2canvas from 'html2canvas' import html2canvas from 'html2canvas'
import { getUUID, httpErrorHandle, fetchRouteParamsLocation, base64toFile, JSONStringify, JSONParse } from '@/utils' import { getUUID, httpErrorHandle, fetchRouteParamsLocation, base64toFile, JSONStringify, JSONParse } from '@/utils'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' 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 { useChartHistoryStore } from '@/store/modules/chartHistoryStore/chartHistoryStore'
import { StylesSetting } from '@/components/Pages/ChartItemSetting' import { StylesSetting } from '@/components/Pages/ChartItemSetting'
import { useSystemStore } from '@/store/modules/systemStore/systemStore' import { useSystemStore } from '@/store/modules/systemStore/systemStore'
@@ -290,7 +290,7 @@ export const useSync = () => {
if (updateImg) { if (updateImg) {
// 获取缩略图片 // 获取缩略图片
const range = document.querySelector('.go-edit-range') as HTMLElement const range = document.querySelector('.go-edit-range') as HTMLElement
// 生成图片 // 生成图片(透明底)
const canvasImage: HTMLCanvasElement = await html2canvas(range, { const canvasImage: HTMLCanvasElement = await html2canvas(range, {
backgroundColor: null, backgroundColor: null,
allowTaint: true, allowTaint: true,
@@ -312,7 +312,8 @@ export const useSync = () => {
if (uploadRes.data.result_url) { if (uploadRes.data.result_url) {
await updateProjectApi({ await updateProjectApi({
id: fetchRouteParamsLocation(), id: fetchRouteParamsLocation(),
indexImage: uploadRes.data.result_url indexImage: uploadRes.data.result_url,
backgroundImage: chartEditStore.getEditCanvasConfig.backgroundImage
}) })
} }
} }