Skip to content

Commit 5215b98

Browse files
authored
自动升级替换为手动 (#569)
* update: 更新文案、翻译 (#568) * update: 更新、替换 reload命令 (#568) * feat: 初始化时自动更新换成手动 (#568) * update: 更新日文文案 * update: 清理文件锁相关内容 (#568) * update: 优化代码 (#568)
1 parent 5bcacc9 commit 5215b98

16 files changed

+102
-184
lines changed

l10n/bundle.l10n.ja.json

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

l10n/bundle.l10n.json

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

package-lock.json

Lines changed: 2 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "background",
33
"displayName": "background",
44
"description": "Bring background images to your vscode",
5-
"version": "2.0.5",
5+
"version": "2.0.6-alpha.0",
66
"scripts": {
77
"vscode:prepublish": "npm run compile",
88
"vscode:uninstall": "node ./out/uninstall",
@@ -316,7 +316,6 @@
316316
},
317317
"devDependencies": {
318318
"@ianvs/prettier-plugin-sort-imports": "^4.7.0",
319-
"@types/lockfile": "^1.0.4",
320319
"@types/node": "^24",
321320
"@types/stylis": "^4.2.7",
322321
"@types/uglify-js": "^3.17.5",
@@ -334,7 +333,6 @@
334333
"dependencies": {
335334
"@vscode/sudo-prompt": "^9.3.1",
336335
"fast-glob": "^3.3.3",
337-
"lockfile": "^1.0.4",
338336
"stylis": "^4.3.6",
339337
"uglify-js": "^3.19.3"
340338
}

package.nls.ja.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extension.background.command.info.title": "backgroundへようこそ。",
3-
"extension.background.command.install.title": "「background」をインストールして有効にします。",
4-
"extension.background.command.disable.title": "background」を無効にする。",
3+
"extension.background.command.install.title": "有効にして適用「Background」 を有効にして適用",
4+
"extension.background.command.disable.title": "Background」を無効にする。",
55
"extension.background.command.uninstall.title": "拡張機能をアンインストール",
66

77
"extension.background.enabled.description": "拡張機能の有効化を制御します",

package.nls.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"extension.background.command.info.title": "Welcome to background.",
3-
"extension.background.command.install.title": "Install and enable the background.",
3+
"extension.background.command.install.title": "Enable and apply the background.",
44
"extension.background.command.disable.title": "Disable the background.",
55
"extension.background.command.uninstall.title": "Uninstall the extension.",
66

package.nls.zh.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"extension.background.command.info.title": "欢迎使用 background 插件",
3-
"extension.background.command.install.title": "安装/激活插件",
3+
"extension.background.command.install.title": "激活/应用插件",
44
"extension.background.command.disable.title": "禁用插件",
55
"extension.background.command.uninstall.title": "卸载插件",
66

src/background/Background.ts

Lines changed: 44 additions & 42 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;
@@ -155,25 +139,20 @@ export class Background implements Disposable {
155139
if (!enabled) {
156140
if (hasInstalled) {
157141
await this.uninstall();
158-
vsHelp.showInfoRestart(l10n.t('Background has been disabled! Please restart.'));
159-
}
160-
return;
161-
}
162142

163-
// 更新,需要二次确认
164-
const confirm = await vscode.window.showInformationMessage(
165-
l10n.t('Configuration has been changed, click to update.'),
166-
{
167-
title: l10n.t('Update and restart')
143+
vsHelp.reload({
144+
message: l10n.t('Background has been disabled! Please reload.')
145+
});
168146
}
169-
);
170-
171-
if (!confirm) {
172147
return;
173148
}
174149

175-
await this.applyPatch();
176-
vscode.commands.executeCommand('workbench.action.reloadWindow');
150+
// 更新,需要二次确认
151+
vsHelp.reload({
152+
message: l10n.t('Configuration has been changed, click to apply.'),
153+
btnReload: l10n.t('Apply and Reload'),
154+
beforeReload: () => this.applyPatch()
155+
});
177156
}
178157

179158
public async applyPatch() {
@@ -193,25 +172,48 @@ export class Background implements Disposable {
193172
/**
194173
* 初始化
195174
*
196-
* @return {*} {Promise<void>}
175+
* @return {*} {Promise<any>}
197176
* @memberof Background
198177
*/
199178
public async setup(): Promise<any> {
200-
await this.removeLegacyCssPatch(); // 移除v1旧版本patch
179+
await this.removeLegacyCssPatch(); // 移除「v1旧版本」patch
201180

202181
await this.checkFirstload(); // 是否初次加载插件
203182

204-
const patchType = await this.jsFile.getPatchType(); // css 文件目前状态
183+
const patchType = await this.jsFile.getPatchType(); // 「js文件」目前状态
205184

206-
// 如果「开启」状态,文件不是「latest」,则进行更新
207-
if (this.config.enabled) {
208-
// 此时一般为 vscode更新、background更新
209-
if ([EFilePatchType.Legacy, EFilePatchType.None].includes(patchType)) {
210-
if (await this.applyPatch()) {
211-
vsHelp.showInfoRestart(l10n.t('Background has been changed! Please restart.'));
212-
}
213-
}
185+
// 如果「开启」状态,文件不是「latest」,则进行「提示更新」
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+
});
214208
}
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+
// }
215217

216218
// 监听文件改变
217219
this.disposables.push(

src/background/CssFile.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ export class CssFile {
177177
*/
178178
public async uninstall(): Promise<boolean> {
179179
try {
180-
await _.lock();
181180
let content = await this.getContent();
182181
content = this.clearContent(content);
183182
// 异常case return
@@ -188,8 +187,6 @@ export class CssFile {
188187
} catch (ex) {
189188
console.log(ex);
190189
return false;
191-
} finally {
192-
await _.unlock();
193190
}
194191
}
195192
}

0 commit comments

Comments
 (0)