Skip to content

Commit

Permalink
macOS 支持
Browse files Browse the repository at this point in the history
  • Loading branch information
xiajingren committed Mar 5, 2022
1 parent 6666a54 commit 00c52f6
Show file tree
Hide file tree
Showing 14 changed files with 19,697 additions and 786 deletions.
20,393 changes: 19,615 additions & 778 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xhznl-todo-list",
"version": "0.2.0",
"version": "0.2.1",
"private": true,
"author": "xhznl",
"description": "a todo list application",
Expand All @@ -18,6 +18,7 @@
"core-js": "^3.6.5",
"dayjs": "^1.9.6",
"electron-updater": "^4.3.5",
"electron-builder":"^22.10.5",
"exceljs": "^4.2.0",
"fs-extra": "^9.0.1",
"lodash-id": "^0.14.0",
Expand All @@ -35,7 +36,7 @@
"@vue/cli-service": "~4.5.0",
"@vue/eslint-config-prettier": "^6.0.0",
"babel-eslint": "^10.1.0",
"electron": "^9.0.0",
"electron": "^11.0.0",
"electron-devtools-installer": "^3.1.0",
"eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.1.3",
Expand Down
9 changes: 9 additions & 0 deletions public/entitlements.mac.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key><true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key><true/>
<key>com.apple.security.cs.disable-library-validation</key><true/>
</dict>
</plist>
1 change: 1 addition & 0 deletions public/license_zh_CN.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
我不知会遇见你。
Binary file modified public/logo.icns
Binary file not shown.
Binary file modified public/logo.ico
Binary file not shown.
Binary file removed public/tary.png
Binary file not shown.
Binary file added public/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/tray.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { createProtocol } from "vue-cli-plugin-electron-builder/lib";
//import installExtension, { VUEJS_DEVTOOLS } from "electron-devtools-installer";
const isDevelopment = process.env.NODE_ENV !== "production";

import { initExtra, createTray } from "@/utils/backgroundExtra";
import { initExtra, createTray, createAppMenu } from "@/utils/backgroundExtra";

import { autoUpdater } from "electron-updater";

Expand All @@ -28,6 +28,8 @@ protocol.registerSchemesAsPrivileged([
{ scheme: "app", privileges: { secure: true, standard: true } },
]);

createAppMenu();

async function createWindow() {
// Create the browser window.
win = new BrowserWindow({
Expand Down Expand Up @@ -129,6 +131,7 @@ function init() {
createWindow();
initExtra();
createTray(showWindow);
//createAppMenu();
}

// Exit cleanly on request from parent process in development mode.
Expand Down
27 changes: 26 additions & 1 deletion src/utils/backgroundExtra.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ export function initExtra() {
}

export function createTray(setPosition) {
tray = new Tray(path.join(__static, "./tary.png"));
tray = new Tray(
path.join(
__static,
process.platform !== "darwin" ? "./tray.png" : "./tray-mac.png"
)
);

const contextMenu = Menu.buildFromTemplate([
{
Expand Down Expand Up @@ -89,6 +94,26 @@ export function createTray(setPosition) {
});
}

export function createAppMenu() {
const template = [
// { role: 'appMenu' }
...(process.platform === "darwin"
? [
{
label: app.name,
submenu: [
{ role: "about", label: "关于" },
{ type: "separator" },
{ role: "quit", label: "退出" },
],
},
]
: []),
];
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
}

function setOpenAtLogin(openAtLogin) {
if (app.isPackaged) {
app.setLoginItemSettings({
Expand Down
43 changes: 39 additions & 4 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,53 @@ module.exports = {
appId: "xhznl-todo-list",
productName: "xhznl-todo-list",
copyright: "Copyright © 2020 xhznl",
// directories: {
// output: "./dist", //输出文件路径
// },
directories: {
buildResources: "./public",
// output: "./dist", //输出文件路径
},
electronDownload: {
mirror: "https://npm.taobao.org/mirrors/electron/",
},
win: {
icon: "./public/logo.ico",
target: "nsis",
target: [
{
target: "nsis",
arch: ["x64", "ia32"],
},
],
},
nsis: {
oneClick: false,
allowToChangeInstallationDirectory: true,
shortcutName: "xhznl-todo-list",
},
dmg: {
contents: [
{
x: 410,
y: 150,
type: "link",
path: "/Applications",
},
{
x: 130,
y: 150,
type: "file",
},
],
},
mac: {
icon: "./public/logo.icns",
hardenedRuntime: true,
gatekeeperAssess: false,
entitlements: "./public/entitlements.mac.plist",
entitlementsInherit: "./public/entitlements.mac.plist",
target: {
target: "default",
arch: "universal",
},
},
publish: ["github"],
// releaseInfo: {
// releaseName: "",
Expand Down

0 comments on commit 00c52f6

Please sign in to comment.