vscode-live2d icon indicating copy to clipboard operation
vscode-live2d copied to clipboard

安装后重启vscode 无法打开

Open ZyGitZy opened this issue 2 years ago • 4 comments

插件安装后再次打开vscode的时候 vscode就打不开了 vscode版本1.79.2

ZyGitZy avatar Jun 27 '23 06:06 ZyGitZy

注意下面更改后每次在vscode中设置live2d的配置的时候他会覆盖html的内容 所以将修改后的html复制下来,每次修改配置后去替换一下html就好了 其他的不用动 (live2d的配置有修改高度,修改板娘等等....他都会还原他html的内容导致vscode打不开,打不开原因是js报错) workbench.html路径 安装目录\Microsoft VS Code\resources\app\out\vs\code\electron-sandbox\workbench 需要管理员打开vscode

更改workbench.html body中加入 <div id="waifu" style="position: absolute; right: 20px; bottom: 20px; opacity: 1; transition: opacity 300ms ease-in-out; pointer-events: none"> <div id="waifu-tips" style="transform: translateX(-50%) scale(1);position:relative;top:15rem"></div><canvas id="live2d" width="280" height="650"></canvas></div>

添加scrtip引用 `

`

添加css引用 <link src="./live2d/waifu.css"></link> meta 标签中移除 require-trusted-types-for 'script' 移除 <script src="../../../../bootstrap.js"></script> <script src="../../../../vs/loader.js"></script> <script src="../../../../bootstrap-window.js"></script> 这三个js的引用 保留 workbench.js script 的引用

删除 workbench.js中 live2d的js内容 `//# sourceMappingURL=https://ticino.blob.core.windows.net/sourcemaps/695af097c7bd098fbf017ce3ac85e09bbc5dda06/core/vs/code/electron-sandbox/workbench/workbench.js.map /ext-vscode-live2d-start/ /ext.vscode-live2d.ver.1.8.1/ function addElement(elementName, src) { var tempDom = document.createElement(elementName); tempDom.src = src; tempDom.href = src; tempDom.rel = 'stylesheet'; document.body.appendChild(tempDom); return new Promise(resolve => { tempDom.onload = res => { setTimeout(resolve, 0, res); }; }); } var tempDiv = document.createElement('div'); tempDiv.innerHTML = '

'; var waifu = document.body.appendChild(tempDiv.children[0]);
if (false) {
	// 用 waifu 上的鼠标事件来做,无法同时实现穿透效果,算坐标是最简单的方案
	var tid, flag;
	document.body.addEventListener("mousemove", function(e) {
		var _pointerOverHidden = () => {
			var cursorX = e.clientX;
			var cursorY = e.clientY;
			var minX = waifu.offsetLeft;
			var maxX = minX + waifu.clientWidth;
			var minY = waifu.offsetTop;
			var maxY = minY + waifu.clientHeight;
			if (cursorX >= minX && cursorX <= maxX && cursorY >= minY && cursorY <= maxY) {
				if (!waifu.over) {
					waifu.style.opacity = '0';
					waifu.over = true
				}
			} else {
				if (waifu.over) {
					waifu.style.opacity = '1';
					waifu.over = false
				}
			}
		}

		// 实现一个简单的 throttle 来降低开销
		if (!tid) {
			if (!flag) {
				_pointerOverHidden();
			}
			tid = setTimeout(() => {
				clearTimeout(tid);
				tid = null;
				if (flag) {
					_pointerOverHidden();
					flag = false;
				}
			}, 300);
		} else {
			flag = true;
		}
	});
}

addElement('link', './live2d/waifu.css');
addElement('script', './live2d/live2d.js')
	.then(() => addElement('script', './live2d/message.js'))
	.then(() => {
		loadlive2d(
			'live2d', 
			'./models/shizuku/index.json'
			);
		});
/*ext-vscode-live2d-end*/`

ZyGitZy avatar Jun 27 '23 09:06 ZyGitZy

我也是安装了以后vscode就打不开了,按照您的步骤走了一遍,还是不行

airuikun avatar Aug 02 '23 06:08 airuikun

或者直接删掉 loader.js的引用也行 Microsoft VS Code\resources\app\out\vs\code\electron-sandbox\workbench\workbench.html

ZyGitZy avatar Aug 02 '23 06:08 ZyGitZy

可以,有用

KDR622 avatar Sep 11 '23 09:09 KDR622