File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed
packages/x-flow/src/utils Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change 30
30
| zoomOnScroll | 是否通过滚动鼠标滚轮来缩放画布 | ` boolean ` | ` true ` |
31
31
| panOnScroll | 是否通过滚动鼠标滚轮来平移画布 | ` boolean ` | ` false ` |
32
32
| preventScrolling | 是否阻止浏览器在画布上滚动时的默认行为 | ` boolean ` | ` true ` |
33
-
34
-
33
+ | openColorfulMode | 是否开启多彩模式 | ` boolean ` | ` false ` |
35
34
36
35
37
36
## TNodePanel
Original file line number Diff line number Diff line change @@ -340,11 +340,23 @@ export function isTruthy(value: any) {
340
340
return Boolean ( value ) ;
341
341
}
342
342
343
-
344
343
export function hexToRgba ( hex : string , alpha = 0.25 ) {
345
- // 确保输入是合法的六位十六进制颜色
344
+ // 处理缺少 # 前缀的情况
345
+ if ( hex . charAt ( 0 ) !== '#' ) {
346
+ hex = '#' + hex ;
347
+ }
348
+
349
+ // 处理3位十六进制颜色值 (#RGB)
350
+ if ( / ^ # ( [ 0 - 9 A - F a - f ] { 3 } ) $ / . test ( hex ) ) {
351
+ const r = hex . charAt ( 1 ) ;
352
+ const g = hex . charAt ( 2 ) ;
353
+ const b = hex . charAt ( 3 ) ;
354
+ hex = `#${ r } ${ r } ${ g } ${ g } ${ b } ${ b } ` ;
355
+ }
356
+
357
+ // 如果不是合法的六位十六进制颜色,返回默认颜色
346
358
if ( ! / ^ # ( [ 0 - 9 A - F a - f ] { 6 } ) $ / . test ( hex ) ) {
347
- throw new Error ( "Invalid hex color format. Must be #RRGGBB." ) ;
359
+ hex = '#F79009' ; // 使用默认颜色
348
360
}
349
361
350
362
// 提取 R、G 和 B 值
@@ -360,7 +372,7 @@ export function hexToRgba(hex: string, alpha = 0.25) {
360
372
export function getColorfulModeBackground ( color : string , openColorfulMode : boolean ) {
361
373
362
374
if ( ! openColorfulMode ) {
363
- return { } ;
375
+ return { } ;
364
376
}
365
377
return {
366
378
background : `linear-gradient(to bottom, ${ hexToRgba ( color || '#F79009' ) } , #fff)` ,
You can’t perform that action at this time.
0 commit comments