Skip to content

Commit 4715193

Browse files
committed
重构VSCode设置,更新默认格式化工具为TypeScript语言特性,优化updateHelper.js中的错误处理逻辑
1 parent 0da85b7 commit 4715193

File tree

2 files changed

+89
-93
lines changed

2 files changed

+89
-93
lines changed

.vscode/settings.json

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,16 @@
55
"editor.formatOnType": false,
66
// Default formatter for different languages
77
"[javascript]": {
8-
"editor.defaultFormatter": "esbenp.prettier-vscode"
8+
"editor.defaultFormatter": "vscode.typescript-language-features"
99
},
1010
"[typescript]": {
11-
"editor.defaultFormatter": "esbenp.prettier-vscode"
11+
"editor.defaultFormatter": "vscode.typescript-language-features"
1212
},
13-
"[csharp]": {
14-
"editor.defaultFormatter": "ms-dotnettools.csharp"
15-
},
16-
// ESLint configuration for JavaScript and TypeScript
17-
"eslint.validate": [
18-
"javascript",
19-
"javascriptreact",
20-
"typescript",
21-
"typescriptreact"
22-
],
2313
// Enable linting on save
2414
"editor.codeActionsOnSave": {
2515
"source.organizeImports": "explicit",
2616
"source.fixAll": "explicit"
2717
},
28-
// Prettier configuration for consistent formatting
29-
"prettier.printWidth": 100,
30-
"prettier.singleQuote": true,
31-
"prettier.trailingComma": "es5",
32-
"prettier.tabWidth": 2,
33-
"prettier.useTabs": false,
34-
"prettier.arrowParens": "avoid",
35-
// C# specific settings
36-
"omnisharp.enableRoslynAnalyzers": true,
37-
"omnisharp.enableEditorConfigSupport": true,
38-
"omnisharp.organizeImportsOnFormat": true,
39-
"csharp.format.enable": true,
4018
// Editor-specific preferences
4119
"editor.tabSize": 2,
4220
"editor.insertSpaces": true,
@@ -48,4 +26,4 @@
4826
// Enable bracket colorization for better code readability
4927
"editor.bracketPairColorization.enabled": true,
5028
"dotnet.preferCSharpExtension": true
51-
}
29+
}

src/src/utils/updateHelper.js

