vueCli + electron12.0.0
调用C# DLL
electron-updater在线更新
npm install
npm run serve
npm run build
npm run lint
npm run electron:serve
npm run electron:build
Add DLL operations and so on
- Put C#DLL into root directory /** (public/resources ) */
- Modification of documents /** Under the path ( src/background.js ) */
在background.js里的(调用dll (模块) start)区域里添加dll操作
1. background.js:
+ const dllVariable = process.env.NODE_ENV === 'development'
+ ? path.resolve("public/resources/DLL_file_name.dll")
+ : path.resolve("resources/DLL_file_name.dll")
2. background.js:
+ let funVariable = edge.func({
+ assemblyFile:dllVariable,
+ typeName: 'DLL_file_name.Namespace',
+ methodName: 'DLL_file_name.MethodName'
+ })
3.background.js:
+ ipcMain.on('ipcObject',(event,arg) =>{
+ funVariable(arg,function(error,result){
+ if (error) throw error
+ console.log('Dll返回:' + result)
+ })
+ })
4. xxx.vue:
<template>
<div>
<button @click="call">调用DLL</button>
</div>
</template>
<script>
import { ipcRenderer } from 'electron'
export default {
methods: {
call(){
var data = {
"name":"小明",
sex:"男",
age:18
}
ipcRenderer.send("ipcObject" , JSON.stringify(data));
},
}
}
5. vue.config.js:
in ( pluginOptions/electronBuilder/builderOptions/extraResources ) add
+ {
+ "from": "./public/resources/DLL_file_name.dll",
+ "to": "./"
+ },
and so on
+ {
+
+ }
</script>
- vue.config.js pluginOptions/electronBuilder/builderOptions publish --> "url":"http://..../bbbb/" url是服务器的文件夹,文件夹下放打包出来的文件
background.js 76行 链接跟上面的一样 let feedUrl = "http://..../bbbb/"
- 每次更新需要修改package.json下的version数值,打包放上服务器文件夹下