在线ide离线开发功能实现
# 目录树自定义
目的就是屏蔽真是物理路径;
实现方案:在文件系统中,获取到文件或者文件夹时,做过服务器中目录和文件筛选;在显示单个目录时,过滤文件目录替换;
# 筛选目录和文件
async resolveChildren(tree: IFileTreeService, path: string | FileStat, parent?: Directory, compact?: boolean) {
let file: FileStat | undefined;
if (!this.userhomePath) {
const userhome = await this.fileServiceClient.getCurrentUserHome();
if (userhome) {
this.userhomePath = new URI(userhome.uri);
}
}
if (typeof path === 'string') {
file = await this.fileServiceClient.getFileStat(path);
} else {
file = await this.fileServiceClient.getFileStat(path.uri);
}
if (file) {
if (file.children?.length === 1 && file.children[0].isDirectory && compact) {
const parentURI = new URI(file.children[0].uri);
if (!!parent && parent.parent) {
const parentName = (parent.parent as Directory).uri.relative(parentURI)?.toString();
if (parentName && parentName !== parent.name) {
parent.updateMetaData({
name: parentName,
uri: parentURI,
fileStat: file.children[0],
tooltip: this.getReadableTooltip(parentURI),
});
}
}
return await this.resolveChildren(tree, file.children[0].uri, parent, compact);
} else {
// 为文件树节点新增isInSymbolicDirectory属性,用于探测节点是否处于软链接文件中
const filestat = {
...file,
isInSymbolicDirectory: parent?.filestat.isSymbolicLink || parent?.filestat.isInSymbolicDirectory,
};
const cateList = tree.getCateList && tree.getCateList()
const scriptList = tree.getScriptList && tree.getScriptList()
return {
children: this.toNodes(tree, filestat, parent,cateList, scriptList),
filestat,
};
}
} else {
return {
children: [],
filestat: null,
};
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# 替换目录名
主要这里还要处理多目录连着的问题;
const renderDisplayName = (node: Directory | File) => {
if (Template) {
return <Template />;
}
if (isPrompt && node instanceof PromptHandle) {
return (
<div className={cls(styles.file_tree_node_segment, styles.file_tree_node_inputbox)}>
<div className={cls('input-box', styles.file_tree_node_prompt_box)}>
<node.ProxiedInput wrapperStyle={{ height: FILE_TREE_NODE_HEIGHT, padding: '0 5px' }} />
</div>
</div>
);
}
if (isCompactName) {
const paths = node.displayName.split(Path.separator);
const nameBlock = paths.map((path, index) => {
const localPath = paths.slice(0, index + 1).join(Path.separator);
const clickHandler = (event: React.MouseEvent) => {
event.stopPropagation();
setActiveIndex(index);
const activeUri: URI = item.parent.uri.resolve(paths.slice(0, index + 1).join(Path.separator));
onClick(event, item as File, itemType, activeUri!);
};
const contextMenuHandler = (event: React.MouseEvent) => {
event.stopPropagation();
setActiveIndex(index);
const activeUri: URI = item.parent.uri.resolve(paths.slice(0, index + 1).join(Path.separator));
onContextMenu(event, item as File, itemType, activeUri!);
};
const dragOverHandler = (event: React.DragEvent) => {
event.stopPropagation();
event.preventDefault();
if (activeIndex !== index) {
setActiveIndex(index);
dndService.handleDragOver(event, item as File);
}
};
const dragLeaveHandler = (event: React.DragEvent) => {
event.stopPropagation();
event.preventDefault();
setActiveIndex(-1);
return;
};
const dragStartHandler = (event: React.DragEvent) => {
event.stopPropagation();
if (activeIndex !== index) {
setActiveIndex(index);
}
const activeUri: URI = item.parent.uri.resolve(paths.slice(0, index + 1).join(Path.separator));
dndService.handleDragStart(event, item as File, activeUri!);
};
const dropHandler = (event: React.DragEvent) => {
event.stopPropagation();
const activeUri: URI = item.parent.uri.resolve(paths.slice(0, index + 1).join(Path.separator));
dndService.handleDrop(event, item as File, activeUri!);
};
const pathClassName = cls(activeIndex === index && styles.active, styles.compact_name);
let pathName = path
const cateObj = cateList.find(item => item.cataCode === path)
if(cateObj && cateObj.cataName){
pathName = cateObj.cataName
}
return (
<span key={localPath}>
<a
className={pathClassName}
draggable={true}
onContextMenu={contextMenuHandler}
onDragStart={dragStartHandler}
onDragOver={dragOverHandler}
onDragLeave={dragLeaveHandler}
onDrop={dropHandler}
onClick={clickHandler}
>
{pathName}
</a>
{index !== paths.length - 1 ? (
<span className={styles.compact_name_separator}>{Path.separator}</span>
) : null}
</span>
);
});
return <div className={cls(styles.file_tree_node_segment, styles.file_tree_node_displayname)}>{nameBlock}</div>;
}
let pathName = node.displayName
const cateObj = cateList.find(item => item.cataCode === node.displayName)
if(cateObj && cateObj.cataName){
pathName = cateObj.cataName
}
{/* {labelService.getName(node.uri) || node.displayName} */}
return (
<div className={cls(styles.file_tree_node_segment, styles.file_tree_node_displayname)}>{pathName}</div>
);
};
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# 脚本文件CRUD
# 文件相关信息
# 菜单处理
Menu中的when不好控制,只好借助command中visable设置;
menuRegistry.registerMenuItem(MenuId.DataDevContext, {
command: {
id: BDP_FILE_COMMANDS.DELETE_FILE.id,
label: localize("file.delete"),
},
order: 3,
group: "2_operator",
// when: FilesExplorerFilteredContext.not,
});
commands.registerCommand<ExplorerContextCallback>(
BDP_FILE_COMMANDS.DELETE_FILE,
{
execute: async (_, uris) => {
// 检查多文件,并且检查是否有文件夹,做提醒;只能处理当个文件的
if (!uris) {
if (this.fileTreeModelService.focusedFile) {
this.willDeleteUris.push(
this.fileTreeModelService.focusedFile.uri
);
} else if (
this.fileTreeModelService.selectedFiles &&
this.fileTreeModelService.selectedFiles.length > 0
) {
this.willDeleteUris = this.willDeleteUris.concat(
this.fileTreeModelService.selectedFiles.map((file) => file.uri)
);
} else {
return;
}
} else {
this.willDeleteUris = this.willDeleteUris.concat(uris);
}
if (this.willDeleteUris.length>1) {
await this.dialogService.error(localize("file.onlyfilestips","只能选择一个文件操作"));
this.willDeleteUris = []
return
}
return this.deleteThrottler.queue<void>(this.doDelete.bind(this));
},
// 只有文件可以删除,而且只能单个文件
isVisible: () =>
!!this.fileTreeModelService.contextMenuFile &&
!this.fileTreeModelService.contextMenuFile.uri.isEqual(
(this.fileTreeModelService.treeModel.root as Directory).uri
) && this.fileTreeModelService.contextMenuFile.type===1,
}
);
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# 增加/自定义页面
modules/file-tree-next/browser/file-tree-data-dev.service.ts
// 提交接口也要合并到这里
createScript = async (obj) => {
let error;
try {
this._fileTreeDataDevModel.treeLoading = true;
const { isSuccess, data } = await createScript({ ...obj }).then((res) =>
hocResponse(res)
);
if (isSuccess && data) {
const newScriptObj = pick(data, [
"scriptPath",
"scriptId",
"scriptType",
"scriptName",
"statusCd",
"sysUserId",
"nodeId",
"projectId",
"scriptDirId",
]);
const { scriptPath, scriptName, scriptId } = newScriptObj;
const scriptList = this._fileTreeDataDevModel.scriptList;
const index = scriptList.findIndex((item) => item.scriptId === scriptId);
if (index === -1) {
scriptList.splice(scriptList.length, 0, newScriptObj);
} else {
scriptList.splice(index, 1, newScriptObj);
}
try {
// const uri = `file://${this.workspaceDir}/${scriptPath}/${scriptName}`;
const uri = path.join('file://', this.workspaceDir, scriptPath, scriptName)
const newUri = new URI(uri);
error = await this.fileTreeAPI.createFile(newUri);
console.info(error);
} catch (err) {
// TODO:删除线上文件
console.error(err);
error = err
}
}
} catch (error) {
console.error(error);
} finally {
this._fileTreeDataDevModel.treeLoading = false;
}
return error;
};
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# 查询/搜索
只搜索脚本处理显示;利用自带的搜索功能,但是只能搜索到可以之前看见过的数组数据;
目前的方案是,判断是在搜索阶段,先全部自动展开一次,保证加载全部数据,再进行之前的恶搜索数据;
modules/file-tree-next/browser/file-tree.service.ts
# 默认打开搜索功能
// 筛选模式开关
private _filterMode = true;
2
# 默认展开全部
最新版本已经支持,要升级最新版本处理;
# 全局搜索单独处理
主要时屏蔽不必要的目录和脚本路径替换;
# 搜索显示
只处理文件搜索,文件夹不做搜索处理;而且项目中的文件夹名字是做过二次修改过也搜索不准;
modules/file-tree-next/browser/components/RecycleTree.tsx
// 过滤Root节点展示
private filterItems = (filter: string) => {
const {
model: { root },
filterProvider,
} = this.props;
this.filterWatcherDisposeCollection.dispose();
this.idToFilterRendererPropsCache.clear();
if (!filter) {
return;
}
const isPathFilter = /\//.test(filter);
const idSets: Set<number> = new Set();
const idToRenderTemplate: Map<number, any> = new Map();
const nodes: TreeNode[] = [];
for (let idx = 0; idx < root.branchSize; idx++) {
const node = root.getTreeNodeAtIndex(idx)!;
if (node instanceof File) nodes.push(node as TreeNode); //只对文件处理搜索;这个搜索也有局限性,只能针对看得到的搜索
}
//。。。。
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
目前搜索只能搜索到展开数据列表的文件;这里要做二次修改;【这个目前是ide默认的功能】;
目前的方案是,在检测到搜索后,全部文件展开,而且设置不可以折叠功能;
# 修改/重命名
modules/file-tree-next/browser/file-tree-contribution.ts
commands.registerCommand<ExplorerContextCallback>(
BDP_FILE_COMMANDS.RENAME_FILE,
{
execute: (uri) => {
if (!uri) {
if (this.fileTreeModelService.contextMenuFile) {
uri = this.fileTreeModelService.contextMenuFile.uri;
} else if (this.fileTreeModelService.focusedFile) {
uri = this.fileTreeModelService.focusedFile.uri;
} else {
return;
}
}
this.fileTreeModelService.renamePrompt(uri);
},
isVisible: () =>
!!this.fileTreeModelService.contextMenuFile &&
!this.fileTreeModelService.contextMenuFile.uri.isEqual(
(this.fileTreeModelService.treeModel.root as Directory).uri
)&& this.fileTreeModelService.contextMenuFile.type===1
}
);
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
modules/file-tree-next/browser/services/file-tree-model.service.ts
async renamePrompt(uri: URI) {
const targetNode = await this.getPromptTarget(uri);
if (targetNode) {
this.proxyPrompt(await this.fileTreeHandle.promptRename(targetNode, uri.displayName));
}
}
private proxyPrompt = (promptHandle: RenamePromptHandle | NewPromptHandle) => {
let isCommit = false;
const selectNodeIfNodeExist = async (path: string) => {
// 文件树更新后尝试定位文件位置
const node = await this.fileTreeService.getNodeByPathOrUri(path);
if (node && node.path === path) {
this.selectFileDecoration(node);
}
};
const commit = async (newName) => {
this.validateMessage = undefined;
if (promptHandle instanceof RenamePromptHandle) {
const target = promptHandle.target as File | Directory;
// 只做修改文件名处理,简化很多;
let isSuccess
this.validateMessage = {
type: PROMPT_VALIDATE_TYPE.ERROR,
message: "修改错误!",
value: newName,
};
var newNameExt = newName.substring(newName.lastIndexOf('.'));
var targetNameExt = target.name.substring(target.name.lastIndexOf('.'));
if (newNameExt !== targetNameExt) {
this.validateMessage.message = "文件名后缀 类型不能修改!";
promptHandle.addValidateMessage(this.validateMessage);
return false;
}
try {
promptHandle.addAddonAfter('loading_indicator');
isSuccess = await this.fileTreeDataDevService.updateZdevscript(target.filestat.uri,newName)
} catch (error) {
isSuccess=false
console.error(error);
} finally{
promptHandle.removeAddonAfter();
}
if (!isSuccess) {
promptHandle.addValidateMessage(this.validateMessage);
return false;
}
const nameFragments = (promptHandle.target as File).displayName.split(Path.separator);
const index = this.activeUri?.displayName ? nameFragments.indexOf(this.activeUri?.displayName) : -1;
const newNameFragments = index === -1 ? [] : nameFragments.slice(0, index).concat(newName);
let from = target.uri;
let to = (target.parent as Directory).uri.resolve(newName);
const isCompactNode = target.name.indexOf(Path.separator) > 0;
// 无变化,直接返回
if ((isCompactNode && this.activeUri?.displayName === newName) || (!isCompactNode && newName === target.name)) {
return true;
}
promptHandle.addAddonAfter('loading_indicator');
if (isCompactNode && newNameFragments.length > 0) {
// 压缩目录情况下,需要计算下标进行重命名路径拼接
from = (target.parent as Directory).uri.resolve(nameFragments.slice(0, index + 1).join(Path.separator));
to = (target.parent as Directory).uri.resolve(newNameFragments.concat().join(Path.separator));
}
// 屏蔽重命名文件事件
const error = await this.fileTreeAPI.mv(from, to, target.type === TreeNodeType.CompositeTreeNode);
if (error) {
this.validateMessage = {
type: PROMPT_VALIDATE_TYPE.ERROR,
message: error,
value: newName,
};
promptHandle.addValidateMessage(this.validateMessage);
return false;
}
if (!isCompactNode && target.parent) {
// 重命名节点的情况,直接刷新一下父节点即可
const node = await this.fileTreeService.moveNodeByPath(
target.parent as Directory,
target.parent as Directory,
target.name,
newName,
target.type,
);
if (node) {
this.selectFileDecoration(node as File, false);
}
} else {
// 更新压缩目录展示名称
// 由于节点移动时默认仅更新节点路径
// 我们需要自己更新额外的参数,如uri, filestat等
(target as Directory).updateMetaData({
name: newNameFragments.concat(nameFragments.slice(index + 1)).join(Path.separator),
uri: to,
fileStat: {
...target.filestat,
uri: to.toString(),
},
tooltip: this.fileTreeAPI.getReadableTooltip(to),
});
this.treeModel.dispatchChange();
if ((target.parent as Directory).children?.find((child) => target.path.indexOf(child.path) >= 0)) {
// 当重命名后的压缩节点在父节点中存在子节点时,刷新父节点
// 如:
// 压缩节点 001/002 修改为 003/002 时
// 同时父节点下存在 003 空节点
await this.fileTreeService.refresh(target.parent as Directory);
} else {
// 压缩节点重命名时,刷新文件夹更新子文件路径
await this.fileTreeService.refresh(target as Directory);
}
}
promptHandle.removeAddonAfter();
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
验证判断逻辑
private validateFileName = (
promptHandle: RenamePromptHandle | NewPromptHandle,
name: string,
): FileTreeValidateMessage | null => {
// 转换为合适的名称
name = this.getWellFormedFileName(name);
// 不存在文件名称
if (!name || name.length === 0 || /^\s+$/.test(name)) {
return {
message: localize('validate.tree.emptyFileNameError'),
type: PROMPT_VALIDATE_TYPE.ERROR,
value: name,
};
}
// 不允许开头为分隔符的名称
var newNameBefore = name.substring(0, name.lastIndexOf('.'));
if (!(/^[A-Za-z0-9_-]+$/.test(newNameBefore))) {
return {
message: "只能由数字,字母,下划线以及中划线(-)组成及保留文件名后缀",
type: PROMPT_VALIDATE_TYPE.ERROR,
value: name,
};
}}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 删除
modules/file-tree-next/browser/file-tree-contribution.ts
commands.registerCommand<ExplorerContextCallback>(
BDP_FILE_COMMANDS.DELETE_FILE,
{
execute: async (_, uris) => {
// 检查多文件,并且检查是否有文件夹,做提醒;只能处理当个文件的
if (!uris) {
if (this.fileTreeModelService.focusedFile) {
this.willDeleteUris.push(
this.fileTreeModelService.focusedFile.uri
);
} else if (
this.fileTreeModelService.selectedFiles &&
this.fileTreeModelService.selectedFiles.length > 0
) {
this.willDeleteUris = this.willDeleteUris.concat(
this.fileTreeModelService.selectedFiles.map((file) => file.uri)
);
} else {
return;
}
} else {
this.willDeleteUris = this.willDeleteUris.concat(uris);
}
if (this.willDeleteUris.length>1) {
await this.dialogService.error(localize("file.onlyfilestips","只能选择一个文件操作"));
this.willDeleteUris = []
return
}
return this.deleteThrottler.queue<void>(this.doDelete.bind(this));
},
// 只有文件可以删除,而且只能单个文件
isVisible: () =>
!!this.fileTreeModelService.contextMenuFile &&
!this.fileTreeModelService.contextMenuFile.uri.isEqual(
(this.fileTreeModelService.treeModel.root as Directory).uri
) && this.fileTreeModelService.contextMenuFile.type===1,
}
);
private doDelete() {
const uris = this.willDeleteUris.slice();
this.willDeleteUris = [];
return this.fileTreeModelService.deleteFileByUris(uris);
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
modules/file-tree-next/browser/services/file-tree-model.service.ts
async deleteFileByUris(uris: URI[]) {
if (uris.length === 0) {
return;
}
if (this.corePreferences['explorer.confirmDelete']) {
const ok = localize('file.confirm.delete.ok');
const cancel = localize('file.confirm.delete.cancel');
const deleteFilesMessage = `[ ${uris
.slice(0, 5)
.map((uri) => uri.displayName)
.join(',')}${uris.length > 5 ? ' ...' : ''} ]`;
const confirm = await this.dialogService.warning(formatLocalize('file.confirm.delete', deleteFilesMessage), [
cancel,
ok,
]);
if (confirm !== ok) {
return;
}
}
const roots = this.fileTreeService.sortPaths(uris);
let nextFocusedFile;
if (this.treeModel.root.branchSize === uris.length) {
nextFocusedFile = undefined;
} else if (
this.selectedFiles.length &&
!roots.find((root) => root.path.toString() === this.selectedFiles[0].uri.toString())
) {
// 当存在选中的文件时,默认选中首个文件作为焦点
nextFocusedFile = this.selectedFiles[0];
} else {
const lastFile = roots[roots.length - 1].node;
const lastIndex = this.treeModel.root.getIndexAtTreeNode(lastFile);
let nextIndex = lastIndex + 1;
if (nextIndex >= this.treeModel.root.branchSize) {
const firstFile = roots[0].node;
const firstIndex = this.treeModel.root.getIndexAtTreeNode(firstFile);
nextIndex = firstIndex - 1;
}
nextFocusedFile = this.treeModel.root.getTreeNodeAtIndex(nextIndex);
}
const toPromise = [] as Promise<boolean>[];
//本地业务代码,只处理单个文件的删除操作
try {
const currentNodeUri = roots[0].node.filestat.uri
const isSuccess = await this.fileTreeDataDevService.deleteZdevscript(currentNodeUri)
if (!isSuccess) {
return
}
roots.forEach((root) => {
this.loadingDecoration.addTarget(root.node);
toPromise.push(
this.deleteFile(root.node, root.path).then((v) => {
this.loadingDecoration.removeTarget(root.node);
return v;
}),
);
});
this.treeModel.dispatchChange();
await Promise.all(toPromise);
// 删除文件后重置一下当前焦点
if (nextFocusedFile) {
this.activeFileDecoration(nextFocusedFile);
}
} catch (error) {
console.error(error);
}
}
async deleteFile(node: File | Directory, path: URI | string): Promise<boolean> {
const uri = typeof path === 'string' ? new URI(path) : (path as URI);
const error = await this.fileTreeAPI.delete(uri);
if (error) {
this.messageService.error(error);
return false;
}
const processNode = (_node: Directory | File) => {
if (_node.uri.isEqual(uri)) {
this.fileTreeService.deleteAffectedNodeByPath(_node.path);
} else {
// 说明是异常情况或子路径删除
this.fileTreeService.refresh(node.parent as Directory);
}
this.loadingDecoration.removeTarget(_node);
// 清空节点路径焦点态
this.contextKey?.explorerCompressedFocusContext.set(false);
this.contextKey?.explorerCompressedFirstFocusContext.set(false);
this.contextKey?.explorerCompressedLastFocusContext.set(false);
};
processNode(node);
return true;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# 主题颜色
# 背景
框架内会注册一份默认的变量,如果需要自定义,比较建议通过主题插件的方式去拓展;
可以在集成的时候去覆盖,注意样式引入顺序就行;
https://github.com/opensumi/core/blob/795a5b44a59839e47b63771c8b9dac0cf04b3cde/packages/theme/src/common/themeCompatibility.ts#L54
参考主题方案:
//直接改主题源
https://github.com/opensumi/Default-Themes//类似这种
//可以自己 fork 出来改,然后拿去用就行了
2
3
# 实现
# 入口处理
import { ConfigProvider } from 'antd';
// ...
return (
<ConfigProvider prefixCls="sumi_antd">
<App />
</ConfigProvider>
);
2
3
4
5
6
7
Developement
- 找到你要覆盖的 antd 组件
- 在
src
下新建一个${组件名}.less
- 在
src/index.less
import 这个文件 - npm run start 即可开始开发对应组件
Tips
antd.less
基本涵盖 antd 中所有的变量和值,可供快速参考查阅- 更完整的 antd 的 less 变量请参见 antd repo 源码
- Open Sumi Tokens 表 (opens new window)
AntdLayout.tsx
组件
// 处理antd样式
import * as React from 'react';
import { ConfigProvider } from 'antd';
import zhCN from 'antd/es/locale/zh_CN';
import 'antd/dist/antd.css';
import '@opensumi/antd-theme/lib/index.css';
import "@/modules/styles/global.less";
import "@/modules/styles/default.less";
import './antd.global.less';
interface IProps {
prefixCls?: string;
children: React.ReactNode;
}
const AntdLayout: React.FC<IProps> = ({
children,
prefixCls = 'ant',
// prefixCls = 'sumi_antd',
}) => {
return (
// <ConfigProvider locale={zhCN}>
<ConfigProvider prefixCls={prefixCls} locale={zhCN}>
{children}
</ConfigProvider>
);
};
export default AntdLayout;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# antd默认样式覆盖
antd.global.less
// :global {
@primary-color: #00c1de; // #1890ff 1785EB
@primary-color-secondary: #26d7eb; //#40a9ff
@primary-color-active: #0099b8; //#096dd9
//ant-btn
.ant-btn:hover, .ant-btn:focus {
color: @primary-color-secondary;
border-color: @primary-color-secondary;
}
.ant-btn:active, .ant-btn.active {
color: @primary-color-active;
border-color: @primary-color-active;
}
.ant-btn-primary {
background-color: @primary-color;
border-color: @primary-color;
}
.ant-btn-primary:hover, .ant-btn-primary:focus {
background-color: @primary-color-secondary;
border-color: @primary-color-secondary;
color: #fff;
}
.ant-btn-primary:active, .ant-btn-primary.active {
background-color: @primary-color-active;
border-color: @primary-color-active;
color: #fff;
}
//ant-radio-button
.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):hover {
color: @primary-color-secondary;
border-color: @primary-color-secondary;
-webkit-box-shadow: -1px 0 0 0 @primary-color-secondary;
box-shadow: -1px 0 0 0 @primary-color-secondary;
}
.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled) {
z-index: 1;
color: @primary-color;
background: #fff;
border-color: @primary-color;
-webkit-box-shadow: -1px 0 0 0 @primary-color;
box-shadow: -1px 0 0 0 @primary-color;
}
.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled)::before {
background-color: @primary-color !important;
}
.ant-radio-button-wrapper:hover {
color: @primary-color;
}
// ant-select
.ant-select-selection:hover {
border-color: @primary-color-secondary;
}
.ant-select-focused .ant-select-selection, .ant-select-selection:focus, .ant-select-selection:active {
border-color: @primary-color-secondary;
}
// ant-radio
.ant-radio-wrapper:hover .ant-radio, .ant-radio:hover .ant-radio-inner, .ant-radio-input:focus + .ant-radio-inner {
border-color: @primary-color-secondary;
}
.ant-radio-checked .ant-radio-inner {
border-color: @primary-color;
}
.ant-radio-inner::after{
background-color: @primary-color;
}
.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled):first-child {
border-color:@primary-color-secondary;
}
// ant-input
.ant-input:hover {
border-color: @primary-color-secondary;
}
.ant-input:focus {
border-color: @primary-color-secondary;
}
.ant-input-affix-wrapper:hover .ant-input:not(.ant-input-disabled){
border-color: @primary-color-secondary;
}
//ant-input-number
.ant-input-number:hover {
border-color: @primary-color-secondary;
}
.ant-input-number:focus {
border-color: @primary-color-secondary;
}
//ant-calendar
.ant-calendar-today .ant-calendar-date {
color: @primary-color;
border-color: @primary-color;
}
.ant-calendar-picker:hover .ant-calendar-picker-input:not(.ant-input-disabled) {
border-color: @primary-color-secondary;
}
.ant-calendar .ant-calendar-ok-btn {
// color: #fff;
background-color: @primary-color;
border-color: @primary-color;
}
.ant-calendar .ant-calendar-ok-btn:active, .ant-calendar .ant-calendar-ok-btn.active {
// color: #fff;
background-color: @primary-color-active;
border-color: @primary-color-active;
}
//ant-time-picker
.ant-time-picker-panel-select li:focus {
color: @primary-color;
}
//ant-switch
.ant-switch-checked {
background-color: @primary-color;
}
//ant-tabs
.ant-tabs-nav .ant-tabs-tab-active {
color: @primary-color;
}
.ant-tabs-nav .ant-tabs-tab:active {
color:@primary-color-active;
}
.ant-tabs-nav .ant-tabs-tab:hover {
color:@primary-color-secondary;
}
//ant-spin
.ant-spin-dot-item {
background-color: @primary-color;
}
.tree-search-box {
padding-top: 12px;
}
// }
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# 配合主题样式
# 配置
目前只适配了Light主题,ide默认是这个主题;再配合main的背景处理;
defaultPreferences: {
// "general.theme": "bdp-dark",
"general.theme": "bdp-light",
"general.icon": "vscode-icons",
'files.exclude': {
'**!/.sumi/!**': true,
'**!/.tmp_code*': true,
},
'search.exclude': {
'**!/.sumi/!**': true,
'**!/.tmp_code*': true,
},
},
2
3
4
5
6
7
8
9
10
11
12
13
#main {
display: flex;
flex-direction: column;
width: 100vw;
height: 100vh;
margin: 0;
padding: 0;
overflow: hidden;
background-color: var(--background);
}
2
3
4
5
6
7
8
9
10
# 自定义主题
extensions/bdp-ide.default-themes/themes/light/plus.json
{
"$schema": "vscode://schemas/color-theme",
"name": "OpenSumi Light+ (default light)",
"tokenColors": [
{
"scope": ["meta.embedded", "source.groovy.embedded"],
"settings": {
"foreground": "#000000ff"
}
},
{
"scope": "emphasis",
"settings": {
"fontStyle": "italic"
}
},
{
"scope": "strong",
"settings": {
"fontStyle": "bold"
}
},
{
"scope": "meta.diff.header",
"settings": {
"foreground": "#000080"
}
},
{
"scope": "comment",
"settings": {
"foreground": "#008000"
}
},
{
"scope": "constant.language",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": [
"constant.numeric",
"variable.other.enummember",
"keyword.operator.plus.exponent",
"keyword.operator.minus.exponent"
],
"settings": {
"foreground": "#098658"
}
},
{
"scope": "constant.regexp",
"settings": {
"foreground": "#811f3f"
}
},
{
"name": "css tags in selectors, xml tags",
"scope": "entity.name.tag",
"settings": {
"foreground": "#800000"
}
},
{
"scope": "entity.name.selector",
"settings": {
"foreground": "#800000"
}
},
{
"scope": "entity.other.attribute-name",
"settings": {
"foreground": "#ff0000"
}
},
{
"scope": [
"entity.other.attribute-name.class.css",
"entity.other.attribute-name.class.mixin.css",
"entity.other.attribute-name.id.css",
"entity.other.attribute-name.parent-selector.css",
"entity.other.attribute-name.pseudo-class.css",
"entity.other.attribute-name.pseudo-element.css",
"source.css.less entity.other.attribute-name.id",
"entity.other.attribute-name.scss"
],
"settings": {
"foreground": "#800000"
}
},
{
"scope": "invalid",
"settings": {
"foreground": "#cd3131"
}
},
{
"scope": "markup.underline",
"settings": {
"fontStyle": "underline"
}
},
{
"scope": "markup.bold",
"settings": {
"fontStyle": "bold",
"foreground": "#000080"
}
},
{
"scope": "markup.heading",
"settings": {
"fontStyle": "bold",
"foreground": "#800000"
}
},
{
"scope": "markup.italic",
"settings": {
"fontStyle": "italic"
}
},
{
"scope": "markup.inserted",
"settings": {
"foreground": "#098658"
}
},
{
"scope": "markup.deleted",
"settings": {
"foreground": "#a31515"
}
},
{
"scope": "markup.changed",
"settings": {
"foreground": "#0451a5"
}
},
{
"scope": [
"punctuation.definition.quote.begin.markdown",
"punctuation.definition.list.begin.markdown"
],
"settings": {
"foreground": "#0451a5"
}
},
{
"scope": "markup.inline.raw",
"settings": {
"foreground": "#800000"
}
},
{
"name": "brackets of XML/HTML tags",
"scope": "punctuation.definition.tag",
"settings": {
"foreground": "#800000"
}
},
{
"scope": ["meta.preprocessor", "entity.name.function.preprocessor"],
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "meta.preprocessor.string",
"settings": {
"foreground": "#a31515"
}
},
{
"scope": "meta.preprocessor.numeric",
"settings": {
"foreground": "#098658"
}
},
{
"scope": "meta.structure.dictionary.key.python",
"settings": {
"foreground": "#0451a5"
}
},
{
"scope": "storage",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "storage.type",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": ["storage.modifier", "keyword.operator.noexcept"],
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": ["string", "meta.embedded.assembly"],
"settings": {
"foreground": "#a31515"
}
},
{
"scope": [
"string.comment.buffered.block.pug",
"string.quoted.pug",
"string.interpolated.pug",
"string.unquoted.plain.in.yaml",
"string.unquoted.plain.out.yaml",
"string.unquoted.block.yaml",
"string.quoted.single.yaml",
"string.quoted.double.xml",
"string.quoted.single.xml",
"string.unquoted.cdata.xml",
"string.quoted.double.html",
"string.quoted.single.html",
"string.unquoted.html",
"string.quoted.single.handlebars",
"string.quoted.double.handlebars"
],
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "string.regexp",
"settings": {
"foreground": "#811f3f"
}
},
{
"name": "String interpolation",
"scope": [
"punctuation.definition.template-expression.begin",
"punctuation.definition.template-expression.end",
"punctuation.section.embedded"
],
"settings": {
"foreground": "#0000ff"
}
},
{
"name": "Reset JavaScript string interpolation expression",
"scope": ["meta.template.expression"],
"settings": {
"foreground": "#000000"
}
},
{
"scope": [
"support.constant.property-value",
"support.constant.font-name",
"support.constant.media-type",
"support.constant.media",
"constant.other.color.rgb-value",
"constant.other.rgb-value",
"support.constant.color"
],
"settings": {
"foreground": "#0451a5"
}
},
{
"scope": [
"support.type.vendored.property-name",
"support.type.property-name",
"variable.css",
"variable.scss",
"variable.other.less",
"source.coffee.embedded"
],
"settings": {
"foreground": "#ff0000"
}
},
{
"scope": ["support.type.property-name.json"],
"settings": {
"foreground": "#0451a5"
}
},
{
"scope": "keyword",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "keyword.control",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "keyword.operator",
"settings": {
"foreground": "#000000"
}
},
{
"scope": [
"keyword.operator.new",
"keyword.operator.expression",
"keyword.operator.cast",
"keyword.operator.sizeof",
"keyword.operator.alignof",
"keyword.operator.typeid",
"keyword.operator.alignas",
"keyword.operator.instanceof",
"keyword.operator.logical.python",
"keyword.operator.wordlike"
],
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "keyword.other.unit",
"settings": {
"foreground": "#098658"
}
},
{
"scope": [
"punctuation.section.embedded.begin.php",
"punctuation.section.embedded.end.php"
],
"settings": {
"foreground": "#800000"
}
},
{
"scope": "support.function.git-rebase",
"settings": {
"foreground": "#0451a5"
}
},
{
"scope": "constant.sha.git-rebase",
"settings": {
"foreground": "#098658"
}
},
{
"name": "coloring of the Java import and package identifiers",
"scope": [
"storage.modifier.import.java",
"variable.language.wildcard.java",
"storage.modifier.package.java"
],
"settings": {
"foreground": "#000000"
}
},
{
"name": "this.self",
"scope": "variable.language",
"settings": {
"foreground": "#0000ff"
}
},
{
"name": "Function declarations",
"scope": [
"entity.name.function",
"support.function",
"support.constant.handlebars",
"source.powershell variable.other.member",
"entity.name.operator.custom-literal" // See https://en.cppreference.com/w/cpp/language/user_literal
],
"settings": {
"foreground": "#795E26"
}
},
{
"name": "Types declaration and references",
"scope": [
"meta.return-type",
"support.class",
"support.type",
"entity.name.type",
"entity.name.namespace",
"entity.other.attribute",
"entity.name.scope-resolution",
"entity.name.class",
"storage.type.numeric.go",
"storage.type.byte.go",
"storage.type.boolean.go",
"storage.type.string.go",
"storage.type.uintptr.go",
"storage.type.error.go",
"storage.type.rune.go",
"storage.type.cs",
"storage.type.generic.cs",
"storage.type.modifier.cs",
"storage.type.variable.cs",
"storage.type.annotation.java",
"storage.type.generic.java",
"storage.type.java",
"storage.type.object.array.java",
"storage.type.primitive.array.java",
"storage.type.primitive.java",
"storage.type.token.java",
"storage.type.groovy",
"storage.type.annotation.groovy",
"storage.type.parameters.groovy",
"storage.type.generic.groovy",
"storage.type.object.array.groovy",
"storage.type.primitive.array.groovy",
"storage.type.primitive.groovy"
],
"settings": {
"foreground": "#267f99"
}
},
{
"name": "Types declaration and references, TS grammar specific",
"scope": [
"meta.type.cast.expr",
"meta.type.new.expr",
"support.constant.math",
"support.constant.dom",
"support.constant.json",
"entity.other.inherited-class"
],
"settings": {
"foreground": "#267f99"
}
},
{
"name": "Control flow / Special keywords",
"scope": [
"keyword.control",
"source.cpp keyword.operator.new",
"source.cpp keyword.operator.delete",
"keyword.other.using",
"keyword.other.operator",
"entity.name.operator"
],
"settings": {
"foreground": "#AF00DB"
}
},
{
"name": "Variable and parameter name",
"scope": [
"variable",
"meta.definition.variable.name",
"support.variable",
"entity.name.variable",
"constant.other.placeholder" // placeholders in strings
],
"settings": {
"foreground": "#001080"
}
},
{
"name": "Constants and enums",
"scope": ["variable.other.constant", "variable.other.enummember"],
"settings": {
"foreground": "#0070C1"
}
},
{
"name": "Object keys, TS grammar specific",
"scope": ["meta.object-literal.key"],
"settings": {
"foreground": "#001080"
}
},
{
"name": "CSS property value",
"scope": [
"support.constant.property-value",
"support.constant.font-name",
"support.constant.media-type",
"support.constant.media",
"constant.other.color.rgb-value",
"constant.other.rgb-value",
"support.constant.color"
],
"settings": {
"foreground": "#0451a5"
}
},
{
"name": "Regular expression groups",
"scope": [
"punctuation.definition.group.regexp",
"punctuation.definition.group.assertion.regexp",
"punctuation.definition.character-class.regexp",
"punctuation.character.set.begin.regexp",
"punctuation.character.set.end.regexp",
"keyword.operator.negation.regexp",
"support.other.parenthesis.regexp"
],
"settings": {
"foreground": "#d16969"
}
},
{
"scope": [
"constant.character.character-class.regexp",
"constant.other.character-class.set.regexp",
"constant.other.character-class.regexp",
"constant.character.set.regexp"
],
"settings": {
"foreground": "#811f3f"
}
},
{
"scope": "keyword.operator.quantifier.regexp",
"settings": {
"foreground": "#000000"
}
},
{
"scope": ["keyword.operator.or.regexp", "keyword.control.anchor.regexp"],
"settings": {
"foreground": "#EE0000"
}
},
{
"scope": "constant.character",
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "constant.character.escape",
"settings": {
"foreground": "#EE0000"
}
},
{
"scope": "entity.name.label",
"settings": {
"foreground": "#000000"
}
}
],
"colors": {
"activityBar.activeBorder": "#00c1de",
"activityBar.activeForeground": "#262626",
"activityBar.background": "#ECECEC",
"activityBar.border": "#E0E0E0",
"activityBar.disableForeground": "#CCCCCC",
"activityBar.dropBackground": "#E0E0E0",
"activityBar.foreground": "#4D4D4D",
"activityBar.inactiveForeground": "#999999",
"activityBarBadge.background": "#00c1de",
"activityBarBadge.foreground": "#FFFFFF",
"badge.background": "#0000001F",
"badge.foreground": "#4D4D4D",
"checkbox.background": "#FFFFFF",
"checkbox.border": "#E0E0E0",
"descriptionForeground": "#999999",
"diffEditor.insertedTextBackground": "#5CDBD340",
"editor.background": "#FFFFFF",
"editor.findMatchHighlightBackground": "#FF9C6E40",
"editorGroup.border": "#E0E0E0",
"editorGroup.dropBackground": "#CCCCCC40",
"editorGroup.emptyBackground": "#FFFFFF",
"editorGroupHeader.tabsBackground": "#F2F2F2",
"editorSuggestWidget.selectedBackground": "#6EB6FA40",
"errorForeground": "#A1260D",
"focusBorder": "#00c1de",
"foreground": "#4D4D4D",
"gitDecoration.addedResourceForeground": "#52C41A",
"gitDecoration.conflictingResourceForeground": "",
"gitDecoration.deletedResourceForeground": "#FA541C",
"gitDecoration.ignoredResourceForeground": "#666666",
"gitDecoration.modifiedResourceForeground": "#FAAD14",
"gitDecoration.submoduleResourceForeground": "#1785EB",
"gitDecoration.untrackedResourceForeground": "#13C2C2",
"icon.foreground": "#4D4D4D",
"input.background": "#FFFFFF",
"input.foreground": "#4D4D4D",
"input.placeholderForeground": "#CCCCCC",
"inputDropdown.searchMatchForeground": "#1785EB",
"inputIcon.foreground": "#CCCCCC",
"inputValidation.errorBackground": "#FFF1F0",
"inputValidation.errorBorder": "#F5222D",
"inputValidation.errorForeground": "#4D4D4D",
"inputValidation.errorText": "#FFF1F0",
"inputValidation.warningBackground": "#FFFBE6",
"inputValidation.warningBorder": "#FFC53D",
"inputValidation.warningText": "#FFC53D",
"keybinding.background": "#99999933",
"kt.accentForeground": "#262626",
"kt.actionbar.disableForeground": "#CCCCCC",
"kt.actionbar.foreground": "#4D4D4D",
"kt.actionbar.selectionBackground": "#E6F3FF",
"kt.actionbar.selectionBorder": "#3D9CF5",
"kt.actionbar.separatorBackground": "#CCCCCC40",
"kt.activityBar.dropUpBackground": "#CCE7FF",
"kt.button.disableBackground": "#CCCCCC40",
"kt.button.disableBorder": "#CCCCCC80",
"kt.button.disableForeground": "#CCCCCC",
"kt.checkbox.disableBackground": "#CCCCCC40",
"kt.checkbox.disableForeground": "#CCCCCC",
"kt.checkbox.hoverBorder": "#00c1de",
"kt.checkbox.selectionBackground": "#1785EB",
"kt.checkbox.selectionForeground": "#FFFFFF",
"kt.dangerButton.background": "#FF4D4F",
"kt.dangerButton.clickBackground": "#F5222D",
"kt.dangerButton.foreground": "#FFFFFF",
"kt.dangerButton.hoverBackground": "#FF7875",
"kt.dangerGhostButton.border": "#FF4D4F",
"kt.dangerGhostButton.clickBorder": "#F5222D",
"kt.dangerGhostButton.clickForeground": "#F5222D",
"kt.dangerGhostButton.foreground": "#FF4D4F",
"kt.dangerGhostButton.hoverBorder": "#FF7875",
"kt.dangerGhostButton.hoverForeground": "#FF7875",
"kt.defaultButton.background": "#FFFFFF",
"kt.defaultButton.border": "#E0E0E0",
"kt.defaultButton.clickBackground": "#FFFFFF",
"kt.defaultButton.clickBorder": "#00c1de",
"kt.defaultButton.disableBackground": "#CCCCCC40",
"kt.defaultButton.disableBorder": "#CCCCCC80",
"kt.defaultButton.disableForeground": "#CCCCCC",
"kt.defaultButton.foreground": "#0099b8",
"kt.defaultButton.hoverBackground": "#FFFFFF",
"kt.defaultButton.hoverBorder": "#6EB6FA",
"kt.defaultButton.selectionBackground": "#1785EB",
"kt.defaultButton.selectionForeground": "#FFFFFF",
"kt.dirtyDot.foreground": "#999999",
"kt.disableForeground": "#CCCCCC",
"kt.editorBreadcrumb.borderDown": "#F2F2F2",
"kt.errorBackground": "#FF787540",
"kt.errorIconForeground": "#FF4D4F",
"kt.hintBackground": "#CCCCCC40",
"kt.hintIconForeground": "#999999",
"kt.icon.clickForeground": "#4D4D4D",
"kt.icon.disableForeground": "#CCCCCC",
"kt.icon.foreground": "#4D4D4D",
"kt.icon.hoverBackground": "#E6F3FF",
"kt.icon.hoverForeground": "#4D4D4D",
"kt.icon.secondaryForeground": "#999999",
"kt.infoBackground": "#6EB6FA40",
"kt.infoIconForeground": "#3D9CF5",
"kt.input.border": "#E0E0E0",
"kt.input.disableBackground": "#CCCCCC40",
"kt.input.disableForeground": "#CCCCCC",
"kt.input.selectionBackground": "#CCE7FF",
"kt.linkButton.clickForeground": "#0D75D6",
"kt.linkButton.disableForeground": "#CCCCCC",
"kt.linkButton.foreground": "#1785EB",
"kt.linkButton.hoverForeground": "#3D9CF5",
"kt.menu.descriptionForeground": "#999999",
"kt.menu.disableForeground": "#CCCCCC",
"kt.menubar.background": "#F2F2F2",
"kt.menubar.border": "#E0E0E0",
"kt.menubar.foreground": "#4D4D4D",
"kt.menubar.separatorBackground": "#CCCCCC40",
"kt.modal.background": "#FFFFFF",
"kt.modal.foreground": "#4D4D4D",
"kt.modal.separatorBackground": "#E0E0E0",
"kt.modalErrorIcon.foreground": "#F5222D",
"kt.modalInfoIcon.foreground": "#1785EB",
"kt.modalSuccessIcon.foreground": "#52C41A",
"kt.modalWarningIcon.foreground": "#FAAD14",
"kt.panel.secondaryForeground": "#999999",
"kt.panelTab.activeBackground": "#FFFFFF",
"kt.panelTab.activeForeground": "#262626",
"kt.panelTab.border": "#E0E0E0",
"kt.panelTab.inactiveBackground": "#F2F2F2",
"kt.panelTab.inactiveForeground": "#4D4D4D",
"kt.panelTitle.background": "#F2F2F2",
"kt.popover.background": "#FFFFFF",
"kt.popover.border": "#E0E0E0",
"kt.popover.foreground": "#4D4D4D",
"kt.popover.prominentBackground": "#F2F2F2",
"kt.primaryButton.background": "#00C1DE",
"kt.primaryButton.clickBackground": "#0099b8",
"kt.primaryButton.foreground": "#FFFFFF",
"kt.primaryButton.hoverBackground": "#26d7eb",
"kt.primaryGhostButton.border": "#00C1DE",
"kt.primaryGhostButton.clickBorder": "#0099b8",
"kt.primaryGhostButton.clickForeground": "#0099b8",
"kt.primaryGhostButton.foreground": "#00C1DE",
"kt.secondaryButton.border": "#E0E0E0",
"kt.secondaryButton.clickBorder": "#00C1DE",
"kt.secondaryButton.clickForeground": "#00C1DE",
"kt.secondaryButton.foreground": "#FFFFFF",
"kt.secondaryButton.hoverBorder": "#6EB6FA",
"kt.secondaryButton.hoverForeground": "#6EB6FA",
"kt.select.background": "#FFFFFF",
"kt.select.border": "#E0E0E0",
"kt.select.disableBackground": "#CCCCCC40",
"kt.select.disableForeground": "#CCCCCC",
"kt.select.foreground": "#4D4D4D",
"kt.select.placeholderForeground": "#CCCCCC",
"kt.selectDropdown.background": "#FFFFFF",
"kt.selectDropdown.foreground": "#4D4D4D",
"kt.selectDropdown.hoverBackground": "#CCCCCC40",
"kt.selectDropdown.selectionBackground": "#6EB6FA40",
"kt.selectOption.activeBorder": "#00c1de",
"kt.statusbar.offline.background": "#F5222D",
"kt.successBackground": "#95DE6440",
"kt.successIconForeground": "#73D13D",
"kt.tab.activeBorder": "#00c1de",
"kt.tab.activeForeground": "#262626",
"kt.tab.borderDown": "#CCCCCC40",
"kt.tab.inactiveForeground": "#4D4D4D",
"kt.tree.activeSelectionBackground": "#0D75D6",
"kt.tree.activeSelectionForeground": "#FFFFFF",
"kt.tree.hoverBackground": "#CCCCCC40",
"kt.tree.hoverForeground": "#4D4D4D",
"kt.tree.inactiveSelectionBackground": "#6EB6FA40",
"kt.tree.inactiveSelectionForeground": "#4D4D4D",
"kt.warningBackground": "#FFD66640",
"kt.warningIconForeground": "#FFC53D",
"kt.whiteGhostButton.border": "#FFFFFF",
"kt.whiteGhostButton.clickBorder": "#FFFFFFA6",
"kt.whiteGhostButton.clickForeground": "#FFFFFFA6",
"kt.whiteGhostButton.disableBackground": "#FFFFFF03",
"kt.whiteGhostButton.disableBorder": "#FFFFFF40",
"kt.whiteGhostButton.disableForeground": "#FFFFFF40",
"kt.whiteGhostButton.foreground": "#FFFFFF",
"list.activeSelectionBackground": "#0D75D6",
"list.activeSelectionForeground": "#FFFFFF",
"list.evenItemBackground": "#99999914",
"list.headerBackground": "#9999991F",
"list.hoverBackground": "#CCCCCC40",
"menu.background": "#FFFFFF",
"menu.foreground": "#4D4D4D",
"menu.selectionBackground": "#CCCCCC40",
"menu.selectionForeground": "#262626",
"menu.separatorBackground": "#E0E0E0",
"menubar.selectionBackground": "#E0E0E0",
"menubar.selectionForeground": "#262626",
"message.background": "#FFFFFF",
"message.foreground": "#4D4D4D",
"messageErrorIcon.foreground": "#F5222D",
"messageInfoIcon.foreground": "#1785EB",
"messageSuccessIcon.foreground": "#52C41A",
"messageWarningIcon.foreground": "#FAAD14",
"notifications.background": "#FFFFFF",
"notifications.foreground": "#4D4D4D",
"notificationsErrorIcon.foreground": "#F5222D",
"notificationsInfoIcon.foreground": "#1785EB",
"notificationsWarningIcon.foreground": "#FAAD14",
"panel.background": "#FFFFFF",
"panel.border": "#E0E0E0",
"panel.foreground": "#4D4D4D",
"panel.selectionBackground": "#CCCCCC40",
"panel.separatorBackground": "#F2F2F2",
"panelMenuBadge.background": "#FFFFFF",
"panelMenuBar.background": "#F2F2F2",
"panelMenuBarBadge.foreground": "#CCCCCC40",
"panelTabBarActionIcon.Background": "#999999",
"panelTabBarError.foreground": "#F5222D",
"panelTitle.activeBorder": "#00c1de",
"panelTitle.activeForeground": "#262626",
"panelTitle.hoverForeground": "#262626",
"panelTitle.inactiveForeground": "#4D4D4D",
"selectDropdown.descriptionForeground": "#999999",
"selectDropdown.teamForeground": "#999999",
"sideBar.background": "#F2F2F2",
"sideBar.border": "#E0E0E0",
"sideBar.dropBackground": "#E0E0E0",
"sideBar.dropUpBackground": "#CCE7FF",
"sideBarSectionHeader.background": "#E0E0E0",
"sideBarSectionHeader.foreground": "#262626",
"sideBarTitle.foreground": "#262626",
"statusBar.background": "#262626",
"statusBar.debuggingBackground": "#FA8C16",
"statusBar.foreground": "#FFFFFF",
"statusBar.noFolderBackground": "#4D4D4D",
"statusBarItem.activeBackground": "#FFFFFF40",
"statusBarItem.hoverBackground": "#FFFFFF03",
"statusBarItem.remoteBackground": "#722ED1",
"tab.activeBackground": "#FFFFFF",
"tab.activeForeground": "#262626",
"tab.border": "#E0E0E0",
"tab.inactiveBackground": "#ECECEC",
"tab.inactiveForeground": "#4D4D4D",
"tab.unfocusedActiveBackground": "#FFFFFF",
"tab.unfocusedActiveForeground": "#999999",
"tab.unfocusedInactiveForeground": "#999999",
"terminal.background": "#FFFFFF",
"terminal.border": "#E0E0E0",
"terminal.foreground": "#4D4D4D",
"terminal.offlineBackground": "#FF787540",
"terminal.offlineForeground": "#999999",
"terminal.offlineLinkForeground": "#1785EB",
"terminal.selectionBackground": "#CCCCCC40",
"tooltip.background": "#FFFFFF",
"tooltip.foreground": "#4D4D4D",
"widget.shadow": "#CCCCCC"
},
"semanticHighlighting": true,
"semanticTokenColors": {
"newOperator": "#0000ff",
"stringLiteral": "#a31515",
"customLiteral": "#000000",
"numberLiteral": "#098658"
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
# 格式化功能
# 功能
相关的命令
// 注销编辑器的格式化和使...格式化和命令编码
const formatIdlist = [
// UN_EDITOR_COMMANDS.FORMAT_DOCUMENT_WITH,
// UN_EDITOR_COMMANDS.FORMAT_SELECTION_WITH,
// UN_EDITOR_COMMANDS.formatDocument, // vscode插件自带的
UN_EDITOR_COMMANDS.quickCommand,
]
formatIdlist.forEach(commandId => {
menuRegistry.unregisterMenuItem(UN_EDITOR_COMMANDS.context, commandId)
})
2
3
4
5
6
7
8
9
10
# 不同语言格式化
shell格式化:使用vs-shell-format
插件
sql格式化:使用vscode-sql-formatter
插件
# vscode中的处理
The Formatting API
The code snippets below show what to do and what not to do when implementing a formatter. The best practice is to use the formatting API and not create a new action, such as "Format Foo File." The full extension example can be found on GitHub (opens new window).
// 👎 formatter implemented as separate command
vscode.commands.registerCommand('extension.format-foo', () => {
const { activeTextEditor } = vscode.window;
if (activeTextEditor && activeTextEditor.document.languageId === 'foo-lang') {
const { document } = activeTextEditor;
const firstLine = document.lineAt(0);
if (firstLine.text !== '42') {
const edit = new vscode.WorkspaceEdit();
edit.insert(document.uri, firstLine.range.start, '42\n');
return vscode.workspace.applyEdit(edit);
}
}
});
// 👍 formatter implemented using API
vscode.languages.registerDocumentFormattingEditProvider('foo-lang', {
provideDocumentFormattingEdits(document: vscode.TextDocument): vscode.TextEdit[] {
const firstLine = document.lineAt(0);
if (firstLine.text !== '42') {
return [vscode.TextEdit.insert(firstLine.range.start, '42\n')];
}
}
});
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Recently, we added the "Format on Save" feature. An extension properly implementing the formatting API supports this feature without any new code.
Tip: To take advantage of this, a formatting extension needs to be registered using the registerDocumentFormattingEditProvider (opens new window) API call.
https://code.visualstudio.com/blogs/2016/11/15/formatters-best-practices
# Sql提示
参考插件SQLTools