Modify the warehouse source
Due to the unknown of the electron version, there may be a situation where the server is available and a white screen opens after the build, so it needs to be treated with caution. It is best to commit a version when it is available to facilitate code rollback. If anyone has better information, they would like to share it.
Before starting the configuration, you can slightly modify the rc files of yarn and npm. Use commands or files to directly modify .npmrc or .yarnrc. These two global configuration files are generally in C:\user\your In the folder of the current account, or create a new file command rc file under the current project to partially change the configuration.
Because the electron download will fail due to network problems, it is changed to Taobao source, Huawei source can also be used.
npm set config registry http://registry.npm.taobao.org/ npm set config chromedriver_cdnurl http://registry.npm.taobao.org/chromedriver npm set config electron_mirror http://registry.npm.taobao.org/electron/ npm set config electron_builder_binaries_mirror http://registry.npm.taobao.org/electron-builder-binaries/
During the installation process, use vue create
Startup
The corresponding startup command has been assembled in package.json,
Use npm run electron:serve to start development
npm run electron:build Compile and package production
Replace vue-devtools
Project project under src/background .ts is the startup directory of electron. In the development environment, the following situations may occur where the startup waiting time is long
Launching Electron...
Failed to fetch extension, trying 4 more times
Failed to fetch extension, trying 3 more times
Failed to fetch extension, trying 2 more times
Failed to fetch extension, trying 1 more times
is because the project needs to be downloaded from the Google Store online And failed to load vue-devtools.
I have tried many methods to load tools but all failed, so the temporary method is to remove tools. The code is found, just remove installExtension
app.on('ready', async () => { if (isDevelopment && !process.env.IS_TEST) { // Install Vue Devtools try { // await installExtension(VUEJS_DEVTOOLS) } catch (e) { console.error('Vue Devtools failed to install:', e.toString()) } } createWindow() })
I tried many methods before but it didn’t work. Later, I carefully compared the following and found some problems.
The vue3 version is different from the vue2 version of vue-devtools, so the dev-tools of vue2 cannot be used by vue3. Therefore, you need to download the development tools corresponding to vue3. The latest version of vue2 is 5.x, while the version of vue3 is 6.x beta version. This version of the plugin can be downloaded via crx4chrome. Unzip the downloaded crx, and then copy it to the project root directory. Use session loading to replace the original await installExtension(VUEJS_DEVTOOLS) part with
import {session} from 'electron' app.on('ready', async () => { if (isDevelopment && !process.env.IS_TEST) { // Install Vue Devtools try { const vue_devtools = 'ljjemllljcmogpfapbkkighbhhppjdbg-6.0.0-beta-13-Crx4Chrome.com' await session.defaultSession.loadExtension(path.resolve(vue_devtools)) } catch (e) { console.error('Vue Devtools failed to install:', e.toString()) } } createWindow() })
. After starting the project, you can view the extension of vue. For
(node:5904) ExtensionLoadWarning: Warnings loading extension at E:\scan\vue3_electron\ljjemllljcmogpfapbkkighbhhppjdbg-6.0.0-beta-13-Crx4Chrome.com:
Unrecognized manifest key 'browser_action '.
Unrecognized manifest key 'update_url'.
Permission 'contextMenus' is unknown or URL pattern is malformed.
Cannot load extension with file or directory name _metadata. Filenames starting with "_" are reserved for use by the system.
(Use `electron --trace-warnings ...` to show where the warning was created)
You can ignore it. If you don’t want to see annoying prompts, you can delete the content corresponding to the prompts in the manifest.json of tools
Notes
When using script-setup as a module, it can be used normally during the serve phase, but after the build the component is not loaded, the page appears blank, and no error is reported, the reason is unknown
Use electron-edge-js loads the dll file developed by c#. The configuration process is a bit cumbersome. I spent 2 days looking for answers, but to no avail. The following is the solution, which requires the right medicine
c and dll developed by c# Use a different loader, c uses ffi-napi.
Using edge requires adding three configurations at the same time
When there is no configuration, Uncaught (in promise) Error: Cannot find module '... \node_modules\electron\dist\resources\electron.asar\renderer\native\win32\x64\14.16.0\edge_nativeclr' At this time, you need to add it to the vue.config.js file. If there is no configuration file, you need to add it to package.json Created at the same level.
module.exports = { pluginOptions: { electronBuilder: { externals: ['electron-edge-js'] } } }
When the configuration is not enabled, you will not be able to use nodejs built-in variables such as __dirname __filename
Uncaught (in promise) ReferenceError: __dirname is not defined First you need to configure new BrowserWindow
{ // 如果使用到nodejs的api,则打包时需要将此设置为true nodeIntegration: true, // 同时,需要设置此项为false // 未设置时报 Uncaught ReferenceError: require is not defined contextIsolation: false }
After the above configuration is completed, Uncaught (in promise) TypeError: fs.existsSync is not a function
At this time, you need to continue to add configuration items of vue.config.js
module.exports = { pluginOptions: { electronBuilder: { externals: ['electron-edge-js'], // 此处同样需要开启,将会在编译阶段将引用关系写入 nodeIntegration: true, } } }
If you configure this item separately , but nodeIntegration: true of new BrowserWindow is not enabled, Uncaught ReferenceError: require is not defined
will occur.此外,对于dll放置的文件夹,一般在项目根目录创resources用于存放资源,并且项目打包过程中会不会直接打包资源目录,所以需要增加资源配置,以防止出错。对于文件的引用,在开发环境下,为当前所看到的结构,当编译打包后,为安装目录下resources目录,所以生产和开发的引用文件存在一定区别,可以实验后再看文件引用
module.exports = { pluginOptions: { electronBuilder: { externals: ['electron-edge-js'], // 此处同样需要开启,将会在编译阶段将引用关系写入 nodeIntegration: true, builderOptions:{ extraResources: { // 拷贝静态文件到指定位置,否则会提示文件找不到 from: 'resources/', to: './' }, } } } }
提供文件获取目录方法,可以直接获取不同操作系统下app的resource目录,如果是window即 process.platform==='win32'
const path = require('path') export function getAppResourcePath (filePath:string) { if (process.platform === 'darwin' || process.platform === 'linux') { if (process.env.NODE_ENV === 'development') { return path.resolve('resources/' + filePath) } else { return path.join(__dirname, '..') + filePath } } else { return path.resolve('resources/' + filePath) } }
使用setup语法时,需使用require('electron-edge-js')引入,不可以使用import,否则会报 Syntax Error: TypeError: Cannot read property 'content' of null 而非 setup语法,则可以直接import
无边框窗口
系统本身是带有框架的,如果需要自定义框架,可以使用frameless 设置,如果需要使用自定义组件(比如 div.custom-frame-title)拖拽操作窗口时,需要给对应的元素增加样式:
.custom-frame-title { -webkit-user-select: none; // 此项防止与文本选择冲突 -webkit-app-region: drag; // 此项为系统相应状态栏 }
前后台通知
import {ipcMain,ipcRenderer} from 'electron'
在electron中有很多可用api,其中最重要的是:ipcMain和ipcRenderer,用于ui进程和系统进程的通信。 在vue内使用ipcRenderer.on('eventname') 接受系统发来的消息,用ipcRenderer.send('eventname') 发送通知给系统,同样ipcMain可以在主线程使用。
ipc通常结合自定义标题栏完成以下操作,或者其他需要操作窗口本身的事件
win.minimize() //最小化窗口 win.maximize() //最大化窗口 win.close() //关闭窗口 win.hide() //隐藏窗口
The above is the detailed content of How to develop client configuration with vue3+electron12+dll. For more information, please follow other related articles on the PHP Chinese website!

Netflix uses React as its front-end framework. 1) React's componentized development model and strong ecosystem are the main reasons why Netflix chose it. 2) Through componentization, Netflix splits complex interfaces into manageable chunks such as video players, recommendation lists and user comments. 3) React's virtual DOM and component life cycle optimizes rendering efficiency and user interaction management.

Netflix's choice in front-end technology mainly focuses on three aspects: performance optimization, scalability and user experience. 1. Performance optimization: Netflix chose React as the main framework and developed tools such as SpeedCurve and Boomerang to monitor and optimize the user experience. 2. Scalability: They adopt a micro front-end architecture, splitting applications into independent modules, improving development efficiency and system scalability. 3. User experience: Netflix uses the Material-UI component library to continuously optimize the interface through A/B testing and user feedback to ensure consistency and aesthetics.

Netflixusesacustomframeworkcalled"Gibbon"builtonReact,notReactorVuedirectly.1)TeamExperience:Choosebasedonfamiliarity.2)ProjectComplexity:Vueforsimplerprojects,Reactforcomplexones.3)CustomizationNeeds:Reactoffersmoreflexibility.4)Ecosystema

Netflix mainly considers performance, scalability, development efficiency, ecosystem, technical debt and maintenance costs in framework selection. 1. Performance and scalability: Java and SpringBoot are selected to efficiently process massive data and high concurrent requests. 2. Development efficiency and ecosystem: Use React to improve front-end development efficiency and utilize its rich ecosystem. 3. Technical debt and maintenance costs: Choose Node.js to build microservices to reduce maintenance costs and technical debt.

Netflix mainly uses React as the front-end framework, supplemented by Vue for specific functions. 1) React's componentization and virtual DOM improve the performance and development efficiency of Netflix applications. 2) Vue is used in Netflix's internal tools and small projects, and its flexibility and ease of use are key.

Vue.js is a progressive JavaScript framework suitable for building complex user interfaces. 1) Its core concepts include responsive data, componentization and virtual DOM. 2) In practical applications, it can be demonstrated by building Todo applications and integrating VueRouter. 3) When debugging, it is recommended to use VueDevtools and console.log. 4) Performance optimization can be achieved through v-if/v-show, list rendering optimization, asynchronous loading of components, etc.

Vue.js is suitable for small to medium-sized projects, while React is more suitable for large and complex applications. 1. Vue.js' responsive system automatically updates the DOM through dependency tracking, making it easy to manage data changes. 2.React adopts a one-way data flow, and data flows from the parent component to the child component, providing a clear data flow and an easy-to-debug structure.

Vue.js is suitable for small and medium-sized projects and fast iterations, while React is suitable for large and complex applications. 1) Vue.js is easy to use and is suitable for situations where the team is insufficient or the project scale is small. 2) React has a richer ecosystem and is suitable for projects with high performance and complex functional needs.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 Linux new version
SublimeText3 Linux latest version

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.