diff --git a/CHANGELOG.md b/CHANGELOG.md index fbdf124..cfde771 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -108,4 +108,8 @@ 3.社区支持注册(需邮箱激活) 4.社区支持回复主题,上传图片、添加第三方图片(用于设置背景图) 5.社区支持发布个人主题(私人图库)(需要作者审核) - 6.修复开启自动更换的异常 (2.5.1/2024.05.27) \ No newline at end of file + 6.修复开启自动更换的异常 (2.5.1/2024.05.27) + +#### ver 2.5.2 (2024/06/24) + + 1.修复图片无法显示的bug \ No newline at end of file diff --git a/README.md b/README.md index ca90499..f6b83a3 100644 --- a/README.md +++ b/README.md @@ -112,15 +112,10 @@ Add a picture you like to cover the entire vscode.. ## 最近更新日志 [完整日志](https://github.com/vscode-extension/vscode-background-cover/blob/master/CHANGELOG.md) -#### ver 2.5.0 (2024/05/26) - - 1.支持在线图片快速设置背景!!! - 2.在线社区集成进vscode左侧栏,发布图片、设置默认页 - 3.社区支持注册(需邮箱激活) - 4.社区支持回复主题,上传图片、添加第三方图片(用于设置背景图) - 5.社区支持发布个人主题(私人图库)(需要作者审核) - 6.修复开启自动更换的异常 (2.5.1/2024.05.27) - +#### ver 2.5.2 (2024/06/24) + + 1.修复图片无法显示的bug + --- ### Thanks 感谢 diff --git a/package-lock.json b/package-lock.json index 0d0cfd4..4c5f57a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "background-cover", - "version": "2.5.1", + "version": "2.5.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "background-cover", - "version": "2.5.1", + "version": "2.5.2", "license": "ISC", "devDependencies": { "@types/mocha": "^5.2.7", diff --git a/package.json b/package.json index bc3d032..3647802 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "background-cover", "displayName": "background-cover", "description": "Add a picture you like to cover the entire vscode..", - "version": "2.5.1", + "version": "2.5.2", "publisher": "manasxx", "engines": { "vscode": "^1.38.0" diff --git a/resources/support.jpg b/resources/support.jpg index d3f2a26..46bbaaa 100644 Binary files a/resources/support.jpg and b/resources/support.jpg differ diff --git a/src/FileDom.ts b/src/FileDom.ts index e69a439..da9d3c0 100644 --- a/src/FileDom.ts +++ b/src/FileDom.ts @@ -28,6 +28,9 @@ export class FileDom { sizeModel = "cover"; } this.sizeModel = sizeModel; + if(imagePath.substr(0, 8).toLowerCase() !== 'https://'){ + this.localImgToVsc(); + } } @@ -144,7 +147,7 @@ export class FileDom { } - public localImgToVsc() { + private localImgToVsc() { var url = "vscode-file://vscode-app/" + this.imagePath this.imagePath = Uri.parse(url).toString(); } diff --git a/src/PickLIst.ts b/src/PickLIst.ts index 20a2f02..68c86db 100644 --- a/src/PickLIst.ts +++ b/src/PickLIst.ts @@ -14,7 +14,7 @@ import { extensions, InputBoxOptions, ConfigurationTarget, - } from 'vscode'; +} from 'vscode'; import { FileDom } from './FileDom'; import { ImgItem } from './ImgItem'; @@ -42,7 +42,7 @@ export class PickList { private imageFileType: number; // 当前系统标识 - private osType: number; + private osType: number; // 当前配置的背景图尺寸模式 private sizeModel: string; @@ -50,7 +50,7 @@ export class PickList { // 初始下拉列表 public static createItemLIst() { let config: WorkspaceConfiguration = - workspace.getConfiguration('backgroundCover'); + workspace.getConfiguration( 'backgroundCover' ); let list: QuickPick = window.createQuickPick(); list.placeholder = 'Please choose configuration! / 请选择相关配置!'; @@ -87,18 +87,18 @@ export class PickList { imageType: 7 }, ]; - if (config.autoStatus) { - items.push({ + if ( config.autoStatus ) { + items.push( { label: '$(sync) OFF Start Replacement ', description: '关闭启动自动更换', imageType: 10 - }) + } ) } else { - items.push({ + items.push( { label: '$(sync) ON Start Replacement ', description: '开启启动自动更换', imageType: 11 - }) + } ) } // 更多 items.push( @@ -117,37 +117,36 @@ export class PickList { label: '$(heart) Support ', description: '请作者喝一杯咖啡吧~ ', imageType: 14, - path : "//resources//support.jpg" + path: "//resources//support.jpg" }, { label: '$(organization) Wechat ', description: '微信群聊~ ', imageType: 14, - path : "//resources//wx.jpg" + path: "//resources//wx.jpg" }, { label: '$(ports-open-browser-icon) Online images ', description: '在线图库', imageType: 17, - path : "https://vs.20988.xyz/d/24-bei-jing-tu-tu-ku" + path: "https://vs.20988.xyz/d/24-bei-jing-tu-tu-ku" } ) list.items = items; list.title = "背景图设置"; - - PickList.itemList = new PickList(config, list); + + PickList.itemList = new PickList( config, list ); } /** * 自动更新背景 */ public static autoUpdateBackground() { - let config = workspace.getConfiguration('backgroundCover'); - if (!config.randomImageFolder || !config.autoStatus) { + let config = workspace.getConfiguration( 'backgroundCover' ); + if ( !config.randomImageFolder || !config.autoStatus ) { return false; } - PickList.itemList = new PickList(config); - PickList.itemList.imageFileType = 1; + PickList.itemList = new PickList( config ); PickList.itemList.autoUpdateBackground(); return PickList.itemList = undefined; } @@ -156,47 +155,43 @@ export class PickList { * 随机更新一张背景 */ public static randomUpdateBackground() { - let config = workspace.getConfiguration('backgroundCover'); - if (!config.randomImageFolder) { + let config = workspace.getConfiguration( 'backgroundCover' ); + if ( !config.randomImageFolder ) { window.showWarningMessage( - 'Please add a directory! / 请添加目录!'); + 'Please add a directory! / 请添加目录!' ); return false; } - PickList.itemList = new PickList(config); - PickList.itemList.imageFileType = 1; + PickList.itemList = new PickList( config ); PickList.itemList.autoUpdateBackground(); PickList.itemList = undefined; - return commands.executeCommand('workbench.action.reloadWindow'); + return commands.executeCommand( 'workbench.action.reloadWindow' ); } - public static updateImgPath(path:string) { + public static updateImgPath( path: string ) { // 检测图片地址格式 - let isUrl = (path.substr(0, 8).toLowerCase() === 'https://'); - if(!isUrl){ - vsHelp.showInfo("非https格式图片,不支持配置! / Non HTTPS format image, configuration not supported!") + let isUrl = ( path.substr( 0, 8 ).toLowerCase() === 'https://' ); + if ( !isUrl ) { + vsHelp.showInfo( "非https格式图片,不支持配置! / Non HTTPS format image, configuration not supported!" ) return false } - let config = workspace.getConfiguration('backgroundCover'); - PickList.itemList = new PickList(config); - PickList.itemList.imageFileType = 2; - PickList.itemList.updateBackgound(path); + let config = workspace.getConfiguration( 'backgroundCover' ); + PickList.itemList = new PickList( config ); + PickList.itemList.setImageFileType( 2 ); + PickList.itemList.updateBackgound( path ); } // 列表构造方法 private constructor( config: WorkspaceConfiguration, - pickList?: QuickPick) { - this.config = config; - this.imgPath = config.imagePath; - this.opacity = config.opacity; - this.sizeModel = config.sizeModel || 'cover'; - // imgPath是否为https - this.imageFileType = 1; - if(this.imgPath.substr(0, 8).toLowerCase() === 'https://'){ - this.imageFileType = 2; - } + pickList?: QuickPick ) { + this.config = config; + this.imgPath = config.imagePath; + this.opacity = config.opacity; + this.sizeModel = config.sizeModel || 'cover'; + this.imageFileType = 0; + - switch (os.type()) { + switch ( os.type() ) { case 'Windows_NT': this.osType = 1; break; @@ -211,60 +206,60 @@ export class PickList { break } - if (pickList) { + if ( pickList ) { this.quickPick = pickList; this.quickPick.onDidAccept( - (e: any) => this.listChange( + ( e: any ) => this.listChange( this.quickPick.selectedItems[0].imageType, - this.quickPick.selectedItems[0].path)); - this.quickPick.onDidHide(() => { + this.quickPick.selectedItems[0].path ) ); + this.quickPick.onDidHide( () => { this.dispose(); - }, null, this._disposables); + }, null, this._disposables ); this.quickPick.show(); } } // 列表点击事件分配 - private listChange(type: number, path?: string) { - switch (type) { + private listChange( type: number, path?: string ) { + switch ( type ) { case 1: this.imgList(); // 展示图片列表 break; case 2: - this.openFieldDialog(2); // 弹出选择文件夹对话框 + this.openFieldDialog( 2 ); // 弹出选择文件夹对话框 break; case 3: - this.openFieldDialog(1); // 弹出选择图片文件对话框 + this.openFieldDialog( 1 ); // 弹出选择图片文件对话框 break; case 4: - this.updateBackgound(path); // 选择列表内图片,更新背景css + this.updateBackgound( path ); // 选择列表内图片,更新背景css break; case 5: - this.showInputBox(2); // 更改透明度 + this.showInputBox( 2 ); // 更改透明度 break; case 6: - this.showInputBox(1); // 输入图片路径更新背景 + this.showInputBox( 1 ); // 输入图片路径更新背景 break; case 7: - this.updateDom(true); // 关闭背景图片展示 + this.updateDom( true ); // 关闭背景图片展示 break; case 8: commands.executeCommand( - 'workbench.action.reloadWindow'); // 重新加载窗口,使设置生效 + 'workbench.action.reloadWindow' ); // 重新加载窗口,使设置生效 break; case 9: this.quickPick.hide(); // 隐藏设置弹窗 break; case 10: - this.setConfigValue('autoStatus', false, false); + this.setConfigValue( 'autoStatus', false, false ); this.quickPick.hide(); break; case 11: - if (!this.config.randomImageFolder) { + if ( !this.config.randomImageFolder ) { window.showWarningMessage( - 'Please add a directory! / 请添加目录后再来开启!'); + 'Please add a directory! / 请添加目录后再来开启!' ); } else { - this.setConfigValue('autoStatus', true, false); + this.setConfigValue( 'autoStatus', true, false ); this.autoUpdateBackground(); } this.quickPick.hide(); @@ -273,68 +268,68 @@ export class PickList { this.moreMenu(); break; case 13: - this.gotoPath(path); + this.gotoPath( path ); break; case 14: - PickList.gotoFilePath(path); + PickList.gotoFilePath( path ); break; case 15: this.sizeModelView(); break; case 16: - this.setSizeModel(path); + this.setSizeModel( path ); break; case 17: // 打开viewsContainers - commands.executeCommand('workbench.view.extension.backgroundCover-explorer'); + commands.executeCommand( 'workbench.view.extension.backgroundCover-explorer' ); break; default: break; } } - private gotoPath(path?: string){ - if (path == undefined){ - return window.showWarningMessage('无效菜单'); + private gotoPath( path?: string ) { + if ( path == undefined ) { + return window.showWarningMessage( '无效菜单' ); } - let tmpUri : string = path - - env.openExternal(Uri.parse(tmpUri)) + let tmpUri: string = path + + env.openExternal( Uri.parse( tmpUri ) ) } - public static gotoFilePath(path?: string){ - if (path == undefined){ - return window.showWarningMessage('无效菜单'); + public static gotoFilePath( path?: string ) { + if ( path == undefined ) { + return window.showWarningMessage( '无效菜单' ); } - let tmpUri : string = path - let extPath = extensions.getExtension("manasxx.background-cover")?.extensionPath - let tmpPath = "file:///"+extPath+tmpUri - let tmpurl = Uri.parse(tmpPath) - - commands.executeCommand('openFolder', tmpurl); + let tmpUri: string = path + let extPath = extensions.getExtension( "manasxx.background-cover" )?.extensionPath + let tmpPath = "file:///" + extPath + tmpUri + let tmpurl = Uri.parse( tmpPath ) + + commands.executeCommand( 'openFolder', tmpurl ); } - private moreMenu(){ + private moreMenu() { let items: ImgItem[] = [ { label: '$(github) Repository ', description: '仓库地址', imageType: 13, - path : "https://github.com/AShujiao/vscode-background-cover" + path: "https://github.com/AShujiao/vscode-background-cover" }, { label: '$(issues) Issues ', description: '有疑问就来提问', imageType: 13, - path : "https://github.com/AShujiao/vscode-background-cover/issues" + path: "https://github.com/AShujiao/vscode-background-cover/issues" }, { label: '$(star) Star ', description: '给作者点个Star吧', imageType: 13, - path : "https://github.com/AShujiao/vscode-background-cover" + path: "https://github.com/AShujiao/vscode-background-cover" } ]; @@ -342,67 +337,67 @@ export class PickList { this.quickPick.show(); } - private sizeModelView(){ + private sizeModelView() { let items: ImgItem[] = [ { label: '$(diff-ignored) cover (default) ', - description: '填充(默认) ' + (this.sizeModel == 'cover' ? '$(check)' : ''), + description: '填充(默认) ' + ( this.sizeModel == 'cover' ? '$(check)' : '' ), imageType: 16, - path : "cover" + path: "cover" }, { label: '$(layout-menubar) repeat ', - description: '平铺' + (this.sizeModel == 'repeat' ? '$(check)' : ''), + description: '平铺' + ( this.sizeModel == 'repeat' ? '$(check)' : '' ), imageType: 16, - path : "repeat" + path: "repeat" }, { label: '$(diff-added) contain ', - description: '拉伸' + (this.sizeModel == 'contain' ? '$(check)' : ''), + description: '拉伸' + ( this.sizeModel == 'contain' ? '$(check)' : '' ), imageType: 16, - path : "contain" + path: "contain" }, { label: '$(diff-modified) not(center) ', - description: '无适应(居中)' + (this.sizeModel == 'not_center' ? '$(check)' : ''), + description: '无适应(居中)' + ( this.sizeModel == 'not_center' ? '$(check)' : '' ), imageType: 16, - path : "not_center" + path: "not_center" }, { label: '$(layout) not(right_bottom) ', - description: '无适应(右下角)' + (this.sizeModel == 'not_right_bottom' ? '$(check)' : ''), + description: '无适应(右下角)' + ( this.sizeModel == 'not_right_bottom' ? '$(check)' : '' ), imageType: 16, - path : "not_right_bottom" + path: "not_right_bottom" }, { label: '$(layout) not(right_top) ', - description: '无适应(右上角)' + (this.sizeModel == 'not_right_top' ? '$(check)' : ''), + description: '无适应(右上角)' + ( this.sizeModel == 'not_right_top' ? '$(check)' : '' ), imageType: 16, - path : "not_right_top" + path: "not_right_top" }, { label: '$(layout) not(left) ', - description: '无适应(靠左)' + (this.sizeModel == 'not_left' ? '$(check)' : ''), + description: '无适应(靠左)' + ( this.sizeModel == 'not_left' ? '$(check)' : '' ), imageType: 16, - path : "not_left" + path: "not_left" }, { label: '$(layout) not(right) ', - description: '无适应(靠右)' + (this.sizeModel == 'not_right' ? '$(check)' : ''), + description: '无适应(靠右)' + ( this.sizeModel == 'not_right' ? '$(check)' : '' ), imageType: 16, - path : "not_right" + path: "not_right" }, { label: '$(layout) not(top) ', - description: '无适应(靠上)' + (this.sizeModel == 'not_top' ? '$(check)' : ''), + description: '无适应(靠上)' + ( this.sizeModel == 'not_top' ? '$(check)' : '' ), imageType: 16, - path : "not_top" + path: "not_top" }, { label: '$(layout) not(bottom) ', - description: '无适应(靠下)' + (this.sizeModel == 'not_bottom' ? '$(check)' : ''), + description: '无适应(靠下)' + ( this.sizeModel == 'not_bottom' ? '$(check)' : '' ), imageType: 16, - path : "not_bottom" + path: "not_bottom" }, ]; @@ -416,9 +411,9 @@ export class PickList { // Clean up our resources this.quickPick.hide(); - while (this._disposables.length) { + while ( this._disposables.length ) { const x = this._disposables.pop(); - if (x) { + if ( x ) { x.dispose(); } } @@ -428,23 +423,23 @@ export class PickList { * 启动时自动更新背景 */ private autoUpdateBackground() { - if (this.checkFolder(this.config.randomImageFolder)) { + if ( this.checkFolder( this.config.randomImageFolder ) ) { // 获取目录下的所有图片 let files: string[] = - this.getFolderImgList(this.config.randomImageFolder); + this.getFolderImgList( this.config.randomImageFolder ); // 是否存在图片 - if (files.length > 0) { + if ( files.length > 0 ) { // 获取一个随机路径存入数组中 - let randomFile = files[Math.floor(Math.random() * files.length)]; - let file = path.join(this.config.randomImageFolder, randomFile); - this.listChange(4, file); + let randomFile = files[Math.floor( Math.random() * files.length )]; + let file = path.join( this.config.randomImageFolder, randomFile ); + this.listChange( 4, file ); } } return true; } // 根据图片目录展示图片列表 - private imgList(folderPath?: string) { + private imgList( folderPath?: string ) { let items: ImgItem[] = [{ label: '$(diff-added) Manual selection', description: '选择一张背景图', @@ -453,27 +448,27 @@ export class PickList { let randomPath: any = folderPath ? folderPath : this.config.randomImageFolder; - if (this.checkFolder(randomPath)) { + if ( this.checkFolder( randomPath ) ) { // 获取目录下的所有图片 - let files: string[] = this.getFolderImgList(randomPath); + let files: string[] = this.getFolderImgList( randomPath ); // 是否存在图片 - if (files.length > 0) { + if ( files.length > 0 ) { // 获取一个随机路径存入数组中 - let randomFile = files[Math.floor(Math.random() * files.length)]; - items.push({ + let randomFile = files[Math.floor( Math.random() * files.length )]; + items.push( { label: '$(light-bulb) Random pictures', description: '随机自动选择 ctrl+shift+F7', imageType: 4, - path: path.join(randomPath, randomFile) - }); - items.push({ + path: path.join( randomPath, randomFile ) + } ); + items.push( { label: '', description: '', imageType: 0, kind: QuickPickItemKind.Separator - }); - items = items.concat(files.map( - (e) => new ImgItem('$(tag) ' + e, e, 4, path.join(randomPath, e)))); + } ); + items = items.concat( files.map( + ( e ) => new ImgItem( '$(tag) ' + e, e, 4, path.join( randomPath, e ) ) ) ); } } @@ -485,34 +480,34 @@ export class PickList { * 获取目录下的所有图片 * @param pathUrl */ - private getFolderImgList(pathUrl: string): string[] { - if (!pathUrl || pathUrl === '') { + private getFolderImgList( pathUrl: string ): string[] { + if ( !pathUrl || pathUrl === '' ) { return []; } // 获取目录下的所有图片 - let files: string[] = fs.readdirSync(path.resolve(pathUrl)).filter((s) => { - return s.endsWith('.png') || s.endsWith('.PNG') || s.endsWith('.jpg') || s.endsWith('.JPG') - || s.endsWith('.jpeg') || s.endsWith('.gif') || s.endsWith('.webp') || s.endsWith('.bmp') - || s.endsWith('.jfif'); - }); + let files: string[] = fs.readdirSync( path.resolve( pathUrl ) ).filter( ( s ) => { + return s.endsWith( '.png' ) || s.endsWith( '.PNG' ) || s.endsWith( '.jpg' ) || s.endsWith( '.JPG' ) + || s.endsWith( '.jpeg' ) || s.endsWith( '.gif' ) || s.endsWith( '.webp' ) || s.endsWith( '.bmp' ) + || s.endsWith( '.jfif' ); + } ); return files; } // 检查选择的文件及目录是否正确 - private checkFolder(folderPath: string) { - if (!folderPath) { + private checkFolder( folderPath: string ) { + if ( !folderPath ) { return false; } // 判断路径是否存在 - let fsStatus = fs.existsSync(path.resolve(folderPath)); - if (!fsStatus) { + let fsStatus = fs.existsSync( path.resolve( folderPath ) ); + if ( !fsStatus ) { return false; } // 判断是否为目录路径 - let stat = fs.statSync(folderPath); - if (!stat.isDirectory()) { + let stat = fs.statSync( folderPath ); + if ( !stat.isDirectory() ) { return false; } @@ -520,8 +515,8 @@ export class PickList { } // 创建一个输入框 - private showInputBox(type: number) { - if (type <= 0 || type > 2) { return false; } + private showInputBox( type: number ) { + if ( type <= 0 || type > 2 ) { return false; } let placeString = type === 2 ? 'Opacity ranges:0.00 - 1,current:(' + this.opacity + ')' : @@ -537,89 +532,90 @@ export class PickList { prompt: promptString }; - window.showInputBox(option).then(value => { + window.showInputBox( option ).then( value => { //未输入值返回false - if (!value) { + if ( !value ) { window.showWarningMessage( - 'Please enter configuration parameters / 请输入配置参数!'); + 'Please enter configuration parameters / 请输入配置参数!' ); return; } - if (type === 1) { + if ( type === 1 ) { // 判断路径是否存在 - let fsStatus = fs.existsSync(path.resolve(value)); - let isUrl = (value.substr(0, 8).toLowerCase() === 'https://'); - if (!fsStatus && !isUrl) { + let fsStatus = fs.existsSync( path.resolve( value ) ); + let isUrl = ( value.substr( 0, 8 ).toLowerCase() === 'https://' ); + if ( !fsStatus && !isUrl ) { window.showWarningMessage( - 'No access to the file or the file does not exist! / 无权限访问文件或文件不存在!'); + 'No access to the file or the file does not exist! / 无权限访问文件或文件不存在!' ); return false; } - // 如果为https连接图片,则更新图片类型 - if(isUrl){ - this.imageFileType = 2; - } } else { - let isOpacity = parseFloat(value); + let isOpacity = parseFloat( value ); - if (isOpacity < 0 || isOpacity > 1 || isNaN(isOpacity)) { - window.showWarningMessage('Opacity ranges in:0 - 1!'); + if ( isOpacity < 0 || isOpacity > 1 || isNaN( isOpacity ) ) { + window.showWarningMessage( 'Opacity ranges in:0 - 1!' ); return false; } } this.setConfigValue( - (type === 1 ? 'imagePath' : 'opacity'), - (type === 1 ? value : parseFloat(value)), true); - }) + ( type === 1 ? 'imagePath' : 'opacity' ), + ( type === 1 ? value : parseFloat( value ) ), true ); + } ) } - private setSizeModel(value?: string){ - if (!value) { - return vsHelp.showInfo('No parameter value was obtained / 未获取到参数值'); + private setSizeModel( value?: string ) { + if ( !value ) { + return vsHelp.showInfo( 'No parameter value was obtained / 未获取到参数值' ); } - this.setConfigValue('sizeModel', value, true); + this.setConfigValue( 'sizeModel', value, true ); + } + + public setImageFileType( value: number ) { + this.imageFileType = value; + } // 更新配置 - public updateBackgound(path?: string) { - if (!path) { - return vsHelp.showInfo('Unfetched Picture Path / 未获取到图片路径'); + public updateBackgound( path?: string ) { + if ( !path ) { + return vsHelp.showInfo( 'Unfetched Picture Path / 未获取到图片路径' ); } - this.setConfigValue('imagePath', path); + this.setConfigValue( 'imagePath', path ); } // 文件、目录选择 - private async openFieldDialog(type: number) { + private async openFieldDialog( type: number ) { let isFolders = type === 1 ? false : true; let isFiles = type === 2 ? false : true; let filters = - type === 1 ? { 'Images': ['png', 'jpg', 'gif', 'jpeg','jfif'] } : undefined; - let folderUris = await window.showOpenDialog({ + type === 1 ? { 'Images': ['png', 'jpg', 'gif', 'jpeg', 'jfif'] } : undefined; + let folderUris = await window.showOpenDialog( { canSelectFolders: isFolders, canSelectFiles: isFiles, canSelectMany: false, openLabel: 'Select folder', filters: filters - }); - if (!folderUris) { + } ); + if ( !folderUris ) { return false; } let fileUri = folderUris[0]; - if (type === 2) { - this.setConfigValue('randomImageFolder', fileUri.fsPath, false); - return this.imgList(fileUri.fsPath); + if ( type === 2 ) { + this.setConfigValue( 'randomImageFolder', fileUri.fsPath, false ); + return this.imgList( fileUri.fsPath ); } - if (type === 1) { - return this.setConfigValue('imagePath', fileUri.fsPath); + if ( type === 1 ) { + return this.setConfigValue( 'imagePath', fileUri.fsPath ); } return false; } // 更新配置 - private setConfigValue(name: string, value: any, updateDom: Boolean = true) { + private setConfigValue( name: string, value: any, updateDom: Boolean = true ) { // 更新变量 - this.config.update(name, value, ConfigurationTarget.Global); - switch (name) { + this.config.update( name, value, ConfigurationTarget.Global ); + switch ( name ) { case 'opacity': this.opacity = value; break; @@ -633,7 +629,7 @@ export class PickList { break; } // 是否需要更新Dom - if (updateDom) { + if ( updateDom ) { this.updateDom(); } return true; @@ -641,26 +637,22 @@ export class PickList { // 更新、卸载css - private updateDom(uninstall: boolean = false) { - let dom: FileDom = new FileDom(this.imgPath, this.opacity, this.sizeModel); + private updateDom( uninstall: boolean = false ) { + let dom: FileDom = new FileDom( this.imgPath, this.opacity, this.sizeModel ); let result = false; - if (uninstall) { + if ( uninstall ) { result = dom.uninstall(); } else { - // 是否需要转base64 - if(this.imageFileType == 1){ - dom.localImgToVsc(); - } - if (this.osType === 1) { + if ( this.osType === 1 ) { result = dom.install(); - } else if (this.osType === 2) { + } else if ( this.osType === 2 ) { result = dom.installMac(); - } else if (this.osType === 3) { + } else if ( this.osType === 3 ) { result = dom.install(); // 暂未做对应处理 } } - if (result) { - if(this.quickPick){ + if ( result ) { + if ( this.quickPick ) { this.quickPick.placeholder = 'Reloading takes effect? / 重新加载生效?'; this.quickPick.items = [ { @@ -672,22 +664,22 @@ export class PickList { ]; this.quickPick.ignoreFocusOut = true; this.quickPick.show(); - }else{ + } else { // 通过在线图库更新提示弹窗 - if(this.imageFileType == 2){ + if ( this.imageFileType == 2 ) { // 弹出提示框确认是否重启 window.showInformationMessage( - '"' + this.imgPath + '"' + ' | Reloading takes effect? / 重新加载生效?', 'YES', 'NO').then( - (value) => { - if (value === 'YES') { + '"' + this.imgPath + '"' + ' | Reloading takes effect? / 重新加载生效?', 'YES', 'NO' ).then( + ( value ) => { + if ( value === 'YES' ) { commands.executeCommand( - 'workbench.action.reloadWindow'); + 'workbench.action.reloadWindow' ); } - }); + } ); } } - + } } } \ No newline at end of file diff --git a/src/extension.ts b/src/extension.ts index e77a850..e4d9c37 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -46,7 +46,7 @@ export function activate(context: ExtensionContext) { let title:string = ex ? ex.packageJSON['one_title'] : ''; if(openVersion != version && title != ""){ context.globalState.update('ext_version',version); - vsHelp.showWebview('🐷已更新到2.5.1:集成在线图库 --- 🐷\r🐶🐷🐔🦊立即体验!!🐯🐮🐹🐽❓'); + vsHelp.showWebview('🐷已更新到2.5.2:修复图片无法显示的问题 --- 🐷\r🐶🐷🐔🦊立即体验!!🐯🐮🐹🐽❓'); } setContext(context); } diff --git a/src/version.ts b/src/version.ts index 5eb31aa..f6719cd 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export default '2.5.1'; \ No newline at end of file +export default '2.5.2'; \ No newline at end of file