perf: mac theme icon
							parent
							
								
									3cef4f2ba9
								
							
						
					
					
						commit
						794458b006
					
				| 
						 | 
				
			
			@ -10,5 +10,5 @@ log4js.configure({
 | 
			
		|||
  appenders: { std: { type: 'stdout' }, file: { type: 'file', pattern: 'yyyy-MM-dd', daysToKeep: 3, filename} },
 | 
			
		||||
  categories: { default: { appenders: ['file', 'std'], level: level } }
 | 
			
		||||
})
 | 
			
		||||
const logger = log4js.getLogger('server')
 | 
			
		||||
const logger = log4js.getLogger('core')
 | 
			
		||||
module.exports = logger
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,2 +1 @@
 | 
			
		|||
// eslint-disable-next-line no-unused-vars
 | 
			
		||||
const mitmproxy = require('./start/mitmproxy.js')
 | 
			
		||||
const https = require('https')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,20 @@
 | 
			
		|||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
 | 
			
		||||
    <title>window</title>
 | 
			
		||||
    <g id="页面-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" transform="scale(0.016, 0.016)">
 | 
			
		||||
        <g id="window">
 | 
			
		||||
            <rect id="矩形" stroke="#979797" fill="#1B7FCD" fill-rule="nonzero" x="0.5" y="0.5" width="1023" height="1023" rx="140"></rect>
 | 
			
		||||
            <g id="编组" transform="translate(512.000000, 511.000000) scale(-1, 1) translate(-512.000000, -511.000000) translate(113.000000, 78.000000)">
 | 
			
		||||
                <ellipse id="椭圆形" fill="#FFFFFF" fill-rule="nonzero" cx="316.962617" cy="428.651363" rx="172.775701" ry="173.945481"></ellipse>
 | 
			
		||||
                <ellipse id="椭圆形" fill="#FFFFFF" fill-rule="nonzero" cx="95.088785" cy="95.0487805" rx="95.088785" ry="95.0487805"></ellipse>
 | 
			
		||||
                <ellipse id="椭圆形" fill="#FFFFFF" fill-rule="nonzero" cx="380.976636" cy="117.413199" rx="68.9859813" ry="68.9569584"></ellipse>
 | 
			
		||||
                <ellipse id="椭圆形" stroke="#FFFFFF" stroke-width="2.8" fill="#FFFFFF" fill-rule="nonzero" cx="183.341121" cy="770.95122" rx="95.088785" ry="95.0487805"></ellipse>
 | 
			
		||||
                <ellipse id="椭圆形" stroke="#FFFFFF" stroke-width="50" cx="694.831776" cy="488.289813" rx="103.168224" ry="103.124821"></ellipse>
 | 
			
		||||
                <line x1="236.168224" y1="325.526542" x2="121.813084" y2="147.853659" id="路径" stroke="#FFFFFF" stroke-width="50"></line>
 | 
			
		||||
                <line x1="339.336449" y1="323.041607" x2="370.411215" y2="154.065997" id="路径" stroke="#FFFFFF" stroke-width="50"></line>
 | 
			
		||||
                <line x1="259.785047" y1="549.170732" x2="208.82243" y2="699.509326" id="路径" stroke="#FFFFFF" stroke-width="50"></line>
 | 
			
		||||
                <line x1="427.588785" y1="429.893831" x2="591.663551" y2="460.955524" id="路径" stroke="#FFFFFF" stroke-width="50"></line>
 | 
			
		||||
            </g>
 | 
			
		||||
        </g>
 | 
			
		||||
    </g>
 | 
			
		||||
</svg>
 | 
			
		||||
| 
		 After Width: | Height: | Size: 2.0 KiB  | 
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
'use strict'
 | 
			
		||||
/* global __static */
 | 
			
		||||
import path from 'path'
 | 
			
		||||
import { app, protocol, BrowserWindow, Menu, Tray, ipcMain, dialog, powerMonitor } from 'electron'
 | 
			
		||||
import { app, protocol, BrowserWindow, Menu, Tray, ipcMain, dialog, powerMonitor, nativeImage, nativeTheme } from 'electron'
 | 
			
		||||
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'
 | 
			
		||||
import backend from './bridge/backend'
 | 
			
		||||
import DevSidecar from '@docmirror/dev-sidecar'
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +23,6 @@ let forceClose = false
 | 
			
		|||
