久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如果我使用帶有電子 js 的 vue 路由器,如何修復

how to fix blank page if i am using vue router with electron js?(如果我使用帶有電子 js 的 vue 路由器,如何修復空白頁?)
本文介紹了如果我使用帶有電子 js 的 vue 路由器,如何修復空白頁?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試將 vue 路由器與 Electron JS 上的應用程序一起使用.如果我在渲染頁面上使用路由器,那么路由器的工作就完成了.但我不明白如何轉換到頁面,例如 - 使用托盤的設置".嘗試轉換時會打開空白頁面.我已經準備了該項目的工作示例.此問題僅存在構建項目.在開發模式下一切正常.

I'm trying to use vue router with an application on an Electron JS. If I use a router on the render page, then the router work done. But I do not understand how to make the transition to the page, for example,- 'Settings' using the Tray. At attempt of transition the empty page opens. I have prepared a working example of the project. This problem exists only build project. In development mode all work well.

這是我在 github 上的工作示例.請需要幫助.

This is my work example on github. Please need help.

git clone https://github.com/DmtryJS/electron-vue-example.git
cd electron-vue-example
npm install
npm run build
and run distwin-unpackedexample_for_stackoverflow.exe

我的 main.js 文件

my main.js file

'use strict'

import { app, protocol, BrowserWindow, Menu, ipcMain, Tray } from 'electron'
import { format as formatUrl } from 'url'
const electron = require('electron');
const path = require('path');

const isDevelopment = process.env.NODE_ENV !== 'production';

let imgBasePath;

if(isDevelopment) {
  imgBasePath = path.join('src','assets', 'img');
} else {
  imgBasePath = path.join(path.dirname(__dirname), 'extraResources', 'img');
}

let win;
let tray;
protocol.registerStandardSchemes(['app'], { secure: true })

const trayIcon = path.join(__static, 'img', 'icon.png');

function createWindow () {
  win = new BrowserWindow({ 
    width: 800, 
    height: 600,
    icon: trayIcon
   })

  routeTo(win, "")

  win.on('closed', () => {
    win = null
  })
   //убрать меню
   win.setMenuBarVisibility(true)

   win.on('show', function() {
   tray.setHighlightMode('always')
   })

   win.on('hide', function() {
     tray.setHighlightMode('never')
   })
}

// Quit when all windows are closed.
app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

app.on('activate', () => {
  if (win === null) {
    createWindow()
  }
})

app.on('ready', () => {
  createWindow()
  win.webContents.openDevTools(); //открыть dev tools
  createTray()
})

// Exit cleanly on request from parent process in development mode.
if (isDevelopment) {
  if (process.platform === 'win32') {
    process.on('message', data => {
      if (data === 'graceful-exit') {
        app.quit()
      }
    })
  } else {
    process.on('SIGTERM', () => {
      app.quit()
    })
  }
}

function createTray()
{
  let traiIconPath = path.join(imgBasePath, 'preloader_tray_icon.png')
  tray = new Tray(traiIconPath)

  const contextMenu = Menu.buildFromTemplate(
    [ 
      {
        label: 'Settings', 
        type: 'normal',

        click: function() 
        {
          routeTo(win, "/settings")
          let contents = win.webContents

          contents.on('dom-ready', function()
          {
            if(!win.isVisible())
            {
              showWindow()
            }
          })   
        }
      },

      {
        label: 'Exit', 
        type: 'normal', 

        click: function() 
        {
          win = null
          app.quit()
        }
      }
    ])

  tray.setContextMenu(contextMenu)

  tray.on('click', function() {
  toggleWindow();
})
}

function showWindow() {
  var position = getPosition();
  win.setPosition(position.x, position.y, false)
  win.show()
  win.focus()
}

ipcMain.on('routerEvent', function(event, arg) {
  routeTo(win, arg)
})

function routeTo(win, to) {
  if (isDevelopment) {
    win.loadURL(`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}` + to)
  } else {
    win.loadURL(formatUrl({
      pathname: path.join(__dirname, 'index.html' + to);,
      protocol: 'file',
      slashes: true
    }))
  }
}

并且路由器.js

import Vue from 'vue'
import Router from 'vue-router'
import Main from './../views/Main.vue'
import Settings from './../views/Settings.vue'

Vue.use(Router)

export default new Router({
  //mode: 'history',
  routes: [
    {
      path: '/',
      name: 'home',
      component: Main
    },
    {
      path: '/settings',
      name: 'settings',
      component: Settings
    }
  ]
})

推薦答案

需要將created添加到主Vue app check 文檔

You need to add created to the main Vue app check docs

// src/main.js

new Vue({
  router,
  render: h => h(App),
  created() {
    // Prevent blank screen in Electron builds
    this.$router.push('/')
  }
}).$mount('#app')

這篇關于如果我使用帶有電子 js 的 vue 路由器,如何修復空白頁?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
How to getCurrentPosition via navigator.geolocation in Electron app?(如何通過電子應用程序中的 navigator.geolocation 獲取當前位置?)
主站蜘蛛池模板: 放个毛片看看 | 亚洲成人高清 | 少妇av片| 国产成人精品福利 | 日韩精品久久久久 | 国产免费观看一区 | 欧美一区在线视频 | 久久精品男人的天堂 | 成年人免费在线视频 | 在线看日韩av | 日韩欧美网 | 成人欧美一区二区三区黑人孕妇 | 韩国av一区二区 | 国产精品久久久久久久久久久新郎 | 国产男人的天堂 | 婷婷国产一区二区三区 | 一区精品视频在线观看 | 成人免费一级 | 91麻豆精品国产91久久久更新资源速度超快 | 亚洲网在线 | 国产真实精品久久二三区 | 久久久久久国产精品 | 国产成人精品一区二 | 黄色免费在线观看 | 精品视频免费 | 亚洲精品在线国产 | www久久av | 国产黄色网址在线观看 | 欧美vide | 欧产日产国产精品视频 | 天天干天天插天天 | 免费观看色 | 伊人亚洲 | 99久久国产精 | 久久国产精品一区二区三区 | www.99精品| 久草成人网 | 自拍偷拍亚洲视频 | 一区二区久久精品 | www..99re| 精品久久1|