Neutralinojs + Vue HelloWorld
安装neu CLI
yarn global add @neutralinojs/neu
创建 Neutralino 空白模板
neu create vueapp --template neutralinojs/neutralinojs-zero
Microsoft Windows [版本 10.0.19045.5737]
(c) Microsoft Corporation。保留所有权利。
D:\letleon\Source\neutralinojs>neu create vueapp --template neutralinojs/neutralinojs-zero
neu: INFO Checking if neutralinojs/neutralinojs-zero is a valid Neutralinojs app template...
neu: WARN Unable to check the template validity via the GitHub API. Assuming that the template is valid...
neu: INFO Downloading neutralinojs/neutralinojs-zero template to vueapp directory...
neu: INFO Extracting template zip file...
neu: INFO Downloading Neutralinojs binaries..
neu: WARN Unable to fetch the latest version tag from GitHub. Using nightly releases...
neu: INFO Extracting binaries.zip file...
neu: INFO Finalizing and cleaning temp. files.
neu: INFO Downloading the Neutralinojs client..
neu: WARN Unable to fetch the latest version tag from GitHub. Using nightly releases...
neu: INFO Downloading the Neutralinojs types..
neu: INFO Finalizing and cleaning temp. files...
-------
neu: INFO Enter 'cd vueapp && neu run' to run your application.
_ _ _ _ _ _
| \ | | ___ _ _| |_ _ __ __ _| (_)_ __ ___ (_)___
| \| |/ _ \ | | | __| '__/ _' | | | '_ \ / _ \| / __|
| |\ | __/ |_| | |_| | | (_| | | | | | | (_) | \__ \
|_| \_|\___|\__,_|\__|_| \__,_|_|_|_| |_|\___// |___/
|__/
创建 Vue 项目
-
删除 www 目录
cd vueapp
rmdir /s www -
安装 Vue
npx create-vue@latest
将vue项目名称改为 vue-src
安装 Vue 依赖
cd vue-src
yarn
配置
- 修改 neutralino.config.json
frontendLibrary 中的配置可以实现热重载!
{
"applicationId": "js.neutralino.zero",
"version": "1.0.0",
"defaultMode": "window",
"documentRoot": "/vue-src/dist/",
"url": "/",
"enableServer": true,
"enableNativeAPI": true,
"nativeAllowList": [
"app.*",
"filesystem.*",
"os.*"
],
"modes": {
"window": {
"title": "PDEView",
"width": 800,
"height": 500,
"minWidth": 400,
"minHeight": 200,
"icon": "/vue-src/public/favicon.ico",
"enableInspector": true,
"borderless": false,
"maximize": false,
"hidden": false,
"resizable": true,
"exitProcessOnClose": false
}
},
"cli": {
"binaryName": "PDEView",
"resourcesPath": "/vue-src/dist/",
"extensionsPath": "/extensions/",
"binaryVersion": "nightly",
"clientVersion": "nightly",
"frontendLibrary": {
"patchFile": "/vue-src/index.html",
"devUrl": "http://localhost:5173",
"projectPath": "/vue-src/",
"initCommand": "yarn install",
"devCommand": "yarn dev",
"buildCommand": "yarn build"
}
}
}
运行
neu run
添加 VSCode 调试任务
.vscode\tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "Run Neutralino App",
"type": "shell",
"command": "neu run",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"panel": "dedicated",
"focus": true
}
}
]
}
.vscode\launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Neutralino App",
"type": "node",
"request": "launch",
"runtimeExecutable": "neu",
"runtimeArgs": ["run"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
即可使用快捷键 Ctrl + Shift + B 或 F5 来一键运行调试啦!
网络问题!
可以修改 C:\Program Files\nodejs\node_modules@neutralinojs\neu\src\constants.js 文件!
使用ghproxy可以加速创建过程!
可自行搜索ghproxy 来替换!