Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

安装后重启vscode 无法打开 #37

Open
ZyGitZy opened this issue Jun 27, 2023 · 4 comments
Open

安装后重启vscode 无法打开 #37

ZyGitZy opened this issue Jun 27, 2023 · 4 comments

Comments

@ZyGitZy
Copy link

ZyGitZy commented Jun 27, 2023

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

@ZyGitZy
Copy link
Author

ZyGitZy commented Jun 27, 2023

注意下面更改后每次在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引用
`<script src="./live2d/live2d.js"></script>

<script src="./live2d/message.js"></script>`

添加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*/`

@airuikun
Copy link

airuikun commented Aug 2, 2023

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

@ZyGitZy
Copy link
Author

ZyGitZy commented Aug 2, 2023

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

@KDR622
Copy link

KDR622 commented Sep 11, 2023

可以,有用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants