mirror of
https://github.com/purocean/yn.git
synced 2026-09-24 15:46:02 +08:00
Merge branch 'release/2.3.2'
This commit is contained in:
@@ -142,12 +142,15 @@ yarn run start
|
||||
## 更新日志
|
||||
[最新发布](https://github.com/purocean/yn/releases)
|
||||
|
||||
### [v2.3.1](https://github.com/purocean/yn/releases/tag/v2.3.1) 2020-04-27
|
||||
1. 增加配置监听端口命令行参数 `--port=8080`
|
||||
### [v2.3.2](https://github.com/purocean/yn/releases/tag/v2.3.2) 2020-04-27
|
||||
1. 调整启动命令行参数
|
||||
|
||||
<details>
|
||||
<summary>展开查看更多版本记录</summary>
|
||||
|
||||
### [v2.3.1](https://github.com/purocean/yn/releases/tag/v2.3.1) 2020-04-27
|
||||
1. 增加配置监听端口命令行参数 `--port=8080`
|
||||
|
||||
### [v2.3.0](https://github.com/purocean/yn/releases/tag/v2.3.0) 2020-04-27
|
||||
1. 增加启动命令行参数
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer" v-if="showFooter">
|
||||
<div class="footer" v-show="showFooter">
|
||||
<slot name="footer"></slot>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -124,18 +124,7 @@ export default {
|
||||
commit('setMarkedFiles', files)
|
||||
},
|
||||
async fetchRepositories ({ commit }) {
|
||||
const initReposParam = window.$args().get('init-repos')
|
||||
|
||||
let initRepos = null
|
||||
if (initReposParam) {
|
||||
try {
|
||||
initRepos = JSON.parse(initReposParam)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
|
||||
const repos = initRepos || (await file.fetchRepositories())
|
||||
const repos = await file.fetchRepositories()
|
||||
commit('setRepositories', repos)
|
||||
},
|
||||
async fetchTree ({ commit }, repo) {
|
||||
|
||||
+2
-1
@@ -301,9 +301,10 @@ xml 代码块 第一行注释需要有 `--drawio--` 文字
|
||||
名称 | 作用 | 默认值 | 说明 | 示例
|
||||
----------------- | ------------ | ----- | ----------------------- | ----
|
||||
--port | 服务器监听端口 | 3044 | 端口 | --port=8080
|
||||
--disable-tray | 禁用常驻托盘 | false | true/false | --disable-tray
|
||||
--readonly | 编辑器只读 | false | true/false | --readonly
|
||||
--show-status-bar | 显示状态栏 | true | true/false | --show-status-bar=false
|
||||
--init-repos | 初始仓库列表 | 无 | json 字符串,注意命令行转义 | --init-repos='{\"test\":\"D:/test\",\"b\":\"E:/test\"}'
|
||||
--data-dir | 数据目录 | 无 | 目录路径字符串 | --data-dir='./.data'
|
||||
--init-repo | 初始仓库名 | 无 | 字符串 | --init-repo='test'
|
||||
--init-file | 加载文件路径 | 无 | 文件路径,相对于仓库路径 | --init-file='/1.md'
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yank.note.yang",
|
||||
"version": "2.3.1",
|
||||
"version": "2.3.2",
|
||||
"description": "Yank Note 一款面向程序员的 Markdown 笔记应用",
|
||||
"main": "dist/app.js",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
+116
-112
@@ -10,6 +10,7 @@ const opn = require('opn')
|
||||
|
||||
let isDev = false
|
||||
|
||||
const showTray = !(yargs.argv['disable-tray'])
|
||||
const backendPort = Number(yargs.argv.port) || 3044
|
||||
const devFrontendPort = 8066
|
||||
|
||||
@@ -17,7 +18,6 @@ const getUrl = () => {
|
||||
const args = Object.entries(yargs.argv).filter(x => [
|
||||
'readonly',
|
||||
'show-status-bar',
|
||||
'init-repos',
|
||||
'init-repo',
|
||||
'init-file',
|
||||
].includes(x[0]))
|
||||
@@ -66,8 +66,10 @@ const createWindow = () => {
|
||||
}, 0)
|
||||
|
||||
win.on('close', e => {
|
||||
hide()
|
||||
e.preventDefault()
|
||||
if (showTray) {
|
||||
hide()
|
||||
e.preventDefault()
|
||||
}
|
||||
})
|
||||
|
||||
win.on('closed', () => {
|
||||
@@ -176,116 +178,118 @@ if (!gotTheLock) {
|
||||
'open-in-browser': () => opn(getUrl())
|
||||
})
|
||||
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
type: 'normal',
|
||||
label: '打开主界面',
|
||||
accelerator: getAccelerator('show-main-window'),
|
||||
click: () => {
|
||||
showWindow()
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'normal',
|
||||
label: '浏览器中打开',
|
||||
accelerator: getAccelerator('open-in-browser'),
|
||||
click: () => {
|
||||
opn(getUrl())
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'normal',
|
||||
label: '打开主目录',
|
||||
click: () => {
|
||||
opn(USER_DIR)
|
||||
}
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
type: 'submenu',
|
||||
label: '开发',
|
||||
submenu: [
|
||||
{
|
||||
type: 'radio',
|
||||
checked: !isDev,
|
||||
label: `正式端口(${backendPort})`,
|
||||
click: () => {
|
||||
isDev = false
|
||||
reload()
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'radio',
|
||||
checked: isDev,
|
||||
label: `开发端口(${devFrontendPort})`,
|
||||
click: () => {
|
||||
isDev = true
|
||||
reload()
|
||||
}
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
type: 'normal',
|
||||
label: '重载页面',
|
||||
click: () => {
|
||||
reload()
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'normal',
|
||||
label: '主窗口开发工具',
|
||||
click: () => {
|
||||
win && win.webContents.openDevTools()
|
||||
}
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
type: 'normal',
|
||||
label: '强制重新启动',
|
||||
click: () => {
|
||||
app.relaunch()
|
||||
app.exit(1)
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'normal',
|
||||
label: '强制退出',
|
||||
click: () => {
|
||||
app.exit(1)
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'normal',
|
||||
label: 'GitHub',
|
||||
click: () => {
|
||||
opn('https://github.com/purocean/yn')
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'normal',
|
||||
label: `版本 ${app.getVersion()}`,
|
||||
click: () => {
|
||||
updater.checkForUpdates()
|
||||
}
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
type: 'normal',
|
||||
label: '退出',
|
||||
click: () => {
|
||||
setTimeout(() => {
|
||||
quit()
|
||||
}, 200)
|
||||
}
|
||||
},
|
||||
])
|
||||
if (showTray) {
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
type: 'normal',
|
||||
label: '打开主界面',
|
||||
accelerator: getAccelerator('show-main-window'),
|
||||
click: () => {
|
||||
showWindow()
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'normal',
|
||||
label: '浏览器中打开',
|
||||
accelerator: getAccelerator('open-in-browser'),
|
||||
click: () => {
|
||||
opn(getUrl())
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'normal',
|
||||
label: '打开主目录',
|
||||
click: () => {
|
||||
opn(USER_DIR)
|
||||
}
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
type: 'submenu',
|
||||
label: '开发',
|
||||
submenu: [
|
||||
{
|
||||
type: 'radio',
|
||||
checked: !isDev,
|
||||
label: `正式端口(${backendPort})`,
|
||||
click: () => {
|
||||
isDev = false
|
||||
reload()
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'radio',
|
||||
checked: isDev,
|
||||
label: `开发端口(${devFrontendPort})`,
|
||||
click: () => {
|
||||
isDev = true
|
||||
reload()
|
||||
}
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
type: 'normal',
|
||||
label: '重载页面',
|
||||
click: () => {
|
||||
reload()
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'normal',
|
||||
label: '主窗口开发工具',
|
||||
click: () => {
|
||||
win && win.webContents.openDevTools()
|
||||
}
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
type: 'normal',
|
||||
label: '强制重新启动',
|
||||
click: () => {
|
||||
app.relaunch()
|
||||
app.exit(1)
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'normal',
|
||||
label: '强制退出',
|
||||
click: () => {
|
||||
app.exit(1)
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
type: 'normal',
|
||||
label: 'GitHub',
|
||||
click: () => {
|
||||
opn('https://github.com/purocean/yn')
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'normal',
|
||||
label: `版本 ${app.getVersion()}`,
|
||||
click: () => {
|
||||
updater.checkForUpdates()
|
||||
}
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
type: 'normal',
|
||||
label: '退出',
|
||||
click: () => {
|
||||
setTimeout(() => {
|
||||
quit()
|
||||
}, 200)
|
||||
}
|
||||
},
|
||||
])
|
||||
|
||||
tray = new Tray(path.join(__dirname, './assets/icon.png'))
|
||||
tray.setToolTip('Yank Note 一款面向程序员的 Markdown 编辑器')
|
||||
tray.on('click', showWindow)
|
||||
tray.setContextMenu(contextMenu)
|
||||
tray = new Tray(path.join(__dirname, './assets/icon.png'))
|
||||
tray.setToolTip('Yank Note 一款面向程序员的 Markdown 编辑器')
|
||||
tray.on('click', showWindow)
|
||||
tray.setContextMenu(contextMenu)
|
||||
}
|
||||
|
||||
updater.init(() => {
|
||||
// 立即升级,退出程序
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import * as path from 'path'
|
||||
import * as os from 'os'
|
||||
import * as yargs from 'yargs'
|
||||
import { isWsl, toWslPath, getWinHomePath } from './wsl'
|
||||
|
||||
const homedir = isWsl ? toWslPath(getWinHomePath()) : os.homedir()
|
||||
|
||||
export const HOME_DIR = homedir
|
||||
export const USER_DIR = path.join(homedir, 'yank-note')
|
||||
export const USER_DIR = path.resolve((yargs.argv['data-dir'] as any) || path.join(homedir, 'yank-note'))
|
||||
export const TRASH_DIR = path.join(USER_DIR, 'trash')
|
||||
export const MAIN_REPO_DIR = path.join(USER_DIR, 'main')
|
||||
export const CONFIG_FILE = path.join(USER_DIR, 'config.json')
|
||||
|
||||
@@ -3,11 +3,13 @@ import * as xfs from 'fs-extra'
|
||||
import * as path from 'path'
|
||||
import * as crypto from 'crypto'
|
||||
import * as NaturalOrderby from 'natural-orderby'
|
||||
import * as yargs from 'yargs'
|
||||
import * as wsl from './wsl'
|
||||
import mark, { MarkedFile } from './mark'
|
||||
import repository from './repository'
|
||||
const opn = require('opn')
|
||||
|
||||
const readonly = !!(yargs.argv['readonly'])
|
||||
const isWsl = wsl.isWsl
|
||||
const ignorePath = /node_modules/
|
||||
|
||||
@@ -117,6 +119,8 @@ const read = (repo: string, p: string) => {
|
||||
}
|
||||
|
||||
const write = (repo: string, p: string, content: any) => {
|
||||
if (readonly) throw new Error('只读模式')
|
||||
|
||||
p = resolvePath(p, repo)
|
||||
|
||||
mkdirPSync(path.dirname(p))
|
||||
@@ -127,6 +131,8 @@ const write = (repo: string, p: string, content: any) => {
|
||||
}
|
||||
|
||||
const rm = (repo: string, p: string) => {
|
||||
if (readonly) throw new Error('只读模式')
|
||||
|
||||
if (resolvePath(p) !== resolvePath('', repo)) {
|
||||
const newPath = path.join(repository.getTrashPath(repo), p.replace(/\.\./g, '')) + '.' + (new Date).getTime()
|
||||
|
||||
@@ -141,6 +147,8 @@ const rm = (repo: string, p: string) => {
|
||||
}
|
||||
|
||||
const mv = (repo: string, oldPath: string, newPath: string) => {
|
||||
if (readonly) throw new Error('只读模式')
|
||||
|
||||
oldPath = resolvePath(oldPath, repo)
|
||||
newPath = resolvePath(newPath, repo)
|
||||
|
||||
@@ -169,6 +177,7 @@ const checkHash = (repo: string, p: string, oldHash: string) => {
|
||||
}
|
||||
|
||||
const upload = (repo: string, file: any, path: string) => {
|
||||
if (readonly) throw new Error('只读模式')
|
||||
write(repo, path, fs.readFileSync(file.path))
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ const getPath = (name: string) => {
|
||||
return /^[a-zA-Z]:/.test(p) ? toWslPath(p) : path.join(MAIN_REPO_DIR, p)
|
||||
}
|
||||
|
||||
return path.isAbsolute(p) ? p : path.join(MAIN_REPO_DIR, p)
|
||||
return path.isAbsolute(p) ? p : path.resolve(p)
|
||||
}
|
||||
|
||||
const getTrashPath = (name: string) => {
|
||||
|
||||
Reference in New Issue
Block a user