@@ -5,28 +5,18 @@ import {
55 IPublicModelNode ,
66 IPublicModelPluginContext ,
77 IPublicTypeDragNodeDataObject ,
8- IPublicTypeI18nData ,
98 IPublicTypeNodeSchema ,
109} from '@alilc/lowcode-types' ;
11- import { isI18nData , isProjectSchema } from '@alilc/lowcode-utils' ;
10+ import { isProjectSchema } from '@alilc/lowcode-utils' ;
1211import { Notification } from '@alifd/next' ;
13- import { intl , getLocale } from '../locale' ;
12+ import { intl } from '../locale' ;
1413
1514function getNodesSchema ( nodes : IPublicModelNode [ ] ) {
1615 const componentsTree = nodes . map ( ( node ) => node ?. exportSchema ( IPublicEnumTransformStage . Clone ) ) ;
1716 const data = { type : 'nodeSchema' , componentsMap : { } , componentsTree } ;
1817 return data ;
1918}
2019
21- function getIntlStr ( data : string | IPublicTypeI18nData ) {
22- if ( ! isI18nData ( data ) ) {
23- return data ;
24- }
25-
26- const locale = getLocale ( ) ;
27- return data [ locale ] || data [ 'zh-CN' ] || data [ 'zh_CN' ] || data [ 'en-US' ] || data [ 'en_US' ] || '' ;
28- }
29-
3020async function getClipboardText ( ) : Promise < IPublicTypeNodeSchema [ ] > {
3121 return new Promise ( ( resolve , reject ) => {
3222 // 使用 Clipboard API 读取剪贴板内容
@@ -61,8 +51,9 @@ async function getClipboardText(): Promise<IPublicTypeNodeSchema[]> {
6151}
6252
6353export const defaultContextMenu = ( ctx : IPublicModelPluginContext ) => {
64- const { material, canvas } = ctx ;
54+ const { material, canvas, common } = ctx ;
6555 const { clipboard } = canvas ;
56+ const { intl : utilsIntl } = common . utils ;
6657
6758 return {
6859 init ( ) {
@@ -150,7 +141,7 @@ export const defaultContextMenu = (ctx: IPublicModelPluginContext) => {
150141 } ) ;
151142 if ( canAddNodes . length === 0 ) {
152143 Notification . open ( {
153- content : `${ nodeSchema . map ( d => getIntlStr ( d . title || d . componentName ) ) . join ( ',' ) } 等组件无法放置到${ getIntlStr ( parent . title || parent . componentName as any ) } 内` ,
144+ content : `${ nodeSchema . map ( d => utilsIntl ( d . title || d . componentName ) ) . join ( ',' ) } 等组件无法放置到${ utilsIntl ( parent . title || parent . componentName as any ) } 内` ,
154145 type : 'error' ,
155146 } ) ;
156147 return ;
@@ -198,7 +189,7 @@ export const defaultContextMenu = (ctx: IPublicModelPluginContext) => {
198189 } ) ;
199190 if ( canAddNodes . length === 0 ) {
200191 Notification . open ( {
201- content : `${ nodeSchema . map ( d => getIntlStr ( d . title || d . componentName ) ) . join ( ',' ) } 等组件无法放置到${ getIntlStr ( node . title || node . componentName as any ) } 内` ,
192+ content : `${ nodeSchema . map ( d => utilsIntl ( d . title || d . componentName ) ) . join ( ',' ) } 等组件无法放置到${ utilsIntl ( node . title || node . componentName as any ) } 内` ,
202193 type : 'error' ,
203194 } ) ;
204195 return ;
0 commit comments