Skip to content

Commit

Permalink
更新文档,去除旧版图片、翻译
Browse files Browse the repository at this point in the history
  • Loading branch information
shalldie committed Oct 18, 2024
1 parent dca7330 commit 13a0c9a
Show file tree
Hide file tree
Showing 21 changed files with 144 additions and 133 deletions.
19 changes: 19 additions & 0 deletions docs/common-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,22 @@ three ways:

Snap use [SquashFS](https://en.wikipedia.org/wiki/SquashFS) to storage packages, it's a compressed readonly file system.
Try to install vscode using deb or rpm.

## Prefer v1 default images?

You can download the default images of v1 version [from here](https://github.com/shalldie/vscode-background/issues/106#issuecomment-392311967), or use the config below:

```json
{
"background.editor": {
"style": {
"opacity": 0.6
},
"images": [
"https://user-images.githubusercontent.com/9987486/40583669-d6189844-61c5-11e8-89e3-c52ad153da09.png",
"https://user-images.githubusercontent.com/9987486/40583670-d6478c9e-61c5-11e8-9551-6b55eacc7b8d.png",
"https://user-images.githubusercontent.com/9987486/40583671-d676c6e4-61c5-11e8-94cb-34ec4a12fa01.png"
]
}
}
```
19 changes: 19 additions & 0 deletions docs/common-issues.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,22 @@

Snap 使用 [SquashFS](https://en.wikipedia.org/wiki/SquashFS) 存储包,这是一个压缩的只读文件系统。
可以使用 deb 或者 rpm 来安装 vscode。

## 想继续使用v1版本的默认图片?

可以从这里 [下载v1版本中的默认图片](<(https://github.com/shalldie/vscode-background/issues/106#issuecomment-392311967)>),或者使用下方配置:

```json
{
"background.editor": {
"style": {
"opacity": 0.6
},
"images": [
"https://user-images.githubusercontent.com/9987486/40583669-d6189844-61c5-11e8-89e3-c52ad153da09.png",
"https://user-images.githubusercontent.com/9987486/40583670-d6478c9e-61c5-11e8-9551-6b55eacc7b8d.png",
"https://user-images.githubusercontent.com/9987486/40583671-d676c6e4-61c5-11e8-94cb-34ec4a12fa01.png"
]
}
}
```
4 changes: 4 additions & 0 deletions docs/migration-from-v1.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
## Migration from v1

> The configuration of v1 is outdated and needs to be migrated. Currently maintaining a certain level of compatibility.
>
> You can download the default images of v1 version [from here](https://github.com/shalldie/vscode-background/issues/106#issuecomment-392311967).
> v1 的配置已经过时,需要进行迁移。当前保持一定的兼容性。
>
> 可以从这里 [下载v1版本中的默认图片](<(https://github.com/shalldie/vscode-background/issues/106#issuecomment-392311967)>)
v1:

Expand Down
2 changes: 2 additions & 0 deletions docs/welcome.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ No more warnings about `Your Code installation appears to be corrupt`.
## Migration from v1

> The configuration of v1 is outdated and needs to be migrated. Currently maintaining a certain level of compatibility.
>
> You can download the default images of v1 version [from here](https://github.com/shalldie/vscode-background/issues/106#issuecomment-392311967).
v1:

Expand Down
2 changes: 2 additions & 0 deletions docs/welcome.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
## 从 v1 迁移

> v1 的配置已经过时,需要进行迁移。当前保持一定的兼容性。
>
> 可以从这里 [下载v1版本中的默认图片](<(https://github.com/shalldie/vscode-background/issues/106#issuecomment-392311967)>)
v1:

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "background",
"displayName": "background",
"description": "Bring background images to your vscode",
"version": "2.0.0-rc.1",
"version": "2.0.0-rc.2",
"scripts": {
"vscode:prepublish": "npm run compile",
"vscode:uninstall": "node ./out/uninstall",
Expand Down Expand Up @@ -69,7 +69,6 @@
"background.useFront": {
"type": "boolean",
"default": true,
"markdownDescription": "%extension.background.useFront.description%",
"markdownDeprecationMessage": "%extension.background.common.deprecation%"
},
"background.style": {
Expand All @@ -79,7 +78,6 @@
"background-size": "auto",
"opacity": 1
},
"markdownDescription": "%extension.background.style.description%",
"markdownDeprecationMessage": "%extension.background.common.deprecation%"
},
"background.styles": {
Expand All @@ -89,7 +87,6 @@
{},
{}
],
"markdownDescription": "%extension.background.styles.description%",
"markdownDeprecationMessage": "%extension.background.common.deprecation%"
},
"background.customImages": {
Expand All @@ -100,13 +97,11 @@
"pattern": "^(https://|file://)",
"patternErrorMessage": "%extension.background.urlProtocol.error%"
},
"markdownDescription": "%extension.background.customImages.description%",
"markdownDeprecationMessage": "%extension.background.common.deprecation%"
},
"background.interval": {
"type": "number",
"default": 0,
"markdownDescription": "%extension.background.interval.description%",
"markdownDeprecationMessage": "%extension.background.common.deprecation%"
},
"background.editor": {
Expand Down
5 changes: 0 additions & 5 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
"extension.background.command.uninstall.title": "Uninstall the extension.",

"extension.background.enabled.description": "Whether to enable background extension.",
"extension.background.useFront.description": "If use front image,which means image is placed on the top of your code.",
"extension.background.style.description": "Custom common style.",
"extension.background.styles.description": "Each style of backgrounds.",
"extension.background.customImages.description": "Your custom images.\n\nExample:\n\n`https://a.com/b.png`\n\n`file:///a/b.jpg`",
"extension.background.interval.description": "Seconds of interval for carousel, default `0` to disabled.",

"extension.background.editor.description": "Editor section config.",
"extension.background.editor.useFront": "Place the image above or below the code.",
Expand Down
5 changes: 0 additions & 5 deletions package.nls.zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
"extension.background.command.uninstall.title": "卸载插件",

"extension.background.enabled.description": "background 插件是否启用",
"extension.background.useFront.description": "把图片放在代码的上方或下方。",
"extension.background.style.description": "自定义各项公有样式",
"extension.background.styles.description": "每一个背景图的独有样式",
"extension.background.customImages.description": "自己定制背景图\n\n例如:\n\n`https://a.com/b.png`\n\n`file:///a/b.jpg`",
"extension.background.interval.description": "单位 `秒`,轮播时候图片切换间隔,默认 `0` 表示不开启。",

"extension.background.editor.description": "编辑器区域配置。",
"extension.background.editor.useFront": "把图片放在代码的上方或下方。",
Expand Down
2 changes: 1 addition & 1 deletion src/background/Background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import path from 'path';

import vscode, { Disposable, Uri } from 'vscode';

import { ENCODING, EXTENSION_NAME, TOUCH_JSFILE_PATH, VERSION } from '../constants';
import { utils } from '../utils';
import { ENCODING, EXTENSION_NAME, TOUCH_JSFILE_PATH, VERSION } from '../utils/constants';
import { vscodePath } from '../utils/vscodePath';
import { vsHelp } from '../utils/vsHelp';
import { CssFile } from './CssFile';
Expand Down
2 changes: 1 addition & 1 deletion src/background/CssFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import fs, { constants as fsConstants } from 'fs';
import { tmpdir } from 'os';
import path from 'path';

import { BACKGROUND_VER, ENCODING, VERSION } from '../constants';
import { utils } from '../utils';
import { BACKGROUND_VER, ENCODING, VERSION } from '../utils/constants';
import { vscode } from '../utils/vsc';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/background/PatchFile/PatchFile.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import fs, { constants as fsConstants } from 'fs';
import { tmpdir } from 'os';
import path from 'path';

import { BACKGROUND_VER, ENCODING, VERSION } from '../../constants';
import { utils } from '../../utils';
import { BACKGROUND_VER, ENCODING, VERSION } from '../../utils/constants';
import { vscode } from '../../utils/vsc';

export enum EFilePatchType {
Expand Down
2 changes: 1 addition & 1 deletion src/background/PatchFile/PatchFile.javascript.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BACKGROUND_VER, VERSION } from '../../constants';
import { BACKGROUND_VER, VERSION } from '../../utils/constants';
import { AbsPatchFile } from './PatchFile.base';

// vscode-background-start background.ver.2.0.0
Expand Down
8 changes: 0 additions & 8 deletions src/constants/defBase64.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/constants/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import vscode from 'vscode';

import { Background } from './background';
import { EXTENSION_ID } from './constants';
import { EXTENSION_ID } from './utils/constants';
import { vsHelp } from './utils/vsHelp';

// this method is called when your extension is activated
Expand Down
2 changes: 1 addition & 1 deletion src/uninstall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import fs from 'fs';

import { JsPatchFile } from './background/PatchFile/PatchFile.javascript';
import { ENCODING, TOUCH_JSFILE_PATH } from './constants';
import { ENCODING, TOUCH_JSFILE_PATH } from './utils/constants';

async function uninstall() {
try {
Expand Down
File renamed without changes.
93 changes: 89 additions & 4 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,89 @@
// export * from './vsc'; // 兼容性文件需要单独导出使用
// export * from './vscodePath';
export * from './utils';
// export * from './vsHelp';
import sudo from '@vscode/sudo-prompt';
import lockfile from 'lockfile';

import { LOCK_PATH } from './constants';

export namespace utils {
/**
* 等待若干时间
*
* @export
* @param {number} [delay=0]
* @return {*}
*/
export function sleep(delay = 0) {
return new Promise<void>(resolve => {
setTimeout(resolve, delay);
});
}

/**
* 添加文件锁
*
* @export
* @return {*}
*/
export function lock() {
return new Promise<void>((resolve, reject) => {
lockfile.lock(
LOCK_PATH,
{
wait: 5000 // 应该能撑200的并发了,,,>_<#@!
},
err => {
if (err) {
return reject(err);
}
resolve();
}
);
});
}

/**
* 取消文件锁
*
* @export
* @return {*}
*/
export function unlock() {
return new Promise<void>((resolve, reject) => {
lockfile.unlock(LOCK_PATH, err => {
if (err) {
return reject(err);
}
resolve();
});
});
}

/**
* 提权运行
*
* @export
* @param {string} cmd
* @param {{ name?: string }} [options={}]
* @return {*} {Promise<any>}
*/
export function sudoExec(cmd: string, options: { name?: string } = {}): Promise<any> {
return new Promise((resolve, reject) => {
sudo.exec(cmd, options, (error?: Error, stdout?: string | Buffer, stderr?: string | Buffer) => {
if (error) {
reject(error);
}
resolve([stdout, stderr]);
});
});
}

/**
* wrap with IIFE
*
* @export
* @param {string} source
* @return {*}
*/
export function withIIFE(source: string) {
return `;(function() { ${source} })();`;
}
}
Loading

0 comments on commit 13a0c9a

Please sign in to comment.