From 6e70ce0e109ac6f9f705afca323a58e2dfdbfd9a Mon Sep 17 00:00:00 2001 From: wangxiaofeng01 Date: Fri, 8 Mar 2024 15:18:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=89=E5=8F=96ui=E6=A8=A1=E6=9D=BF,=20?= =?UTF-8?q?=E8=A7=A3=E5=8E=8B=E5=88=B0=20=E5=B7=A5=E7=A8=8B=E6=96=87?= =?UTF-8?q?=E4=BB=B6/ui=5Fplugin=20=E6=96=87=E4=BB=B6=E5=A4=B9=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/extension.ts | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/extension.ts b/src/extension.ts index 78c9fc1..dd0a7c5 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -3,6 +3,9 @@ import { runShell } from './runShell'; import { LuaDocMaker } from './makeLuaDoc'; import { Env } from './env'; import { GameLauncher } from './launchGame'; +import * as https from 'https'; +import * as JSZip from 'jszip'; +import * as fs from 'fs'; class Helper { private context: vscode.ExtensionContext; @@ -40,6 +43,37 @@ class Helper { let scriptUri = this.env.scriptUri!; let y3Uri = this.env.y3Uri!; + let ui_path = vscode.Uri.joinPath(this.env.projectUri!, 'ui_plugin'); + await https.get('https://up5.nosdn.127.net/editor/zip/edc461b312fc308779be9273a2cee6bb', (resp) => { + // 收到数据 + const chunks: any[] = []; + resp.on('data', (chunk) => { + chunks.push(chunk); + }); + // 数据接收完毧 + resp.on('end', () => { + // 将所有数据块拼接在一起 + const data = Buffer.concat(chunks); + // 加压到目标文件夹 + JSZip.loadAsync(data).then((zip) => { + zip.forEach((relativePath, file) => { + if(file.dir){ + fs.mkdirSync(vscode.Uri.joinPath(ui_path, relativePath).fsPath, {recursive: true}); + } + else{ + file.async('nodebuffer').then((content) => { + fs.writeFileSync(vscode.Uri.joinPath(ui_path, relativePath).fsPath, content); + }); + } + }); + console.log('ZIP 数据已解压缩到文件系统'); + }); + }); + }).on("error", (err) => { + console.log("download ui error" + err.message); + }); + + try { let state = await vscode.workspace.fs.stat(y3Uri); if (state.type === vscode.FileType.Directory) {