Skip to content

Commit

Permalink
增加桌面版
Browse files Browse the repository at this point in the history
  • Loading branch information
zhning12 committed Sep 21, 2019
1 parent a2ae28b commit 345df3c
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 11,794 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

dist
package-lock.json
15 changes: 0 additions & 15 deletions deploy.sh

This file was deleted.

49 changes: 49 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// 引入electron并创建一个Browserwindow
const {app, BrowserWindow} = require('electron')
const path = require('path')
const url = require('url')

// 保持window对象的全局引用,避免JavaScript对象被垃圾回收时,窗口被自动关闭.
let mainWindow

function createWindow () {
//创建浏览器窗口,宽高自定义具体大小你开心就好
mainWindow = new BrowserWindow({width: 800, height: 600})

// 加载应用----react 打包
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, './build/index.html'),
protocol: 'file:',
slashes: true
}))
// 加载应用----适用于 react 开发时项目
// mainWindow.loadURL('http://localhost:3000/');

// 打开开发者工具,默认不打开
// mainWindow.webContents.openDevTools()

// 关闭window时触发下列事件.
mainWindow.on('closed', function () {
mainWindow = null
})
}

// 当 Electron 完成初始化并准备创建浏览器窗口时调用此方法
app.on('ready', createWindow)

// 所有窗口关闭时退出应用.
app.on('window-all-closed', function () {
// macOS中除非用户按下 `Cmd + Q` 显式退出,否则应用与菜单栏始终处于活动状态.
if (process.platform !== 'darwin') {
app.quit()
}
})

app.on('activate', function () {
// macOS中点击Dock图标时没有已打开的其余应用窗口时,则通常在应用中重建一个窗口
if (mainWindow === null) {
createWindow()
}
})

// 你可以在这个脚本中续写或者使用require引入独立的js文件.
38 changes: 33 additions & 5 deletions package.json
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
{
"name": "markdown-nice",
"version": "0.1.0",
"author": "markdown-nice",
"description": "a markdown editor with the function of style edition",
"version": "0.0.1",
"private": true,
"dependencies": {
"main": "main.js",
"homepage": ".",
"license": "SEE LICENSE IN LICENSE",
"devDependencies": {
"@babel/core": "7.2.2",
"@svgr/webpack": "^4.1.0",
"@uiw/react-codemirror": "^1.0.19",
Expand Down Expand Up @@ -32,7 +37,6 @@
"fs-extra": "7.0.1",
"highlight.js": "^9.15.6",
"html-webpack-plugin": "4.0.0-alpha.2",
"html2canvas": "^1.0.0-alpha.12",
"identity-obj-proxy": "3.0.0",
"jest": "23.6.0",
"jest-pnp-resolver": "1.0.2",
Expand Down Expand Up @@ -72,13 +76,37 @@
"webpack": "4.28.3",
"webpack-dev-server": "3.1.14",
"webpack-manifest-plugin": "2.0.4",
"workbox-webpack-plugin": "3.6.3"
"workbox-webpack-plugin": "3.6.3",
"electron": "^6.0.10",
"electron-builder": "^21.2.0"
},
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js",
"deploy": "./deploy.sh"
"electron-start": "electron .",
"package": "rm -rf dist && electron-builder --x64"
},
"build": {
"productName": "Markdown Nice",
"appId": "com.mdnice.www",
"mac": {
"target": [
"dmg",
"zip"
]
},
"win": {
"target": [
"nsis",
"zip"
]
},
"files": [
"build",
"main.js",
"package.json"
]
},
"eslintConfig": {
"extends": "react-app"
Expand Down

0 comments on commit 345df3c

Please sign in to comment.