protocol.registerSchemesAsPrivileged([
 | 
			
		||||
  { scheme: 'app', privileges: { secure: true, standard: true } }
 | 
			
		||||
])
 | 
			
		||||
 | 
			
		||||
// 隐藏主窗口,并创建托盘,绑定关闭事件
 | 
			
		||||
function setTray (app) {
 | 
			
		||||
  // 用一个 Tray 来表示一个图标,这个图标处于正在运行的系统的通知区
 | 
			
		||||
| 
						 | 
				
			
			@ -41,32 +40,43 @@ function setTray (app) {
 | 
			
		|||
    }
 | 
			
		||||
  ]
 | 
			
		||||
  // 设置系统托盘图标
 | 
			
		||||
  let icon = '128x128.png'
 | 
			
		||||
  const iconRootPath = path.join(__dirname, '../extra/icons/tray')
 | 
			
		||||
  let iconPath = path.join(iconRootPath, 'icon.png')
 | 
			
		||||
  const iconWhitePath = path.join(iconRootPath, 'icon-white.png')
 | 
			
		||||
  const iconBlackPath = path.join(iconRootPath, 'icon-black.png')
 | 
			
		||||
  if (isMac) {
 | 
			
		||||
    icon = '16x16-black.png'
 | 
			
		||||
    iconPath = nativeTheme.shouldUseDarkColors ? iconWhitePath : iconBlackPath
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const trayIcon = nativeImage.createFromPath(iconPath)
 | 
			
		||||
  const appTray = new Tray(trayIcon)
 | 
			
		||||
 | 
			
		||||
  // 当桌面主题更新时
 | 
			
		||||
  if (isMac) {
 | 
			
		||||
    nativeTheme.on('updated', () => {
 | 
			
		||||
      console.log('i am changed')
 | 
			
		||||
      if (nativeTheme.shouldUseDarkColors) {
 | 
			
		||||
        console.log('i am dark.')
 | 
			
		||||
        tray.setImage(iconWhitePath)
 | 
			
		||||
      } else {
 | 
			
		||||
        console.log('i am light.')
 | 
			
		||||
        tray.setImage(iconBlackPath)
 | 
			
		||||
        // tray.setPressedImage(iconWhitePath)
 | 
			
		||||
      }
 | 
			
		||||
    })
 | 
			
		||||
  }
 | 
			
		||||
  const iconPath = path.join(__dirname, '../extra/icons/', icon)
 | 
			
		||||
  const appTray = new Tray(iconPath)
 | 
			
		||||
 | 
			
		||||
  // 图标的上下文菜单
 | 
			
		||||
  const contextMenu = Menu.buildFromTemplate(trayMenuTemplate)
 | 
			
		||||
 | 
			
		||||
  // 设置托盘悬浮提示
 | 
			
		||||
  appTray.setToolTip('DevSidecar-开发者边车辅助工具')
 | 
			
		||||
 | 
			
		||||
  // 单击托盘小图标显示应用
 | 
			
		||||
  appTray.on('click', () => {
 | 
			
		||||
    // 显示主程序
 | 
			
		||||
    win.show()
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  // 设置托盘菜单
 | 
			
		||||
  // appTray.setContextMenu(contextMenu)
 | 
			
		||||
 | 
			
		||||
  // appTray.on('double-click', function () {
 | 
			
		||||
  //   log.info('double click')
 | 
			
		||||
  //   win.show()
 | 
			
		||||
  // })
 | 
			
		||||
  appTray.on('right-click', function (event, bounds) {
 | 
			
		||||
    setTimeout(function () {
 | 
			
		||||
      appTray.popUpContextMenu(contextMenu)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,6 +14,7 @@ const modules = {
 | 
			
		|||
export default {
 | 
			
		||||
  install (context) {
 | 
			
		||||
    for (const module in modules) {
 | 
			
		||||
      console.log('install', module)
 | 
			
		||||
      modules[module].install(context)
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,5 +10,5 @@ log4js.configure({
 | 
			
		|||
  appenders: { std: { type: 'stdout' }, file: { type: 'file', pattern: 'yyyy-MM-dd', daysToKeep: 3, filename } },
 | 
			
		||||
  categories: { default: { appenders: ['file', 'std'], level } }
 | 
			
		||||
})
 | 
			
		||||
const logger = log4js.getLogger('server')
 | 
			
		||||
const logger = log4js.getLogger('gui')
 | 
			
		||||
module.exports = logger
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue