Skip to content

Commit caddc24

Browse files
committed
feat: 初始化时自动更新换成手动 (#568)
1 parent 59a7207 commit caddc24

File tree

4 files changed

+42
-41
lines changed

4 files changed

+42
-41
lines changed

l10n/bundle.l10n.ja.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
"Show `background` commands": "「`background`」コマンドの表示",
33
"Background extension has been uninstalled. See you next time!": "Backgroundはアンインストールされています。また今度!",
44
"Reload vscode": "vscode を再読み込み",
5-
"Welcome to use background@{version}!": "ようこそbackground@{version}!",
5+
"Background@{version} is ready! Apply to take effect.": "Background@{version} の準備ができました!「適用」をクリックして反映してください。",
66
"More": "詳細",
77
"Background has been disabled! Please reload.": "Backgroundは無効になっています!再起動してください。",
8-
"Configuration has been changed, click to update.": "構成が変更されたので、更新をクリックします。",
9-
"Update and Reload": "更新して再読み込み",
10-
"Background has been changed! Please reload.": "Backgroundは変わった!再起動してください。"
8+
"Configuration has been changed, click to apply.": "構成が変更されたので、更新をクリックします。",
9+
"Apply and Reload": "適用して再読み込み"
1110
}

l10n/bundle.l10n.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
"Show `background` commands": "Show `background` commands",
33
"Background extension has been uninstalled. See you next time!": "Background extension has been uninstalled. See you next time!",
44
"Reload vscode": "Reload vscode",
5-
"Welcome to use background@{version}!": "Welcome to use background@{version}!",
5+
"Background@{version} is ready! Apply to take effect.": "Background@{version} is ready! Apply to take effect.",
66
"More": "More",
77
"Background has been disabled! Please reload.": "Background has been disabled! Please reload.",
8-
"Configuration has been changed, click to update.": "Configuration has been changed, click to update.",
9-
"Update and Reload": "Update and Reload",
10-
"Background has been changed! Please reload.": "Background has been changed! Please reload."
8+
"Configuration has been changed, click to apply.": "Configuration has been changed, click to apply.",
9+
"Apply and Reload": "Apply and Reload"
1110
}

l10n/bundle.l10n.zh-cn.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
"Show `background` commands": "查看 `background` 命令",
33
"Background extension has been uninstalled. See you next time!": "Background 已经卸载,下次见!",
44
"Reload vscode": "重载 vscode",
5-
"Welcome to use background@{version}!": "欢迎使用 background@{version}!",
5+
"Background@{version} is ready! Apply to take effect.": "Background@{version} 已就绪!点击应用生效。",
66
"More": "更多",
77
"Background has been disabled! Please reload.": "Background 已经禁用! 请重载。",
8-
"Configuration has been changed, click to update.": "配置已改变,点击更新。",
9-
"Update and Reload": "更新并重载",
10-
"Background has been changed! Please reload.": "Background 已经改变!请重载。"
8+
"Configuration has been changed, click to apply.": "配置已改变,点击应用。",
9+
"Apply and Reload": "应用并重载"
1110
}

src/background/Background.ts

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class Background implements Disposable {
6161
// #region private methods 私有方法
6262

6363
/**
64-
* 检测是否初次加载,并在初次加载的时候提示用户
64+
* 检测是否初次加载
6565
*
6666
* @private
6767
* @returns {boolean} 是否初次加载
@@ -71,22 +71,6 @@ export class Background implements Disposable {
7171
const firstLoad = !fs.existsSync(TOUCH_JSFILE_PATH);
7272

7373
if (firstLoad) {
74-
// 提示
75-
vscode.window
76-
.showInformationMessage(l10n.t('Welcome to use background@{version}!', { version: VERSION }), {
77-
title: l10n.t('More')
78-
})
79-
.then(confirm => {
80-
if (!confirm) {
81-
return;
82-
}
83-
this.showWelcome();
84-
});
85-
86-
// 新版本强制提示下吧
87-
// if (VERSION === '2.0.0' || true) {
88-
// this.showWelcome();
89-
// }
9074
// 标识插件已启动过
9175
await fs.promises.writeFile(TOUCH_JSFILE_PATH, vscodePath.jsPath, ENCODING);
9276
return true;
@@ -165,8 +149,8 @@ export class Background implements Disposable {
165149

166150
// 更新,需要二次确认
167151
vsHelp.reload({
168-
message: l10n.t('Configuration has been changed, click to update.'),
169-
btnReload: l10n.t('Update and Reload'),
152+
message: l10n.t('Configuration has been changed, click to apply.'),
153+
btnReload: l10n.t('Apply and Reload'),
170154
beforeReload: () => this.applyPatch()
171155
});
172156
}
@@ -199,17 +183,37 @@ export class Background implements Disposable {
199183
const patchType = await this.jsFile.getPatchType(); // 「js文件」目前状态
200184

201185
// 如果「开启」状态,文件不是「latest」,则进行「提示更新」
202-
if (this.config.enabled) {
203-
// 此时一般为 「background更新」、「vscode更新」
204-
if ([EFilePatchType.Legacy, EFilePatchType.None].includes(patchType)) {
205-
// 提示: background 可更新
206-
if (await this.applyPatch()) {
207-
vsHelp.reload({
208-
message: l10n.t('Background has been changed! Please reload.')
209-
});
210-
}
211-
}
186+
// 此时一般为 「background更新」、「vscode更新」
187+
const needApply = [EFilePatchType.Legacy, EFilePatchType.None].includes(patchType);
188+
if (this.config.enabled && needApply) {
189+
// 提示
190+
vscode.window
191+
.showInformationMessage(
192+
l10n.t('Background@{version} is ready! Apply to take effect.', { version: VERSION }),
193+
{
194+
title: l10n.t('Apply and Reload'),
195+
action: async () => {
196+
await this.applyPatch();
197+
await vsHelp.reload();
198+
}
199+
},
200+
{
201+
title: l10n.t('More'),
202+
action: () => this.showWelcome()
203+
}
204+
)
205+
.then(confirm => {
206+
confirm?.action();
207+
});
212208
}
209+
// if ([EFilePatchType.Legacy, EFilePatchType.None].includes(patchType)) {
210+
// // 提示: 欢迎使用 background@version! 「应用并重载」、「更多」
211+
// if (await this.applyPatch()) {
212+
// vsHelp.reload({
213+
// message: l10n.t('Background has been changed! Please reload.')
214+
// });
215+
// }
216+
// }
213217

214218
// 监听文件改变
215219
this.disposables.push(

0 commit comments

Comments
 (0)