@opensumi/ide-preferences 2.18.4-rc-1655088231.0 → 2.18.4
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/README.md +16 -13
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -3,15 +3,15 @@ id: main-layout
|
|
|
3
3
|
title: 配置模块
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
Preferences 模块主要用于管理整个
|
|
6
|
+
Preferences 模块主要用于管理整个IDE配置的读取逻辑,
|
|
7
7
|
|
|
8
|
-
配置文件的目录位置可通过配置 `AppConfig` 中的
|
|
8
|
+
配置文件的目录位置可通过配置 `AppConfig` 中的 `userPreferenceDirName` 及 `workspacePreferenceDirName` 分别配置 全局配置 和 工作区配置的 `settings.json` 读取路径。
|
|
9
9
|
|
|
10
10
|
> 下面我们统一将 `.sumi` 作为我们默认的配置文件读取路径
|
|
11
11
|
|
|
12
12
|
对于全局配置,我们一般是从 `~/.sumi/settings.json` 文件中读取;
|
|
13
13
|
|
|
14
|
-
针对工作区的配置文件,我们一般是从 `${
|
|
14
|
+
针对工作区的配置文件,我们一般是从 `${worksace_path}/.sumi/settings.json` 文件中读取,但在存在多个工作区存在的`多工作区` 项目,我们则是从 `${workspace_name}.sumi-workspace` 文件中读取;
|
|
15
15
|
|
|
16
16
|
你可以简单的通过如下方式来进行配置文件的修改,同时监听其变化:
|
|
17
17
|
|
|
@@ -38,6 +38,8 @@ export class Demo {
|
|
|
38
38
|
}
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
+
|
|
42
|
+
|
|
41
43
|
# 贡献点
|
|
42
44
|
|
|
43
45
|
## Contribution Providers
|
|
@@ -49,18 +51,18 @@ export class Demo {
|
|
|
49
51
|
用于在框架中注册配置定义,你可以创建一个贡献点模块,在应用启动时引入该贡献点模块,来实现自定义的配置定义。
|
|
50
52
|
|
|
51
53
|
##### Example
|
|
52
|
-
|
|
53
54
|
```ts
|
|
55
|
+
|
|
54
56
|
// 定义一个 `general.language` 配置项
|
|
55
57
|
const preferencesSchema: PreferenceSchema = {
|
|
56
|
-
type: 'object',
|
|
58
|
+
'type': 'object',
|
|
57
59
|
properties: {
|
|
58
60
|
'general.demo': {
|
|
59
61
|
type: 'string',
|
|
60
62
|
default: 'zh-CN',
|
|
61
63
|
description: 'Demo preference%',
|
|
62
64
|
},
|
|
63
|
-
}
|
|
65
|
+
}
|
|
64
66
|
};
|
|
65
67
|
|
|
66
68
|
@Domain(PreferenceContribution)
|
|
@@ -74,12 +76,11 @@ export class DemoPreferenceContribution implements PreferenceContribution {
|
|
|
74
76
|
如果你需要让你定义的配置出现在设置面板中,你还可以通过 `SettingContribution` 贡献点来定义。
|
|
75
77
|
|
|
76
78
|
##### Example
|
|
77
|
-
|
|
78
79
|
```ts
|
|
79
80
|
// 在 `general` 面板追加一个 `general.demo` 配置项的展示
|
|
80
81
|
@Domain(SettingContribution)
|
|
81
82
|
export class DemoSettingContribution implements SettingContribution {
|
|
82
|
-
handleSettingSections(settingSections: { [key: string]: ISettingSection[] }) {
|
|
83
|
+
handleSettingSections(settingSections: { [key: string]: ISettingSection[]; }) {
|
|
83
84
|
return {
|
|
84
85
|
...settingSections,
|
|
85
86
|
general: [
|
|
@@ -103,13 +104,13 @@ export class DemoSettingContribution implements SettingContribution {
|
|
|
103
104
|
|
|
104
105
|
### Command
|
|
105
106
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
* `preference.open.user`: 打开用户配置文件
|
|
108
|
+
* `preference.open.workspace`: 打开工作区配置文件
|
|
109
|
+
* `core.openpreference`: 打开设置面板
|
|
109
110
|
|
|
110
111
|
### KeyBinding
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
* `ctrlcmd+,`: 打开设置面板
|
|
113
114
|
|
|
114
115
|
# 类
|
|
115
116
|
|
|
@@ -123,6 +124,7 @@ export class DemoSettingContribution implements SettingContribution {
|
|
|
123
124
|
|
|
124
125
|
#### `ready`
|
|
125
126
|
|
|
127
|
+
|
|
126
128
|
```ts
|
|
127
129
|
ready: Promise<void>;
|
|
128
130
|
```
|
|
@@ -151,7 +153,7 @@ ready: Promise<void>;
|
|
|
151
153
|
|
|
152
154
|
```ts
|
|
153
155
|
/**
|
|
154
|
-
*
|
|
156
|
+
*
|
|
155
157
|
* @param preferenceName 配置名称
|
|
156
158
|
* @param defaultValue 默认值
|
|
157
159
|
* @param resourceUri 资源路径
|
|
@@ -170,6 +172,7 @@ ready: Promise<void>;
|
|
|
170
172
|
|
|
171
173
|
配置变更事件,这里会获取到一个配置变更的集合。
|
|
172
174
|
|
|
175
|
+
|
|
173
176
|
#### `onPreferenceChanged()`
|
|
174
177
|
|
|
175
178
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/ide-preferences",
|
|
3
|
-
"version": "2.18.4
|
|
3
|
+
"version": "2.18.4",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib"
|
|
6
6
|
],
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
"url": "git@github.com:opensumi/core.git"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@opensumi/ide-core-common": "2.18.4
|
|
19
|
+
"@opensumi/ide-core-common": "2.18.4"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@opensumi/ide-components": "2.18.4
|
|
23
|
-
"@opensumi/ide-core-browser": "2.18.4
|
|
22
|
+
"@opensumi/ide-components": "2.18.4",
|
|
23
|
+
"@opensumi/ide-core-browser": "2.18.4",
|
|
24
24
|
"@opensumi/ide-dev-tool": "^1.3.1",
|
|
25
|
-
"@opensumi/ide-editor": "2.18.4
|
|
26
|
-
"@opensumi/ide-file-service": "2.18.4
|
|
27
|
-
"@opensumi/ide-workspace": "2.18.4
|
|
25
|
+
"@opensumi/ide-editor": "2.18.4",
|
|
26
|
+
"@opensumi/ide-file-service": "2.18.4",
|
|
27
|
+
"@opensumi/ide-workspace": "2.18.4"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "d986d61bfb88b746423e5372e67739a7eac78f33"
|
|
30
30
|
}
|