vue-cli插件配置
pluginOptions: { electronBuilder: { outputDir: 'dist-electron', //打包路徑 chainWebpackMainProcess: (config) => { // Chain webpack config for electron main process only // console.log("electron config",config) }, chainWebpackRendererProcess: (config) => { // Chain webpack config for electron renderer process only // The following example will set IS_ELECTRON to true in your app // config.plugin('define').tap((args) => { // console.log("args",args) // args[0]['IS_ELECTRON'] = true // return args // }) }, // Use this to change the entrypoint of your app's main process // mainProcessFile: 'src/background.js', builderOptions: { // options placed here will be merged with default configuration and passed to electron-builder asar:false, appId: "com.SHOM.app", productName: "SHom", // "directories": { // "output": "./distelectron"//輸出文件路徑 // }, dmg: { contents: [ { x: 410, y: 150, type: "link", path: "/Applications" }, { x: 130, y: 150, type: "file" } ] }, win: {//win相關配置 icon:"./public/timg.ico", // setup圖標 target: [ { target: "nsis",//利用nsis制作安裝程序 arch: [ "x64",//64位 "ia32"//32位 ] } ] }, nsis: { oneClick: false, // 是否一鍵安裝 allowElevation: true, // 允許請求提升。 如果為false,則用戶必須使用提升的權限重新啟動安裝程序。 allowToChangeInstallationDirectory: true, // 允許修改安裝目錄 installerIcon: "./public/timg.ico",// 安裝圖標 uninstallerIcon: "./public/timg.ico",//卸載圖標 installerHeaderIcon: "./public/timg.ico", // 安裝時頭部圖標 createDesktopShortcut: true, // 創建桌面圖標 createStartMenuShortcut: true,// 創建開始菜單圖標 shortcutName: "SHom", // 圖標名稱 include: "./public/nsis/installer.nsh", // 自定義nsis腳本 安裝過程中自行調用 (可用於寫入注冊表 開機自啟動等操作) }, publish: [ { provider: "generic", url: "http://**.**.**.**:3001/download/",//隱藏版本服務器地址 } ], } } }
nsis自定義腳本:
寫入注冊表:
!macro customInstall ; WriteRegStr 根鍵 子鍵 項 值 WriteRegStr HKCR ".om" "" "omFile" WriteRegStr HKCR "omFile\shell\open\command" "" '"$INSTDIR\SHom.exe" "%1"' !macroend
pluginOptions
: {
electronBuilder
: {
outputDir
:
'dist-electron',
//打包路徑
chainWebpackMainProcess
: (
config)
=> {
// Chain webpack config for electron main process only
// console.log("electron config",config)
},
chainWebpackRendererProcess
: (
config)
=> {
// Chain webpack config for electron renderer process only
// The following example will set IS_ELECTRON to true in your app
// config.plugin('define').tap((args) => {
// console.log("args",args)
// args[0]['IS_ELECTRON'] = true
// return args
// })
},
// Use this to change the entrypoint of your app's main process
// mainProcessFile: 'src/background.js',
builderOptions
: {
// options placed here will be merged with default configuration and passed to electron-builder
asar
:
false,
appId
:
"com.SHOM.app",
productName
:
"SHom",
// "directories": {
// "output": "./distelectron"//輸出文件路徑
// },
dmg
: {
contents
: [
{
x
:
410,
y
:
150,
type
:
"link",
path
:
"/Applications"
},
{
x
:
130,
y
:
150,
type
:
"file"
}
]
},
win
: {
//win相關配置
icon
:
"./public/timg.ico",
// setup圖標
target
: [
{
target
:
"nsis",
//利用nsis制作安裝程序
arch
: [
"x64",
//64位
"ia32"
//32位
]
}
]
},
nsis
: {
oneClick
:
false,
// 是否一鍵安裝
allowElevation
:
true,
// 允許請求提升。 如果為false,則用戶必須使用提升的權限重新啟動安裝程序。
allowToChangeInstallationDirectory
:
true,
// 允許修改安裝目錄
installerIcon
:
"./public/timg.ico",
// 安裝圖標
uninstallerIcon
:
"./public/timg.ico",
//卸載圖標
installerHeaderIcon
:
"./public/timg.ico",
// 安裝時頭部圖標
createDesktopShortcut
:
true,
// 創建桌面圖標
createStartMenuShortcut
:
true,
// 創建開始菜單圖標
shortcutName
:
"SHom",
// 圖標名稱
include
:
"./public/nsis/installer.nsh",
// 自定義nsis腳本 安裝過程中自行調用 (可用於寫入注冊表 開機自啟動等操作)
},
publish
: [
{
provider
:
"generic",
url
:
"http://**.**.**.**:3001/download/",
//隱藏版本服務器地址
}
],
}
}
}
