Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>游戏300之坦克大战New to Visual Studio Code? Get it now.
游戏300之坦克大战

游戏300之坦克大战

onions

|
4,192 installs
| (1) | Free
她不是漂不漂亮的问题!她真的是那种……那种很少见的那种 懂我意思吧!
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

tank大战

  1. tank 大战游戏来源: github 地址

  2. 本项目游戏源码来自上述地址,不涉及任何商业用途。

vscode: webview + iframe + 读取本地文件 + 一些配置

核心代码:

const vscode = require('vscode')
const path = require('path')

/**
 * @param {vscode.ExtensionContext} context
 */
function activate(context) {

	const onDiskPath = vscode.Uri.file(
		path.join(context.extensionPath, 'tank', 'index.html')
	)

	let disposable = vscode.commands.registerCommand('wc.tank', function () {
	
		const panel = vscode.window.createWebviewPanel(
			'你在搞毛',
			'坦克大战不是吧不是吧!',
			vscode.ViewColumn.One, // web view 显示位置
			{
				enableScripts: true, // 允许 JavaScript
				retainContextWhenHidden: true, // 在 hidden 的时候保持不关闭
				localResourceRoots: [
					vscode.Uri.file(path.join(context.extensionPath, 'tank'))
				]
			}
		)
		// 读取本地文件
		const catPicSrc = panel.webview.asWebviewUri(onDiskPath)
		panel.webview.html = getWebViewContent(catPicSrc)

	});

	context.subscriptions.push(disposable);
}
exports.activate = activate;

function deactivate() {}

module.exports = {
	activate,
	deactivate
}


function getWebViewContent(src) {
	return `<!DOCTYPE html>
  <html lang="en">
	<head>
	  <meta charset="UTF-8" />
	  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
	  <meta http-equiv="X-UA-Compatible" content="ie=edge" />
	  <title>我是真的😡</title>
	</head>
	<body>
	  <iframe src=${src} width="700" height="700" />
	</body>
  </html>
	`;
  }
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft