日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

VSCode 插件开发实例(WebView):微信读书 ^-^边撸代码边看小说^-^

發布時間:2023/12/4 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 VSCode 插件开发实例(WebView):微信读书 ^-^边撸代码边看小说^-^ 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

最終效果

?

?

主要代碼

package.json

{"name": "WeReadForVSCodeJackieZheng","repository": {"type": "git","url": "https://github.com/JackieZheng/WeReadForVSCode.git"},"displayName": "WeReadForVSCode","description": "WeRead for VSCode 微信讀書 VSCode 插件","version": "0.1.0","author": {"name": "JackieZheng"},"publisher": "JackieZheng","engines": {"vscode": "^1.48.0"},"categories": ["Other", "Keymaps", "Language Packs", "Extension Packs"],"keywords": ["vscode", "plugin", "webView", "weread", "view in browser"],"icon": "Images/icon.png","activationEvents": ["onCommand:WeReadForVSCodeJackieZheng.Start"],"main": "./extension.js","contributes": {"commands": [{"command": "WeReadForVSCodeJackieZheng.Start","title": "Start","category": "WeRead","icon": {"light": "Images/icon.svg","dark": "Images/icon.svg"}}],"keybindings": [{"command": "WeReadForVSCodeJackieZheng.Start","key": "ctrl+f3","mac": "cmd+f3"}]},"license": "SEE LICENSE IN LICENSE.md","bugs": {"url": "https://github.com/JackieZheng/WeReadForVSCode/issues","email": "zhengxinzhe@jackyzheng.uu.me"},"homepage": "https://github.com/JackieZheng/WeReadForVSCode/blob/master/README.md","scripts": {"lint": "eslint .","pretest": "npm run lint","test": "node ./test/runTest.js"},"devDependencies": {"@types/vscode": "^1.48.0","@types/glob": "^7.1.3","@types/mocha": "^8.0.0","@types/node": "^14.0.27","eslint": "^7.6.0","glob": "^7.1.6","mocha": "^8.0.1","typescript": "^3.8.3","vscode-test": "^1.4.0"} }

?extension.js

// @ts-nocheck const vscode = require('vscode'); const {url} = require('inspector');// this method is called when your extension is activated // your extension is activated the very first time the command is executedfunction activate(context) {// The command has been defined in the package.json file// Now provide the implementation of the command with registerCommand// The commandId parameter must match the command field in package.jsonlet disposable = vscode.commands.registerCommand('WeReadForVSCodeJackieZheng.Start', function () {// The code you place here will be executed every time your command is executed// 1.創建并顯示Webviewconst panel = vscode.window.createWebviewPanel(// 該webview的標識,任意字符串'WeRead',// webview面板的標題,會展示給用戶'微信讀書',// webview面板所在的分欄vscode.ViewColumn.One,// 其它webview選項{enableScripts: true, // 啟用JS,默認禁用retainContextWhenHidden: true, // webview被隱藏時保持狀態,避免被重置});//設置標題前圖標panel.iconPath = {dark: vscode.Uri.file(context.extensionPath + '/Images/iconDark.png'),light: vscode.Uri.file(context.extensionPath + '/Images/iconBlack.png')};panel.webview.html = `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"><meta content="portrait" name="x5-orientation"><meta content="true" name="x5-fullscreen"><meta content="portrait" name="screen-orientation"><meta content="yes" name="full-screen"><meta content="webkit" name="renderer"><meta content="IE=Edge" http-equiv="X-UA-Compatible"><title>微信讀書</title><style>html,body,iframe{width:100%;height:100%;border:0;overflow: hidden;}</style></head><body><iframe src="https://weread.qq.com/"/></body></html>`;});context.subscriptions.push(disposable); } exports.activate = activate;// this method is called when your extension is deactivated function deactivate() {}module.exports = {activate,deactivate }

?

其它相關?

安裝腳手架:

npm install -g yo generator-code

初始化項目:

yo code

?

安裝打包工具:

npm i vsce -g

打包成vsix文件:

vsce package

?

打包后插件及完整源碼?

https://marketplace.visualstudio.com/items?itemName=JackieZheng.WeReadForVSCodeJackieZheng

https://github.com/JackieZheng/WeReadForVSCode

?

總結

以上是生活随笔為你收集整理的VSCode 插件开发实例(WebView):微信读书 ^-^边撸代码边看小说^-^的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。