refactor: canvas shape-point style update

This commit is contained in:
wangjiahao
2025-07-21 19:40:02 +08:00
parent 1e0a329ddb
commit 277671c5da
10 changed files with 46 additions and 22 deletions
+2 -2
View File
@@ -44,5 +44,5 @@ async def update_canvas_api(session: SessionDep, user: CurrentUser, dashboard: C
@router.post("/check_name")
async def check_name_api(session: SessionDep, dashboard: QueryDashboard):
return validate_name(session, dashboard)
async def check_name_api(session: SessionDep, user: CurrentUser, dashboard: QueryDashboard):
return validate_name(session, user, dashboard)
@@ -99,19 +99,18 @@ def update_canvas(session: SessionDep, user: CurrentUser, dashboard: CreateDashb
return record
def validate_name(session: SessionDep, dashboard: QueryDashboard) -> bool:
if not dashboard.workspace_id:
raise ValueError("workspace_id is required")
if not dashboard.pid:
raise ValueError("pid is required")
def validate_name(session: SessionDep,user: CurrentUser, dashboard: QueryDashboard) -> bool:
if not dashboard.opt:
raise ValueError("opt is required")
oid = str(user.oid if user.oid is not None else 1)
uid = str(user.id)
if dashboard.opt in ('newLeaf', 'newFolder'):
query = session.query(CoreDashboard).filter(
and_(
CoreDashboard.workspace_id == dashboard.workspace_id,
CoreDashboard.pid == dashboard.pid,
CoreDashboard.workspace_id == oid,
CoreDashboard.create_by == uid,
CoreDashboard.name == dashboard.name
)
)
@@ -120,8 +119,8 @@ def validate_name(session: SessionDep, dashboard: QueryDashboard) -> bool:
raise ValueError("id is required for update operation")
query = session.query(CoreDashboard).filter(
and_(
CoreDashboard.workspace_id == dashboard.workspace_id,
CoreDashboard.pid == dashboard.pid,
CoreDashboard.workspace_id == oid,
CoreDashboard.create_by == uid,
CoreDashboard.name == dashboard.name,
CoreDashboard.id != dashboard.id
)
+3 -1
View File
@@ -32,6 +32,8 @@
"password_reset_successful": "Password reset successful"
},
"dashboard": {
"name_repeat": "Name Repeat",
"rich_text_tips": "Double-click to enter text content",
"exit_preview": "Exit preview",
"no_chat": "No conversations",
"today": "Today",
@@ -471,4 +473,4 @@
"back_community": "Restore to Community Edition",
"confirm_tips": "Are you sure to restore to Community Edition?"
}
}
}
+3 -1
View File
@@ -34,6 +34,8 @@
"password_reset_successful": "重置密码成功"
},
"dashboard": {
"name_repeat": "仪表板名称已被使用",
"rich_text_tips": "双击输入文本内容",
"exit_preview": "退出预览",
"no_chat": "暂无对话",
"today": "今日",
@@ -483,4 +485,4 @@
"back_community": "还原至社区版",
"confirm_tips": "确定还原至社区版?"
}
}
}
@@ -28,8 +28,8 @@ function getPointStyle(point: string) {
// Points at the four corners
if (point.length === 2) {
newLeft = hasL ? '0px' : '100%'
newTop = hasT ? '0px' : '100%'
newLeft = hasL ? '3px' : 'calc(100% - 3px)'
newTop = hasT ? '3px' : 'calc(100% - 3px)'
} else {
// The point between the upper and lower points, with a width centered
if (hasT || hasB) {
@@ -49,7 +49,7 @@ const COMPONENT_LIST = [
component: 'SQText',
name: 'new text',
locked: false,
propValue: 'Double click to edit text',
propValue: null,
editing: false,
x: 1,
y: 1,
@@ -1,7 +1,17 @@
<template>
<div class="rich-main-class" :class="{ 'edit-model': configItem.editing }" draggable="false">
<div
v-if="isDisabled"
v-if="isDisabled && !configItem.propValue"
class="rich-text-empty"
@keydown.stop
@keyup.stop
@mousedown.stop
@dblclick.stop="setEdit"
>
{{ t('dashboard.rich_text_tips') }}
</div>
<div
v-else-if="isDisabled"
draggable="false"
:class="{ 'custom-text-content': true, 'preview-text': true }"
@keydown.stop
@@ -32,7 +42,9 @@ import { computed, nextTick, type PropType, reactive, toRefs } from 'vue'
import { onMounted } from 'vue'
import type { CanvasItem } from '@/utils/canvas.ts'
import { dashboardStoreWithOut } from '@/stores/dashboard/dashboard.ts'
import { useI18n } from 'vue-i18n'
const dashboardStore = dashboardStoreWithOut()
const { t } = useI18n()
const props = defineProps({
configItem: {
@@ -114,7 +126,16 @@ onMounted(() => {
height: 100%;
overflow-y: auto !important;
position: relative;
padding: 12px !important;
.rich-text-empty {
display: flex;
width: 100%;
height: 100%;
align-items: center;
justify-content: center;
font-size: 16px;
color: rgba(100, 106, 115, 1);
}
div::-webkit-scrollbar {
width: 0px !important;
height: 0px !important;
@@ -32,7 +32,7 @@
width: 8px;
height: 8px;
border-radius: 50%;
z-index: 2;
z-index: 10;
}
.sq-component {
@@ -32,13 +32,13 @@ const addComponent = (componentType: string, viewInfo?: any) => {
viewInfo['sourceId'] = viewInfo['id']
viewInfo['id'] = component.id
dashboardStore.addCanvasViewInfo(viewInfo)
}
if (component.component === 'SQTab') {
} else if (component.component === 'SQTab') {
const subTabName = guid('tab')
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
component.propValue[0].name = subTabName
component.activeTabName = subTabName
}
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
dashboardEditorInnerRef.value.addItemToBox(component)
}
@@ -87,7 +87,7 @@ export const saveDashboardResource = (params: any, callBack: Function) => {
} else {
ElMessage({
type: 'warning',
message: 'Name Already In Use',
message: '名称重复',
})
}
})