@ant-design/agentic-ui 2.30.17 → 2.30.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Hooks/useLanguage.d.ts +25 -0
- package/dist/I18n/locales.d.ts +25 -0
- package/dist/I18n/locales.js +58 -2
- package/dist/MarkdownEditor/editor/elements/Code/index.js +12 -0
- package/dist/MarkdownEditor/editor/plugins/hotKeyCommands/enter.js +5 -0
- package/dist/MarkdownInputField/AttachmentButton/index.js +55 -5
- package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundary.d.ts +50 -0
- package/dist/Plugins/code/components/CodeToolbar.js +1 -1
- package/dist/Schema/SchemaForm/index.js +18 -9
- package/dist/Workspace/File/FileTypeProcessor.js +1 -4
- package/dist/Workspace/File/PreviewComponent.js +6 -6
- package/dist/Workspace/File/index.d.ts +1 -0
- package/dist/Workspace/File/index.js +1 -0
- package/dist/Workspace/File/utils.js +4 -2
- package/dist/Workspace/types.d.ts +8 -1
- package/dist/Workspace/types.js +74 -35
- package/package.json +1 -1
|
@@ -437,6 +437,31 @@ export declare function useLanguage(): {
|
|
|
437
437
|
'jinja.template.filter.description': string;
|
|
438
438
|
'jinja.template.setVariable.title': string;
|
|
439
439
|
'jinja.template.setVariable.description': string;
|
|
440
|
+
'schemaForm.invalidFormat': string;
|
|
441
|
+
'schemaForm.mustBeNumber': string;
|
|
442
|
+
'schemaForm.minValue': string;
|
|
443
|
+
'schemaForm.maxValue': string;
|
|
444
|
+
'schemaForm.minItems': string;
|
|
445
|
+
'schemaForm.maxItems': string;
|
|
446
|
+
'schemaForm.addItem': string;
|
|
447
|
+
'schemaForm.deleteItem': string;
|
|
448
|
+
'fileType.plainText': string;
|
|
449
|
+
'fileType.image': string;
|
|
450
|
+
'fileType.video': string;
|
|
451
|
+
'fileType.audio': string;
|
|
452
|
+
'fileType.pdf': string;
|
|
453
|
+
'fileType.word': string;
|
|
454
|
+
'fileType.excel': string;
|
|
455
|
+
'fileType.csv': string;
|
|
456
|
+
'fileType.archive': string;
|
|
457
|
+
'fileType.shell': string;
|
|
458
|
+
'fileType.config': string;
|
|
459
|
+
'fileType.powerpoint': string;
|
|
460
|
+
'workspace.file.unsupportedPreview': string;
|
|
461
|
+
'workspace.file.downloadButton': string;
|
|
462
|
+
'workspace.file.videoNotSupported': string;
|
|
463
|
+
'workspace.file.audioNotSupported': string;
|
|
464
|
+
'workspace.file.fileType': string;
|
|
440
465
|
};
|
|
441
466
|
setLanguage: ((language: "zh-CN" | "en-US") => void) | undefined;
|
|
442
467
|
toggleLanguage: () => void;
|
package/dist/I18n/locales.d.ts
CHANGED
|
@@ -399,6 +399,31 @@ export declare const cnLabels: {
|
|
|
399
399
|
'jinja.template.filter.description': string;
|
|
400
400
|
'jinja.template.setVariable.title': string;
|
|
401
401
|
'jinja.template.setVariable.description': string;
|
|
402
|
+
'schemaForm.invalidFormat': string;
|
|
403
|
+
'schemaForm.mustBeNumber': string;
|
|
404
|
+
'schemaForm.minValue': string;
|
|
405
|
+
'schemaForm.maxValue': string;
|
|
406
|
+
'schemaForm.minItems': string;
|
|
407
|
+
'schemaForm.maxItems': string;
|
|
408
|
+
'schemaForm.addItem': string;
|
|
409
|
+
'schemaForm.deleteItem': string;
|
|
410
|
+
'fileType.plainText': string;
|
|
411
|
+
'fileType.image': string;
|
|
412
|
+
'fileType.video': string;
|
|
413
|
+
'fileType.audio': string;
|
|
414
|
+
'fileType.pdf': string;
|
|
415
|
+
'fileType.word': string;
|
|
416
|
+
'fileType.excel': string;
|
|
417
|
+
'fileType.csv': string;
|
|
418
|
+
'fileType.archive': string;
|
|
419
|
+
'fileType.shell': string;
|
|
420
|
+
'fileType.config': string;
|
|
421
|
+
'fileType.powerpoint': string;
|
|
422
|
+
'workspace.file.unsupportedPreview': string;
|
|
423
|
+
'workspace.file.downloadButton': string;
|
|
424
|
+
'workspace.file.videoNotSupported': string;
|
|
425
|
+
'workspace.file.audioNotSupported': string;
|
|
426
|
+
'workspace.file.fileType': string;
|
|
402
427
|
};
|
|
403
428
|
/**
|
|
404
429
|
* 英文标签映射对象
|
package/dist/I18n/locales.js
CHANGED
|
@@ -426,7 +426,35 @@
|
|
|
426
426
|
'jinja.template.filter.title': '过滤器',
|
|
427
427
|
'jinja.template.filter.description': '{{ value | filter }}',
|
|
428
428
|
'jinja.template.setVariable.title': '设置变量',
|
|
429
|
-
'jinja.template.setVariable.description': '{% set name = value %}'
|
|
429
|
+
'jinja.template.setVariable.description': '{% set name = value %}',
|
|
430
|
+
// SchemaForm validation messages
|
|
431
|
+
'schemaForm.invalidFormat': '格式不正确',
|
|
432
|
+
'schemaForm.mustBeNumber': '必须是数字',
|
|
433
|
+
'schemaForm.minValue': '不能小于 ${min}',
|
|
434
|
+
'schemaForm.maxValue': '不能大于 ${max}',
|
|
435
|
+
'schemaForm.minItems': '至少需要 ${min} 项',
|
|
436
|
+
'schemaForm.maxItems': '最多只能有 ${max} 项',
|
|
437
|
+
'schemaForm.addItem': '添加',
|
|
438
|
+
'schemaForm.deleteItem': '删除',
|
|
439
|
+
// File type names
|
|
440
|
+
'fileType.plainText': '文本文件',
|
|
441
|
+
'fileType.image': '图片',
|
|
442
|
+
'fileType.video': '视频',
|
|
443
|
+
'fileType.audio': '音频',
|
|
444
|
+
'fileType.pdf': 'PDF 文档',
|
|
445
|
+
'fileType.word': 'Word 文档',
|
|
446
|
+
'fileType.excel': 'Excel 表格',
|
|
447
|
+
'fileType.csv': 'CSV 文件',
|
|
448
|
+
'fileType.archive': '压缩文件',
|
|
449
|
+
'fileType.shell': 'Shell 脚本',
|
|
450
|
+
'fileType.config': '配置文件',
|
|
451
|
+
'fileType.powerpoint': 'PowerPoint 演示文稿',
|
|
452
|
+
// PreviewComponent messages
|
|
453
|
+
'workspace.file.unsupportedPreview': '此文件无法预览,请下载查看。',
|
|
454
|
+
'workspace.file.downloadButton': '下载',
|
|
455
|
+
'workspace.file.videoNotSupported': '您的浏览器不支持视频播放',
|
|
456
|
+
'workspace.file.audioNotSupported': '您的浏览器不支持音频播放',
|
|
457
|
+
'workspace.file.fileType': '文件类型:'
|
|
430
458
|
};
|
|
431
459
|
/**
|
|
432
460
|
* 英文标签映射对象
|
|
@@ -856,5 +884,33 @@
|
|
|
856
884
|
'jinja.template.filter.title': 'Filter',
|
|
857
885
|
'jinja.template.filter.description': '{{ value | filter }}',
|
|
858
886
|
'jinja.template.setVariable.title': 'Set variable',
|
|
859
|
-
'jinja.template.setVariable.description': '{% set name = value %}'
|
|
887
|
+
'jinja.template.setVariable.description': '{% set name = value %}',
|
|
888
|
+
// SchemaForm validation messages
|
|
889
|
+
'schemaForm.invalidFormat': 'Invalid format',
|
|
890
|
+
'schemaForm.mustBeNumber': 'Must be a number',
|
|
891
|
+
'schemaForm.minValue': 'Cannot be less than ${min}',
|
|
892
|
+
'schemaForm.maxValue': 'Cannot be greater than ${max}',
|
|
893
|
+
'schemaForm.minItems': 'Must have at least ${min} items',
|
|
894
|
+
'schemaForm.maxItems': 'Cannot have more than ${max} items',
|
|
895
|
+
'schemaForm.addItem': 'Add',
|
|
896
|
+
'schemaForm.deleteItem': 'Delete',
|
|
897
|
+
// File type names
|
|
898
|
+
'fileType.plainText': 'Text file',
|
|
899
|
+
'fileType.image': 'Image',
|
|
900
|
+
'fileType.video': 'Video',
|
|
901
|
+
'fileType.audio': 'Audio',
|
|
902
|
+
'fileType.pdf': 'PDF document',
|
|
903
|
+
'fileType.word': 'Word document',
|
|
904
|
+
'fileType.excel': 'Excel spreadsheet',
|
|
905
|
+
'fileType.csv': 'CSV file',
|
|
906
|
+
'fileType.archive': 'Archive',
|
|
907
|
+
'fileType.shell': 'Shell script',
|
|
908
|
+
'fileType.config': 'Configuration file',
|
|
909
|
+
'fileType.powerpoint': 'PowerPoint presentation',
|
|
910
|
+
// PreviewComponent messages
|
|
911
|
+
'workspace.file.unsupportedPreview': 'This file cannot be previewed, please download to view.',
|
|
912
|
+
'workspace.file.downloadButton': 'Download',
|
|
913
|
+
'workspace.file.videoNotSupported': 'Your browser does not support video playback',
|
|
914
|
+
'workspace.file.audioNotSupported': 'Your browser does not support audio playback',
|
|
915
|
+
'workspace.file.fileType': 'File type: '
|
|
860
916
|
};
|
|
@@ -107,6 +107,18 @@ export var Code = function Code(param) {
|
|
|
107
107
|
background: '#FFFFFF',
|
|
108
108
|
boxShadow: 'var(--shadow-control-base)',
|
|
109
109
|
position: 'relative'
|
|
110
|
+
},
|
|
111
|
+
onKeyDown: function onKeyDown(e) {
|
|
112
|
+
if (e.key === 'Enter') {
|
|
113
|
+
e.stopPropagation();
|
|
114
|
+
e.preventDefault();
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
onKeyUp: function onKeyUp(e) {
|
|
118
|
+
if (e.key === 'Enter') {
|
|
119
|
+
e.stopPropagation();
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
}
|
|
110
122
|
}
|
|
111
123
|
}), /*#__PURE__*/ React.createElement("div", {
|
|
112
124
|
style: {
|
|
@@ -179,6 +179,11 @@ export var EnterKey = /*#__PURE__*/ function() {
|
|
|
179
179
|
this.empty(e, path);
|
|
180
180
|
return;
|
|
181
181
|
}
|
|
182
|
+
if (el.type === 'code') {
|
|
183
|
+
Transforms.insertText(this.editor, '\n');
|
|
184
|
+
e.preventDefault();
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
182
187
|
if (el.type === 'break') {
|
|
183
188
|
Transforms.insertNodes(this.editor, {
|
|
184
189
|
type: 'paragraph',
|
|
@@ -47,6 +47,45 @@ function _instanceof(left, right) {
|
|
|
47
47
|
return left instanceof right;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
+
function _object_spread(target) {
|
|
51
|
+
for(var i = 1; i < arguments.length; i++){
|
|
52
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
53
|
+
var ownKeys = Object.keys(source);
|
|
54
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
55
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
56
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
ownKeys.forEach(function(key) {
|
|
60
|
+
_define_property(target, key, source[key]);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return target;
|
|
64
|
+
}
|
|
65
|
+
function ownKeys(object, enumerableOnly) {
|
|
66
|
+
var keys = Object.keys(object);
|
|
67
|
+
if (Object.getOwnPropertySymbols) {
|
|
68
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
69
|
+
if (enumerableOnly) {
|
|
70
|
+
symbols = symbols.filter(function(sym) {
|
|
71
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
keys.push.apply(keys, symbols);
|
|
75
|
+
}
|
|
76
|
+
return keys;
|
|
77
|
+
}
|
|
78
|
+
function _object_spread_props(target, source) {
|
|
79
|
+
source = source != null ? source : {};
|
|
80
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
81
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
82
|
+
} else {
|
|
83
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
84
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return target;
|
|
88
|
+
}
|
|
50
89
|
function _ts_generator(thisArg, body) {
|
|
51
90
|
var f, y, t, _ = {
|
|
52
91
|
label: 0,
|
|
@@ -357,18 +396,29 @@ var processFile = function processFile(file, index, map, props) {
|
|
|
357
396
|
* @param props.locale - 国际化文案
|
|
358
397
|
*/ export var upLoadFileToServer = function upLoadFileToServer(files, props) {
|
|
359
398
|
return _async_to_generator(function() {
|
|
360
|
-
var map, existingFileCount, hideLoading, fileList, totalCount, isMaxExceeded, isMinNotMet,
|
|
399
|
+
var map, existingFileCount, notifyChange, hideLoading, fileList, totalCount, isMaxExceeded, isMinNotMet, propsWithNotify, _props_onExceedMaxCount, maxCount, rawMessage, errorMessage, i, error;
|
|
361
400
|
return _ts_generator(this, function(_state) {
|
|
362
401
|
switch(_state.label){
|
|
363
402
|
case 0:
|
|
364
403
|
map = props.fileMap || new Map();
|
|
365
404
|
existingFileCount = map.size;
|
|
405
|
+
// Always notify with a new Map reference so React state setters always trigger re-renders,
|
|
406
|
+
// regardless of whether the caller wraps the callback or passes a raw setState directly.
|
|
407
|
+
notifyChange = function notifyChange(m) {
|
|
408
|
+
var _props_onFileMapChange;
|
|
409
|
+
return (_props_onFileMapChange = props.onFileMapChange) === null || _props_onFileMapChange === void 0 ? void 0 : _props_onFileMapChange.call(props, new Map(m));
|
|
410
|
+
};
|
|
366
411
|
hideLoading = function hideLoading() {};
|
|
367
412
|
fileList = Array.from(files);
|
|
368
413
|
fileList.forEach(prepareFile);
|
|
369
414
|
totalCount = fileList.length + existingFileCount;
|
|
370
415
|
isMaxExceeded = typeof props.maxFileCount === 'number' && totalCount > props.maxFileCount;
|
|
371
416
|
isMinNotMet = typeof props.minFileCount === 'number' && totalCount < props.minFileCount;
|
|
417
|
+
// Wrap all internal change notifications to use notifyChange so every update
|
|
418
|
+
// produces a new Map reference that React's state setter will always accept.
|
|
419
|
+
propsWithNotify = _object_spread_props(_object_spread({}, props), {
|
|
420
|
+
onFileMapChange: notifyChange
|
|
421
|
+
});
|
|
372
422
|
if (isMaxExceeded || isMinNotMet) {
|
|
373
423
|
hideLoading();
|
|
374
424
|
if (isMaxExceeded) {
|
|
@@ -382,7 +432,7 @@ var processFile = function processFile(file, index, map, props) {
|
|
|
382
432
|
file.errorMessage = errorMessage;
|
|
383
433
|
if (file.uuid) map.set(file.uuid, file);
|
|
384
434
|
});
|
|
385
|
-
(
|
|
435
|
+
notifyChange(map);
|
|
386
436
|
(_props_onExceedMaxCount = props.onExceedMaxCount) === null || _props_onExceedMaxCount === void 0 ? void 0 : _props_onExceedMaxCount.call(props, {
|
|
387
437
|
maxCount: maxCount,
|
|
388
438
|
currentCount: existingFileCount,
|
|
@@ -395,7 +445,7 @@ var processFile = function processFile(file, index, map, props) {
|
|
|
395
445
|
}
|
|
396
446
|
// 验证通过后再添加到 fileMap
|
|
397
447
|
fileList.forEach(function(file) {
|
|
398
|
-
return updateFileMap(map, file,
|
|
448
|
+
return updateFileMap(map, file, notifyChange);
|
|
399
449
|
});
|
|
400
450
|
_state.label = 1;
|
|
401
451
|
case 1:
|
|
@@ -414,7 +464,7 @@ var processFile = function processFile(file, index, map, props) {
|
|
|
414
464
|
];
|
|
415
465
|
return [
|
|
416
466
|
4,
|
|
417
|
-
processFile(fileList[i], i, map,
|
|
467
|
+
processFile(fileList[i], i, map, propsWithNotify)
|
|
418
468
|
];
|
|
419
469
|
case 3:
|
|
420
470
|
_state.sent();
|
|
@@ -434,7 +484,7 @@ var processFile = function processFile(file, index, map, props) {
|
|
|
434
484
|
error = _state.sent();
|
|
435
485
|
fileList.forEach(function(file) {
|
|
436
486
|
file.status = 'error';
|
|
437
|
-
updateFileMap(map, file,
|
|
487
|
+
updateFileMap(map, file, notifyChange);
|
|
438
488
|
});
|
|
439
489
|
return [
|
|
440
490
|
3,
|
|
@@ -438,6 +438,31 @@ declare class ChartErrorBoundary extends React.Component<ChartErrorBoundaryProps
|
|
|
438
438
|
'jinja.template.filter.description': string;
|
|
439
439
|
'jinja.template.setVariable.title': string;
|
|
440
440
|
'jinja.template.setVariable.description': string;
|
|
441
|
+
'schemaForm.invalidFormat': string;
|
|
442
|
+
'schemaForm.mustBeNumber': string;
|
|
443
|
+
'schemaForm.minValue': string;
|
|
444
|
+
'schemaForm.maxValue': string;
|
|
445
|
+
'schemaForm.minItems': string;
|
|
446
|
+
'schemaForm.maxItems': string;
|
|
447
|
+
'schemaForm.addItem': string;
|
|
448
|
+
'schemaForm.deleteItem': string;
|
|
449
|
+
'fileType.plainText': string;
|
|
450
|
+
'fileType.image': string;
|
|
451
|
+
'fileType.video': string;
|
|
452
|
+
'fileType.audio': string;
|
|
453
|
+
'fileType.pdf': string;
|
|
454
|
+
'fileType.word': string;
|
|
455
|
+
'fileType.excel': string;
|
|
456
|
+
'fileType.csv': string;
|
|
457
|
+
'fileType.archive': string;
|
|
458
|
+
'fileType.shell': string;
|
|
459
|
+
'fileType.config': string;
|
|
460
|
+
'fileType.powerpoint': string;
|
|
461
|
+
'workspace.file.unsupportedPreview': string;
|
|
462
|
+
'workspace.file.downloadButton': string;
|
|
463
|
+
'workspace.file.videoNotSupported': string;
|
|
464
|
+
'workspace.file.audioNotSupported': string;
|
|
465
|
+
'workspace.file.fileType': string;
|
|
441
466
|
};
|
|
442
467
|
language: "zh-CN" | "en-US";
|
|
443
468
|
setLanguage?: ((language: "zh-CN" | "en-US") => void) | undefined;
|
|
@@ -836,6 +861,31 @@ declare class ChartErrorBoundary extends React.Component<ChartErrorBoundaryProps
|
|
|
836
861
|
'jinja.template.filter.description': string;
|
|
837
862
|
'jinja.template.setVariable.title': string;
|
|
838
863
|
'jinja.template.setVariable.description': string;
|
|
864
|
+
'schemaForm.invalidFormat': string;
|
|
865
|
+
'schemaForm.mustBeNumber': string;
|
|
866
|
+
'schemaForm.minValue': string;
|
|
867
|
+
'schemaForm.maxValue': string;
|
|
868
|
+
'schemaForm.minItems': string;
|
|
869
|
+
'schemaForm.maxItems': string;
|
|
870
|
+
'schemaForm.addItem': string;
|
|
871
|
+
'schemaForm.deleteItem': string;
|
|
872
|
+
'fileType.plainText': string;
|
|
873
|
+
'fileType.image': string;
|
|
874
|
+
'fileType.video': string;
|
|
875
|
+
'fileType.audio': string;
|
|
876
|
+
'fileType.pdf': string;
|
|
877
|
+
'fileType.word': string;
|
|
878
|
+
'fileType.excel': string;
|
|
879
|
+
'fileType.csv': string;
|
|
880
|
+
'fileType.archive': string;
|
|
881
|
+
'fileType.shell': string;
|
|
882
|
+
'fileType.config': string;
|
|
883
|
+
'fileType.powerpoint': string;
|
|
884
|
+
'workspace.file.unsupportedPreview': string;
|
|
885
|
+
'workspace.file.downloadButton': string;
|
|
886
|
+
'workspace.file.videoNotSupported': string;
|
|
887
|
+
'workspace.file.audioNotSupported': string;
|
|
888
|
+
'workspace.file.fileType': string;
|
|
839
889
|
}) => void) | undefined;
|
|
840
890
|
}>;
|
|
841
891
|
context: React.ContextType<typeof I18nContext>;
|
|
@@ -158,7 +158,7 @@ import { LoadImage } from "./LoadImage";
|
|
|
158
158
|
width: '1em'
|
|
159
159
|
},
|
|
160
160
|
src: langIconMap.get(((_element_language1 = element.language) === null || _element_language1 === void 0 ? void 0 : _element_language1.toLowerCase()) || '')
|
|
161
|
-
})), /*#__PURE__*/ React.createElement("div", null, element.language
|
|
161
|
+
})), /*#__PURE__*/ React.createElement("div", null, element.language && element.language !== 'plain text' && /*#__PURE__*/ React.createElement("span", null, element.katex ? 'Formula' : element.language === 'html' && element.render ? 'Html Renderer' : element.language))) : // 非只读模式:显示语言选择器
|
|
162
162
|
/*#__PURE__*/ React.createElement(LanguageSelector, languageSelectorProps)), /*#__PURE__*/ React.createElement("div", {
|
|
163
163
|
style: {
|
|
164
164
|
display: 'flex',
|
|
@@ -101,7 +101,7 @@ import { Plus } from "@sofa-design/icons";
|
|
|
101
101
|
import { Button, Card, Form, Input, InputNumber, Select, Space } from "antd";
|
|
102
102
|
import { merge } from "lodash-es";
|
|
103
103
|
import React, { memo, useCallback, useContext, useEffect, useMemo } from "react";
|
|
104
|
-
import { I18nContext } from "../../I18n";
|
|
104
|
+
import { I18nContext, compileTemplate } from "../../I18n";
|
|
105
105
|
/**
|
|
106
106
|
* SchemaForm 组件 - 基于Schema的表单组件
|
|
107
107
|
*
|
|
@@ -169,26 +169,30 @@ import { I18nContext } from "../../I18n";
|
|
|
169
169
|
if (property.type === 'string' && property.pattern) {
|
|
170
170
|
rules.push({
|
|
171
171
|
pattern: new RegExp(property.pattern),
|
|
172
|
-
message: property.patternMessage || "".concat(property.title || property.description || ''
|
|
172
|
+
message: property.patternMessage || "".concat(property.title || property.description || '').concat((locale === null || locale === void 0 ? void 0 : locale['schemaForm.invalidFormat']) || '格式不正确')
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
if (property.type === 'number') {
|
|
176
176
|
rules.push({
|
|
177
177
|
type: 'number',
|
|
178
|
-
message: "".concat(property.title || property.description || ''
|
|
178
|
+
message: "".concat(property.title || property.description || '').concat((locale === null || locale === void 0 ? void 0 : locale['schemaForm.mustBeNumber']) || '必须是数字')
|
|
179
179
|
});
|
|
180
180
|
if (typeof property.minimum === 'number') {
|
|
181
181
|
rules.push({
|
|
182
182
|
type: 'number',
|
|
183
183
|
min: property.minimum,
|
|
184
|
-
message: "".concat(property.title || property.description || ''
|
|
184
|
+
message: "".concat(property.title || property.description || '').concat(compileTemplate((locale === null || locale === void 0 ? void 0 : locale['schemaForm.minValue']) || '不能小于 ${min}', {
|
|
185
|
+
min: String(property.minimum)
|
|
186
|
+
}))
|
|
185
187
|
});
|
|
186
188
|
}
|
|
187
189
|
if (typeof property.maximum === 'number') {
|
|
188
190
|
rules.push({
|
|
189
191
|
type: 'number',
|
|
190
192
|
max: property.maximum,
|
|
191
|
-
message: "".concat(property.title || property.description || ''
|
|
193
|
+
message: "".concat(property.title || property.description || '').concat(compileTemplate((locale === null || locale === void 0 ? void 0 : locale['schemaForm.maxValue']) || '不能大于 ${max}', {
|
|
194
|
+
max: String(property.maximum)
|
|
195
|
+
}))
|
|
192
196
|
});
|
|
193
197
|
}
|
|
194
198
|
}
|
|
@@ -197,14 +201,18 @@ import { I18nContext } from "../../I18n";
|
|
|
197
201
|
rules.push({
|
|
198
202
|
type: 'array',
|
|
199
203
|
min: property.minItems,
|
|
200
|
-
message: "".concat(property.title || property.description || ''
|
|
204
|
+
message: "".concat(property.title || property.description || '').concat(compileTemplate((locale === null || locale === void 0 ? void 0 : locale['schemaForm.minItems']) || '至少需要 ${min} 项', {
|
|
205
|
+
min: String(property.minItems)
|
|
206
|
+
}))
|
|
201
207
|
});
|
|
202
208
|
}
|
|
203
209
|
if (typeof property.maxItems === 'number') {
|
|
204
210
|
rules.push({
|
|
205
211
|
type: 'array',
|
|
206
212
|
max: property.maxItems,
|
|
207
|
-
message: "".concat(property.title || property.description || ''
|
|
213
|
+
message: "".concat(property.title || property.description || '').concat(compileTemplate((locale === null || locale === void 0 ? void 0 : locale['schemaForm.maxItems']) || '最多只能有 ${max} 项', {
|
|
214
|
+
max: String(property.maxItems)
|
|
215
|
+
}))
|
|
208
216
|
});
|
|
209
217
|
}
|
|
210
218
|
}
|
|
@@ -344,12 +352,13 @@ import { I18nContext } from "../../I18n";
|
|
|
344
352
|
},
|
|
345
353
|
block: true,
|
|
346
354
|
icon: /*#__PURE__*/ React.createElement(Plus, null)
|
|
347
|
-
},
|
|
355
|
+
}, (locale === null || locale === void 0 ? void 0 : locale['schemaForm.addItem']) || '添加', " ", getPropertyTitle(property, key))));
|
|
348
356
|
});
|
|
349
357
|
}, [
|
|
350
358
|
readonly,
|
|
351
359
|
renderArrayItemContent,
|
|
352
|
-
getPropertyTitle
|
|
360
|
+
getPropertyTitle,
|
|
361
|
+
locale
|
|
353
362
|
]);
|
|
354
363
|
// 渲染对象表单项
|
|
355
364
|
var renderObjectFormItem = useCallback(function(key, property, baseName) {
|
|
@@ -284,8 +284,7 @@ import { PreviewCapability, dataSourceManager } from "./DataSourceStrategy";
|
|
|
284
284
|
FileCategory.Image,
|
|
285
285
|
FileCategory.Video,
|
|
286
286
|
FileCategory.Audio,
|
|
287
|
-
FileCategory.PDF
|
|
288
|
-
FileCategory.Archive
|
|
287
|
+
FileCategory.PDF
|
|
289
288
|
].includes(typeInference.category);
|
|
290
289
|
}
|
|
291
290
|
},
|
|
@@ -309,8 +308,6 @@ import { PreviewCapability, dataSourceManager } from "./DataSourceStrategy";
|
|
|
309
308
|
return 'inline';
|
|
310
309
|
case FileCategory.PDF:
|
|
311
310
|
return 'inline';
|
|
312
|
-
case FileCategory.Archive:
|
|
313
|
-
return 'modal';
|
|
314
311
|
default:
|
|
315
312
|
return 'external';
|
|
316
313
|
}
|
|
@@ -209,7 +209,7 @@ var PlaceholderContent = function PlaceholderContent(param) {
|
|
|
209
209
|
}
|
|
210
210
|
return response.text();
|
|
211
211
|
}).then(setReadyContent).catch(function(err) {
|
|
212
|
-
var errorMessage = _instanceof(err, Error) ? err.message : '加载文本内容失败';
|
|
212
|
+
var errorMessage = _instanceof(err, Error) ? err.message : (locale === null || locale === void 0 ? void 0 : locale['common.loadTextFailed']) || '加载文本内容失败';
|
|
213
213
|
setContentState({
|
|
214
214
|
status: 'error',
|
|
215
215
|
error: errorMessage
|
|
@@ -326,13 +326,13 @@ var PlaceholderContent = function PlaceholderContent(param) {
|
|
|
326
326
|
className: classNames("".concat(filePrefixCls, "-item-time"), hashId)
|
|
327
327
|
}, formatLastModified(file.lastModified))))))), canDownload && onDownload && /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("div", {
|
|
328
328
|
className: classNames("".concat(prefixCls, "-unsupported-text"), hashId)
|
|
329
|
-
},
|
|
329
|
+
}, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.unsupportedPreview']) || '此文件无法预览,请下载查看。'), /*#__PURE__*/ React.createElement(Button, {
|
|
330
330
|
color: "default",
|
|
331
331
|
variant: "solid",
|
|
332
332
|
icon: /*#__PURE__*/ React.createElement(DownloadIcon, null),
|
|
333
333
|
onClick: handleDownload,
|
|
334
334
|
"aria-label": (locale === null || locale === void 0 ? void 0 : locale['workspace.file.download']) || '下载'
|
|
335
|
-
},
|
|
335
|
+
}, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.downloadButton']) || '下载'))));
|
|
336
336
|
}
|
|
337
337
|
var renderTextOrCode = function renderTextOrCode() {
|
|
338
338
|
if (isCurrentFileHtml) {
|
|
@@ -402,14 +402,14 @@ var PlaceholderContent = function PlaceholderContent(param) {
|
|
|
402
402
|
preload: "metadata"
|
|
403
403
|
}, /*#__PURE__*/ React.createElement("track", {
|
|
404
404
|
kind: "captions"
|
|
405
|
-
}),
|
|
405
|
+
}), (locale === null || locale === void 0 ? void 0 : locale['workspace.file.videoNotSupported']) || '您的浏览器不支持视频播放'),
|
|
406
406
|
audio: /*#__PURE__*/ React.createElement("audio", {
|
|
407
407
|
className: classNames("".concat(prefixCls, "-audio"), hashId),
|
|
408
408
|
src: dataSource.previewUrl,
|
|
409
409
|
controls: true,
|
|
410
410
|
controlsList: "nodownload",
|
|
411
411
|
preload: "metadata"
|
|
412
|
-
},
|
|
412
|
+
}, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.audioNotSupported']) || '您的浏览器不支持音频播放'),
|
|
413
413
|
pdf: /*#__PURE__*/ React.createElement("embed", {
|
|
414
414
|
className: classNames("".concat(prefixCls, "-pdf"), hashId),
|
|
415
415
|
src: dataSource.previewUrl,
|
|
@@ -437,7 +437,7 @@ var PlaceholderContent = function PlaceholderContent(param) {
|
|
|
437
437
|
locale: locale,
|
|
438
438
|
prefixCls: prefixCls,
|
|
439
439
|
hashId: hashId
|
|
440
|
-
}, /*#__PURE__*/ React.createElement("p", null, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.unknownFileType']) || '未知的文件类型'), /*#__PURE__*/ React.createElement("p", null,
|
|
440
|
+
}, /*#__PURE__*/ React.createElement("p", null, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.unknownFileType']) || '未知的文件类型'), /*#__PURE__*/ React.createElement("p", null, (locale === null || locale === void 0 ? void 0 : locale['workspace.file.fileType']) || '文件类型:', typeInference.fileType));
|
|
441
441
|
}
|
|
442
442
|
};
|
|
443
443
|
return wrapSSR(/*#__PURE__*/ React.createElement("div", {
|
|
@@ -3,3 +3,4 @@ export { PreviewComponent } from './PreviewComponent';
|
|
|
3
3
|
export type { PreviewComponentProps } from './PreviewComponent';
|
|
4
4
|
export type { FileActionRef, FileBuiltinActions, FileNode, FileProps, FileRenderContext, FileType, GroupNode, } from '../types';
|
|
5
5
|
export { getFileTypeIcon, getGroupIcon } from './utils';
|
|
6
|
+
export { getFileTypeName } from '../types';
|
|
@@ -57,7 +57,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
57
57
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
58
58
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
59
59
|
}
|
|
60
|
-
import { FileOther as DefaultFileIcon, FileAudio, FileCsv, FileDoc, FileFolders, FileMarkdown, FileOther, FilePdf, FilePic, FileVideo, FileXlsx, FileXml, FileZip } from "@sofa-design/icons";
|
|
60
|
+
import { FileOther as DefaultFileIcon, FileAudio, FileCsv, FileDoc, FileFolders, FileMarkdown, FileOther, FilePdf, FilePic, FilePpt, FileVideo, FileXlsx, FileXml, FileZip } from "@sofa-design/icons";
|
|
61
61
|
import React from "react";
|
|
62
62
|
import { FILE_TYPES, FileCategory, getFileCategory } from "../types";
|
|
63
63
|
// 文件扩展名到图标的映射
|
|
@@ -73,6 +73,8 @@ var EXTENSION_ICON_MAP = {
|
|
|
73
73
|
html: /*#__PURE__*/ React.createElement(FileXml, null),
|
|
74
74
|
md: /*#__PURE__*/ React.createElement(FileMarkdown, null),
|
|
75
75
|
markdown: /*#__PURE__*/ React.createElement(FileMarkdown, null),
|
|
76
|
+
ppt: /*#__PURE__*/ React.createElement(FilePpt, null),
|
|
77
|
+
pptx: /*#__PURE__*/ React.createElement(FilePpt, null),
|
|
76
78
|
zip: /*#__PURE__*/ React.createElement(FileZip, null),
|
|
77
79
|
rar: /*#__PURE__*/ React.createElement(FileZip, null),
|
|
78
80
|
'7z': /*#__PURE__*/ React.createElement(FileZip, null),
|
|
@@ -82,7 +84,7 @@ var EXTENSION_ICON_MAP = {
|
|
|
82
84
|
};
|
|
83
85
|
var _obj;
|
|
84
86
|
// 文件类型到默认图标的映射
|
|
85
|
-
var TYPE_ICON_MAP = (_obj = {}, _define_property(_obj, FileCategory.Text, /*#__PURE__*/ React.createElement(FileMarkdown, null)), _define_property(_obj, FileCategory.Code, /*#__PURE__*/ React.createElement(FileXml, null)), _define_property(_obj, FileCategory.PDF, /*#__PURE__*/ React.createElement(FilePdf, null)), _define_property(_obj, FileCategory.Word, /*#__PURE__*/ React.createElement(FileDoc, null)), _define_property(_obj, FileCategory.Excel, /*#__PURE__*/ React.createElement(FileXlsx, null)), _define_property(_obj, FileCategory.Image, /*#__PURE__*/ React.createElement(FilePic, null)), _define_property(_obj, FileCategory.Video, /*#__PURE__*/ React.createElement(FileVideo, null)), _define_property(_obj, FileCategory.Audio, /*#__PURE__*/ React.createElement(FileAudio, null)), _define_property(_obj, FileCategory.Archive, /*#__PURE__*/ React.createElement(FileZip, null)), _define_property(_obj, FileCategory.Other, /*#__PURE__*/ React.createElement(FileOther, null)), _obj);
|
|
87
|
+
var TYPE_ICON_MAP = (_obj = {}, _define_property(_obj, FileCategory.Text, /*#__PURE__*/ React.createElement(FileMarkdown, null)), _define_property(_obj, FileCategory.Code, /*#__PURE__*/ React.createElement(FileXml, null)), _define_property(_obj, FileCategory.PDF, /*#__PURE__*/ React.createElement(FilePdf, null)), _define_property(_obj, FileCategory.Word, /*#__PURE__*/ React.createElement(FileDoc, null)), _define_property(_obj, FileCategory.Excel, /*#__PURE__*/ React.createElement(FileXlsx, null)), _define_property(_obj, FileCategory.Presentation, /*#__PURE__*/ React.createElement(FilePpt, null)), _define_property(_obj, FileCategory.Image, /*#__PURE__*/ React.createElement(FilePic, null)), _define_property(_obj, FileCategory.Video, /*#__PURE__*/ React.createElement(FileVideo, null)), _define_property(_obj, FileCategory.Audio, /*#__PURE__*/ React.createElement(FileAudio, null)), _define_property(_obj, FileCategory.Archive, /*#__PURE__*/ React.createElement(FileZip, null)), _define_property(_obj, FileCategory.Other, /*#__PURE__*/ React.createElement(FileOther, null)), _obj);
|
|
86
88
|
/**
|
|
87
89
|
* 获取文件类型图标
|
|
88
90
|
*/ export var getFileTypeIcon = function getFileTypeIcon(type, customIcon, fileName) {
|
|
@@ -53,6 +53,7 @@ export declare enum FileCategory {
|
|
|
53
53
|
PDF = "pdf",
|
|
54
54
|
Word = "word",
|
|
55
55
|
Excel = "excel",
|
|
56
|
+
Presentation = "presentation",
|
|
56
57
|
Archive = "archive",
|
|
57
58
|
Other = "other"
|
|
58
59
|
}
|
|
@@ -60,7 +61,8 @@ export interface FileTypeDefinition {
|
|
|
60
61
|
category: FileCategory;
|
|
61
62
|
extensions: string[];
|
|
62
63
|
mimeTypes: string[];
|
|
63
|
-
name
|
|
64
|
+
/** Locale key for the file type display name (e.g. 'fileType.plainText') */
|
|
65
|
+
nameKey: string;
|
|
64
66
|
}
|
|
65
67
|
export declare const FILE_TYPES: Record<string, FileTypeDefinition>;
|
|
66
68
|
export type FileType = keyof typeof FILE_TYPES;
|
|
@@ -238,3 +240,8 @@ export interface CustomProps extends BaseChildProps {
|
|
|
238
240
|
export declare const getFileType: (filename: string) => FileType;
|
|
239
241
|
export declare const getMimeType: (fileType: FileType) => string;
|
|
240
242
|
export declare const getFileCategory: (fileType: FileType) => FileCategory;
|
|
243
|
+
/**
|
|
244
|
+
* Get the localized display name for a file type.
|
|
245
|
+
* Falls back to the nameKey itself when no locale is provided.
|
|
246
|
+
*/
|
|
247
|
+
export declare const getFileTypeName: (fileType: FileType, locale?: Record<string, string>) => string;
|
package/dist/Workspace/types.js
CHANGED
|
@@ -44,7 +44,6 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
44
44
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
45
45
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
46
46
|
}
|
|
47
|
-
// ... (rest of the file content unchanged)
|
|
48
47
|
// 文件类型分类
|
|
49
48
|
export var FileCategory = /*#__PURE__*/ function(FileCategory) {
|
|
50
49
|
FileCategory["Text"] = "text";
|
|
@@ -55,6 +54,7 @@ export var FileCategory = /*#__PURE__*/ function(FileCategory) {
|
|
|
55
54
|
FileCategory["PDF"] = "pdf";
|
|
56
55
|
FileCategory["Word"] = "word";
|
|
57
56
|
FileCategory["Excel"] = "excel";
|
|
57
|
+
FileCategory["Presentation"] = "presentation";
|
|
58
58
|
FileCategory["Archive"] = "archive";
|
|
59
59
|
FileCategory["Other"] = "other";
|
|
60
60
|
return FileCategory;
|
|
@@ -69,7 +69,7 @@ export var FILE_TYPES = {
|
|
|
69
69
|
mimeTypes: [
|
|
70
70
|
'text/plain'
|
|
71
71
|
],
|
|
72
|
-
|
|
72
|
+
nameKey: 'fileType.plainText'
|
|
73
73
|
},
|
|
74
74
|
markdown: {
|
|
75
75
|
category: "text",
|
|
@@ -80,7 +80,7 @@ export var FILE_TYPES = {
|
|
|
80
80
|
mimeTypes: [
|
|
81
81
|
'text/markdown'
|
|
82
82
|
],
|
|
83
|
-
|
|
83
|
+
nameKey: 'markdown'
|
|
84
84
|
},
|
|
85
85
|
image: {
|
|
86
86
|
category: "image",
|
|
@@ -101,21 +101,33 @@ export var FILE_TYPES = {
|
|
|
101
101
|
'image/webp',
|
|
102
102
|
'image/svg+xml'
|
|
103
103
|
],
|
|
104
|
-
|
|
104
|
+
nameKey: 'fileType.image'
|
|
105
105
|
},
|
|
106
106
|
video: {
|
|
107
107
|
category: "video",
|
|
108
108
|
extensions: [
|
|
109
109
|
'mp4',
|
|
110
110
|
'webm',
|
|
111
|
-
'
|
|
111
|
+
'ogv',
|
|
112
|
+
'mov',
|
|
113
|
+
'avi',
|
|
114
|
+
'mkv',
|
|
115
|
+
'flv',
|
|
116
|
+
'3gp',
|
|
117
|
+
'm4v'
|
|
112
118
|
],
|
|
113
119
|
mimeTypes: [
|
|
114
120
|
'video/mp4',
|
|
115
121
|
'video/webm',
|
|
116
|
-
'video/ogg'
|
|
117
|
-
|
|
118
|
-
|
|
122
|
+
'video/ogg',
|
|
123
|
+
'video/quicktime',
|
|
124
|
+
'video/x-msvideo',
|
|
125
|
+
'video/x-matroska',
|
|
126
|
+
'video/x-flv',
|
|
127
|
+
'video/3gpp',
|
|
128
|
+
'video/x-m4v'
|
|
129
|
+
],
|
|
130
|
+
nameKey: 'fileType.video'
|
|
119
131
|
},
|
|
120
132
|
audio: {
|
|
121
133
|
category: "audio",
|
|
@@ -124,16 +136,22 @@ export var FILE_TYPES = {
|
|
|
124
136
|
'wav',
|
|
125
137
|
'ogg',
|
|
126
138
|
'aac',
|
|
127
|
-
'm4a'
|
|
139
|
+
'm4a',
|
|
140
|
+
'flac',
|
|
141
|
+
'wma',
|
|
142
|
+
'opus'
|
|
128
143
|
],
|
|
129
144
|
mimeTypes: [
|
|
130
145
|
'audio/mpeg',
|
|
131
146
|
'audio/wav',
|
|
132
147
|
'audio/ogg',
|
|
133
148
|
'audio/aac',
|
|
134
|
-
'audio/mp4'
|
|
149
|
+
'audio/mp4',
|
|
150
|
+
'audio/flac',
|
|
151
|
+
'audio/x-ms-wma',
|
|
152
|
+
'audio/opus'
|
|
135
153
|
],
|
|
136
|
-
|
|
154
|
+
nameKey: 'fileType.audio'
|
|
137
155
|
},
|
|
138
156
|
pdf: {
|
|
139
157
|
category: "pdf",
|
|
@@ -143,7 +161,7 @@ export var FILE_TYPES = {
|
|
|
143
161
|
mimeTypes: [
|
|
144
162
|
'application/pdf'
|
|
145
163
|
],
|
|
146
|
-
|
|
164
|
+
nameKey: 'fileType.pdf'
|
|
147
165
|
},
|
|
148
166
|
word: {
|
|
149
167
|
category: "word",
|
|
@@ -155,7 +173,7 @@ export var FILE_TYPES = {
|
|
|
155
173
|
'application/msword',
|
|
156
174
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
|
|
157
175
|
],
|
|
158
|
-
|
|
176
|
+
nameKey: 'fileType.word'
|
|
159
177
|
},
|
|
160
178
|
excel: {
|
|
161
179
|
category: "excel",
|
|
@@ -167,7 +185,7 @@ export var FILE_TYPES = {
|
|
|
167
185
|
'application/vnd.ms-excel',
|
|
168
186
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
169
187
|
],
|
|
170
|
-
|
|
188
|
+
nameKey: 'fileType.excel'
|
|
171
189
|
},
|
|
172
190
|
csv: {
|
|
173
191
|
category: "excel",
|
|
@@ -179,7 +197,19 @@ export var FILE_TYPES = {
|
|
|
179
197
|
'application/csv',
|
|
180
198
|
'application/vnd.ms-excel'
|
|
181
199
|
],
|
|
182
|
-
|
|
200
|
+
nameKey: 'fileType.csv'
|
|
201
|
+
},
|
|
202
|
+
powerpoint: {
|
|
203
|
+
category: "presentation",
|
|
204
|
+
extensions: [
|
|
205
|
+
'ppt',
|
|
206
|
+
'pptx'
|
|
207
|
+
],
|
|
208
|
+
mimeTypes: [
|
|
209
|
+
'application/vnd.ms-powerpoint',
|
|
210
|
+
'application/vnd.openxmlformats-officedocument.presentationml.presentation'
|
|
211
|
+
],
|
|
212
|
+
nameKey: 'fileType.powerpoint'
|
|
183
213
|
},
|
|
184
214
|
archive: {
|
|
185
215
|
category: "archive",
|
|
@@ -199,7 +229,7 @@ export var FILE_TYPES = {
|
|
|
199
229
|
'application/gzip',
|
|
200
230
|
'application/x-bzip2'
|
|
201
231
|
],
|
|
202
|
-
|
|
232
|
+
nameKey: 'fileType.archive'
|
|
203
233
|
},
|
|
204
234
|
// 代码文件类型
|
|
205
235
|
javascript: {
|
|
@@ -213,7 +243,7 @@ export var FILE_TYPES = {
|
|
|
213
243
|
'text/javascript',
|
|
214
244
|
'application/javascript'
|
|
215
245
|
],
|
|
216
|
-
|
|
246
|
+
nameKey: 'javascript'
|
|
217
247
|
},
|
|
218
248
|
typescript: {
|
|
219
249
|
category: "code",
|
|
@@ -224,7 +254,7 @@ export var FILE_TYPES = {
|
|
|
224
254
|
'text/typescript',
|
|
225
255
|
'application/typescript'
|
|
226
256
|
],
|
|
227
|
-
|
|
257
|
+
nameKey: 'typescript'
|
|
228
258
|
},
|
|
229
259
|
react: {
|
|
230
260
|
category: "code",
|
|
@@ -236,7 +266,7 @@ export var FILE_TYPES = {
|
|
|
236
266
|
'text/jsx',
|
|
237
267
|
'text/tsx'
|
|
238
268
|
],
|
|
239
|
-
|
|
269
|
+
nameKey: 'react'
|
|
240
270
|
},
|
|
241
271
|
python: {
|
|
242
272
|
category: "code",
|
|
@@ -249,7 +279,7 @@ export var FILE_TYPES = {
|
|
|
249
279
|
'text/x-python',
|
|
250
280
|
'application/x-python-code'
|
|
251
281
|
],
|
|
252
|
-
|
|
282
|
+
nameKey: 'python'
|
|
253
283
|
},
|
|
254
284
|
java: {
|
|
255
285
|
category: "code",
|
|
@@ -259,7 +289,7 @@ export var FILE_TYPES = {
|
|
|
259
289
|
mimeTypes: [
|
|
260
290
|
'text/x-java-source'
|
|
261
291
|
],
|
|
262
|
-
|
|
292
|
+
nameKey: 'java'
|
|
263
293
|
},
|
|
264
294
|
cpp: {
|
|
265
295
|
category: "code",
|
|
@@ -276,7 +306,7 @@ export var FILE_TYPES = {
|
|
|
276
306
|
'text/x-c++src',
|
|
277
307
|
'text/x-c++hdr'
|
|
278
308
|
],
|
|
279
|
-
|
|
309
|
+
nameKey: 'c++'
|
|
280
310
|
},
|
|
281
311
|
c: {
|
|
282
312
|
category: "code",
|
|
@@ -288,7 +318,7 @@ export var FILE_TYPES = {
|
|
|
288
318
|
'text/x-csrc',
|
|
289
319
|
'text/x-chdr'
|
|
290
320
|
],
|
|
291
|
-
|
|
321
|
+
nameKey: 'c'
|
|
292
322
|
},
|
|
293
323
|
csharp: {
|
|
294
324
|
category: "code",
|
|
@@ -298,7 +328,7 @@ export var FILE_TYPES = {
|
|
|
298
328
|
mimeTypes: [
|
|
299
329
|
'text/x-csharp'
|
|
300
330
|
],
|
|
301
|
-
|
|
331
|
+
nameKey: 'c#'
|
|
302
332
|
},
|
|
303
333
|
go: {
|
|
304
334
|
category: "code",
|
|
@@ -308,7 +338,7 @@ export var FILE_TYPES = {
|
|
|
308
338
|
mimeTypes: [
|
|
309
339
|
'text/x-go'
|
|
310
340
|
],
|
|
311
|
-
|
|
341
|
+
nameKey: 'go'
|
|
312
342
|
},
|
|
313
343
|
rust: {
|
|
314
344
|
category: "code",
|
|
@@ -318,7 +348,7 @@ export var FILE_TYPES = {
|
|
|
318
348
|
mimeTypes: [
|
|
319
349
|
'text/x-rust'
|
|
320
350
|
],
|
|
321
|
-
|
|
351
|
+
nameKey: 'rust'
|
|
322
352
|
},
|
|
323
353
|
php: {
|
|
324
354
|
category: "code",
|
|
@@ -333,7 +363,7 @@ export var FILE_TYPES = {
|
|
|
333
363
|
'text/x-php',
|
|
334
364
|
'application/x-httpd-php'
|
|
335
365
|
],
|
|
336
|
-
|
|
366
|
+
nameKey: 'php'
|
|
337
367
|
},
|
|
338
368
|
ruby: {
|
|
339
369
|
category: "code",
|
|
@@ -344,7 +374,7 @@ export var FILE_TYPES = {
|
|
|
344
374
|
mimeTypes: [
|
|
345
375
|
'text/x-ruby'
|
|
346
376
|
],
|
|
347
|
-
|
|
377
|
+
nameKey: 'ruby'
|
|
348
378
|
},
|
|
349
379
|
shell: {
|
|
350
380
|
category: "code",
|
|
@@ -358,7 +388,7 @@ export var FILE_TYPES = {
|
|
|
358
388
|
'text/x-shellscript',
|
|
359
389
|
'application/x-sh'
|
|
360
390
|
],
|
|
361
|
-
|
|
391
|
+
nameKey: 'fileType.shell'
|
|
362
392
|
},
|
|
363
393
|
powershell: {
|
|
364
394
|
category: "code",
|
|
@@ -370,7 +400,7 @@ export var FILE_TYPES = {
|
|
|
370
400
|
mimeTypes: [
|
|
371
401
|
'text/x-powershell'
|
|
372
402
|
],
|
|
373
|
-
|
|
403
|
+
nameKey: 'powershell'
|
|
374
404
|
},
|
|
375
405
|
sql: {
|
|
376
406
|
category: "code",
|
|
@@ -381,7 +411,7 @@ export var FILE_TYPES = {
|
|
|
381
411
|
'text/x-sql',
|
|
382
412
|
'application/sql'
|
|
383
413
|
],
|
|
384
|
-
|
|
414
|
+
nameKey: 'sql'
|
|
385
415
|
},
|
|
386
416
|
lua: {
|
|
387
417
|
category: "code",
|
|
@@ -391,7 +421,7 @@ export var FILE_TYPES = {
|
|
|
391
421
|
mimeTypes: [
|
|
392
422
|
'text/x-lua'
|
|
393
423
|
],
|
|
394
|
-
|
|
424
|
+
nameKey: 'lua'
|
|
395
425
|
},
|
|
396
426
|
perl: {
|
|
397
427
|
category: "code",
|
|
@@ -403,7 +433,7 @@ export var FILE_TYPES = {
|
|
|
403
433
|
mimeTypes: [
|
|
404
434
|
'text/x-perl'
|
|
405
435
|
],
|
|
406
|
-
|
|
436
|
+
nameKey: 'perl'
|
|
407
437
|
},
|
|
408
438
|
scala: {
|
|
409
439
|
category: "code",
|
|
@@ -414,7 +444,7 @@ export var FILE_TYPES = {
|
|
|
414
444
|
mimeTypes: [
|
|
415
445
|
'text/x-scala'
|
|
416
446
|
],
|
|
417
|
-
|
|
447
|
+
nameKey: 'scala'
|
|
418
448
|
},
|
|
419
449
|
config: {
|
|
420
450
|
category: "code",
|
|
@@ -436,7 +466,7 @@ export var FILE_TYPES = {
|
|
|
436
466
|
'text/plain',
|
|
437
467
|
'application/x-wine-extension-ini'
|
|
438
468
|
],
|
|
439
|
-
|
|
469
|
+
nameKey: 'fileType.config'
|
|
440
470
|
}
|
|
441
471
|
};
|
|
442
472
|
// 工具函数
|
|
@@ -474,3 +504,12 @@ export var getFileCategory = function getFileCategory(fileType) {
|
|
|
474
504
|
var _FILE_TYPES_fileType;
|
|
475
505
|
return FILE_TYPES === null || FILE_TYPES === void 0 ? void 0 : (_FILE_TYPES_fileType = FILE_TYPES[fileType]) === null || _FILE_TYPES_fileType === void 0 ? void 0 : _FILE_TYPES_fileType.category;
|
|
476
506
|
};
|
|
507
|
+
/**
|
|
508
|
+
* Get the localized display name for a file type.
|
|
509
|
+
* Falls back to the nameKey itself when no locale is provided.
|
|
510
|
+
*/ export var getFileTypeName = function getFileTypeName(fileType, locale) {
|
|
511
|
+
var _ref;
|
|
512
|
+
var definition = FILE_TYPES[fileType];
|
|
513
|
+
if (!definition) return fileType;
|
|
514
|
+
return (_ref = locale === null || locale === void 0 ? void 0 : locale[definition.nameKey]) !== null && _ref !== void 0 ? _ref : definition.nameKey;
|
|
515
|
+
};
|