Lines changed: 86 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -32,53 +32,63 @@ export default SYNOCOMMUNITY.RRManager.UpdateHelper = {
3232
MAX_POST_FILESIZE: Ext.isWebKit
3333
? -1
3434
: window.console && window.console.firebug
35-
? 20971521
36-
: 4294963200,
35+
? 20971521
36+
: 4294963200,
3737
onRunRrUpdateManuallyClick: async function (updateFilePath) {
3838
const rrConfigJson = localStorage.getItem('rrConfig');
3939
const rrConfig = JSON.parse(rrConfigJson);
4040

4141
const confirmUpload = () => {
42-
return new Promise((resolve) => {
43-
this.appWin.getMsgBox().confirmDelete(
44-
'Confirm',
45-
this.helper.V('upload_file_dialog', 'file_uploading_succesfull_msg'),
46-
result => {
47-
resolve(result === 'yes');
48-
},
49-
null,
50-
{
51-
yes: {
52-
text: this.helper.T('common', 'yes'),
53-
btnStyle: 'red',
42+
return new Promise((resolve, reject) => {
43+
try {
44+
this.appWin.getMsgBox().confirmDelete(
45+
'Confirm',
46+
this.helper.V('upload_file_dialog', 'file_uploading_succesfull_msg'),
47+
result => {
48+
resolve(result === 'yes');
5449
},
55-
no: { text: Ext.MessageBox.buttonText.no },
56-
}
57-
);
50+
null,
51+
{
52+
yes: {
53+
text: this.helper.T('common', 'yes'),
54+
btnStyle: 'red',
55+
},
56+
no: { text: Ext.MessageBox.buttonText.no },
57+
}
58+
);
59+
} catch (error) {
60+
console.error('Error in confirmUpload:', error);
61+
reject(error);
62+
}
5863
});
5964
};
6065

6166
const confirmUpdate = (currentRrVersion, updateRrVersion) => {
62-
return new Promise((resolve) => {
63-
this.appWin.getMsgBox().confirmDelete(
64-
'Confirmation',
65-
this.helper.formatString(
66-
this.helper.V('upload_file_dialog', 'update_rr_confirmation'),
67-
currentRrVersion,
68-
updateRrVersion
69-
),
70-
userResponse => {
71-
resolve(userResponse === 'yes');
72-
},
73-
null,
74-
{
75-
yes: {
76-
text: this.helper.V('upload_file_dialog', 'btn_proceed'),
77-
btnStyle: 'red',
67+
return new Promise((resolve, reject) => {
68+
try {
69+
this.appWin.getMsgBox().confirmDelete(
70+
'Confirmation',
71+
this.helper.formatString(
72+
this.helper.V('upload_file_dialog', 'update_rr_confirmation'),
73+
currentRrVersion,
74+
updateRrVersion
75+
),
76+
userResponse => {
77+
resolve(userResponse === 'yes');
7878
},
79-
no: { text: this.helper.T('common', 'cancel') },
80-
}
81-
);
79+
null,
80+
{
81+
yes: {
82+
text: this.helper.V('upload_file_dialog', 'btn_proceed'),
83+
btnStyle: 'red',
84+
},
85+
no: { text: this.helper.T('common', 'cancel') },
86+
}
87+
);
88+
} catch (error) {
89+
console.error('Error in confirmUpdate:', error);
90+
reject(error);
91+
}
8292
});
8393
};
8494

@@ -107,51 +117,59 @@ export default SYNOCOMMUNITY.RRManager.UpdateHelper = {
107117
let countUpdatesStatusAttemp = 0;
108118

109119
const checkUpdateStatus = async () => {
110-
const checksStatusResponse = await this.apiProvider.callCustomScript(
111-
'checkUpdateStatus.cgi?filename=rr_update_progress'
112-
);
113-
if (!checksStatusResponse?.success) {
114-
this.helper.unmask(this.appWin);
115-
this.showMsg(checksStatusResponse?.status);
116-
return false;
117-
}
118-
const response = checksStatusResponse.result;
119-
this.helper.mask(
120-
this.appWin,
121-
this.helper.formatString(
122-
this.helper.V('upload_file_dialog', 'update_rr_progress_msg'),
123-
response?.progress ?? '--',
124-
response?.progressmsg ?? '--'
125-
),
126-
'x-mask-loading'
127-
);
128-
countUpdatesStatusAttemp++;
129-
if (
130-
countUpdatesStatusAttemp === maxCountOfRefreshUpdateStatus ||
131-
response?.progress?.startsWith('-')
132-
) {
133-
this.helper.unmask(this.appWin);
134-
this.showMsg(
120+
try {
121+
const checksStatusResponse = await this.apiProvider.callCustomScript(
122+
'checkUpdateStatus.cgi?filename=rr_update_progress'
123+
);
124+
if (!checksStatusResponse?.success) {
125+
this.helper.unmask(this.appWin);
126+
this.showMsg(checksStatusResponse?.status);
127+
return false;
128+
}
129+
const response = checksStatusResponse.result;
130+
this.helper.mask(
131+
this.appWin,
135132
this.helper.formatString(
136133
this.helper.V('upload_file_dialog', 'update_rr_progress_msg'),
137-
response?.progress,
138-
response?.progressmsg
139-
)
134+
response?.progress ?? '--',
135+
response?.progressmsg ?? '--'
136+
),
137+
'x-mask-loading'
140138
);
141-
return false;
142-
} else if (response?.progress === '100') {
139+
countUpdatesStatusAttemp++;
140+
if (
141+
countUpdatesStatusAttemp === maxCountOfRefreshUpdateStatus ||
142+
response?.progress?.startsWith('-')
143+
) {
144+
this.helper.unmask(this.appWin);
145+
this.showMsg(
146+
this.helper.formatString(
147+
this.helper.V('upload_file_dialog', 'update_rr_progress_msg'),
148+
response?.progress,
149+
response?.progressmsg
150+
)
151+
);
152+
return false;
153+
} else if (response?.progress === '100') {
154+
this.helper.unmask(this.appWin);
155+
this.showMsg(this.helper.V('upload_file_dialog', 'update_rr_completed'));
156+
return false;
157+
}
158+
return true;
159+
} catch (error) {
160+
console.error('Error in checkUpdateStatus:', error);
143161
this.helper.unmask(this.appWin);
144-
this.showMsg(this.helper.V('upload_file_dialog', 'update_rr_completed'));
162+
this.showMsg(`Error in checkUpdateStatus: ${error}`);
145163
return false;
146164
}
147-
return true;
148165
};
149166

150167
while (await checkUpdateStatus()) {
151168
await new Promise(resolve => setTimeout(resolve, 1500));
152169
}
153170
}
154171
} catch (error) {
172+
console.error('Error in onRunRrUpdateManuallyClick:', error);
155173
this.showMsg(`Error. ${error}`);
156174
}
157175
}

0 commit comments

Comments
 (0)