久久久久久久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 獲取當前位置?)
主站蜘蛛池模板: 日韩一区二区免费视频 | 久久久精彩视频 | 超碰97人人人人人蜜桃 | 特级黄一级播放 | 免费能直接在线观看黄的视频 | 欧美日韩电影免费观看 | 精品国产免费人成在线观看 | 日本一区高清 | 国产黄色大片在线免费观看 | 欧美成人自拍视频 | 手机在线一区二区三区 | 99re6热在线精品视频播放 | 国产免费一区二区 | 91xh98hx 在线 国产 | 久久久久久国产 | 中文字幕亚洲视频 | 91麻豆精品国产91久久久资源速度 | 欧美日韩中文字幕在线 | 国产在线麻豆精品入口 | 国产一区二区三区视频 | 亚洲久草 | 欧美一区二区三区高清视频 | 国产在线中文字幕 | 国产亚洲成av人在线观看导航 | 精品免费国产一区二区三区四区介绍 | 九九热国产精品视频 | 国产在线看片 | 五月婷婷激情网 | 狠狠操狠狠干 | 国产欧美在线播放 | 狠狠干五月天 | 国产一区二区三区四区在线观看 | 天天爱天天操 | 97国产在线视频 | 最新中文在线视频 | 国产精品免费一区二区 | 九九热精品视频 | 涩色视频在线观看 | 久久久999精品 | 中文字幕一区二区三区精彩视频 | aaa精品|