Skip to content

Commit 4642bfe

Browse files
committed
Merge branch 'release/3.86.1'
2 parents 19ba8b6 + 9714248 commit 4642bfe

File tree

13 files changed

+336
-164
lines changed

13 files changed

+336
-164
lines changed

README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,13 @@ For more information on how to use the following functions, please see [characte
7676

7777
## Changelogs
7878

79-
### [v3.85.1](https://github.com/purocean/yn/releases/tag/v3.85.1) 2025-11-25
79+
### [v3.86.1](https://github.com/purocean/yn/releases/tag/v3.86.1) 2025-12-13
8080

81-
[Windows](https://github.com/purocean/yn/releases/download/v3.85.1/Yank-Note-win-x64-3.85.1.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.85.1/Yank-Note-mac-arm64-3.85.1.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.85.1/Yank-Note-mac-x64-3.85.1.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.85.1/Yank-Note-linux-x86_64-3.85.1.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.85.1/Yank-Note-linux-amd64-3.85.1.deb)
81+
[Windows](https://github.com/purocean/yn/releases/download/v3.86.1/Yank-Note-win-x64-3.86.1.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.86.1/Yank-Note-mac-arm64-3.86.1.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.86.1/Yank-Note-mac-x64-3.86.1.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.86.1/Yank-Note-linux-x86_64-3.86.1.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.86.1/Yank-Note-linux-amd64-3.86.1.deb)
8282

83-
1. feat: Add an option to automatically insert spaces between Chinese and English in the settings
84-
3. feat: Optimize the settings panel interaction, add a suggested list for image storage directories, and add code highlighting to custom CSS styles
85-
2. feat: Improve the interaction of the quick filter, add character highlighting
86-
4. feat: Upgrade Electron to 38.7.1
87-
5. fix: Fix the incorrect error message location in the settings panel
88-
6. feat(plugin): Add the text highlighting utility `ctx.utils.createTextHighlighter`
83+
1. feat: Terminal on Windows uses ConPTY
84+
2. fix: Fixed some issues with HTML parsing
85+
3. feat(plugin): Plugins can use the added XTerm component to connect to terminal
8986

9087
[More release notes](https://github.com/purocean/yn/releases)
9188

README_ZH-CN.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,13 @@
7676

7777
## 更新日志
7878

79-
### [v3.85.1](https://github.com/purocean/yn/releases/tag/v3.85.1) 2025-11-25
79+
### [v3.86.1](https://github.com/purocean/yn/releases/tag/v3.86.1) 2025-12-13
8080

81-
[Windows](https://github.com/purocean/yn/releases/download/v3.85.1/Yank-Note-win-x64-3.85.1.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.85.1/Yank-Note-mac-arm64-3.85.1.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.85.1/Yank-Note-mac-x64-3.85.1.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.85.1/Yank-Note-linux-x86_64-3.85.1.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.85.1/Yank-Note-linux-amd64-3.85.1.deb)
81+
[Windows](https://github.com/purocean/yn/releases/download/v3.86.1/Yank-Note-win-x64-3.86.1.exe) | [macOS arm64](https://github.com/purocean/yn/releases/download/v3.86.1/Yank-Note-mac-arm64-3.86.1.dmg) | [macOS x64](https://github.com/purocean/yn/releases/download/v3.86.1/Yank-Note-mac-x64-3.86.1.dmg) | [Linux AppImage](https://github.com/purocean/yn/releases/download/v3.86.1/Yank-Note-linux-x86_64-3.86.1.AppImage) | [Linux deb](https://github.com/purocean/yn/releases/download/v3.86.1/Yank-Note-linux-amd64-3.86.1.deb)
8282

83-
1. feat: 设置中增加自动在中英文之间添加空格选项
84-
3. feat: 优化设置面板交互,图片存放目录增加建议列表,自定义 CSS 样式 增加代码高亮
85-
2. feat: 快捷筛选器交互,增加字符高亮
86-
4. feat: 升级 Electron 到 38.7.1
87-
5. fix: 修复设置面板错误提示位置不正确问题
88-
6. feat(plugin): 增加 `ctx.utils.createTextHighlighter` 文本高亮工具函数
83+
1. feat: Windows 上终端使用 ConPTY
84+
2. fix: 修复解析 HTML 的一些问题
85+
3. feat(plugin): 插件中可使用增加 XTerm 组件连接终端
8986

9087
[更多发布说明](https://github.com/purocean/yn/releases)
9188

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "yank.note",
3-
"version": "3.85.1",
3+
"version": "3.86.1",
44
"description": "Yank Note: A highly extensible Markdown editor, designed for productivity.",
55
"main": "dist/main/app.js",
66
"license": "AGPL-3.0",
@@ -101,6 +101,10 @@
101101
"@vue/compiler-sfc": "^3.5.13",
102102
"@vue/eslint-config-standard": "^8.0.1",
103103
"@vue/eslint-config-typescript": "^13.0.0",
104+
"@xterm/addon-fit": "^0.10.0",
105+
"@xterm/addon-web-links": "^0.11.0",
106+
"@xterm/addon-webgl": "^0.18.0",
107+
"@xterm/xterm": "^5.5.0",
104108
"autoprefixer": "^10.4.16",
105109
"canvas-confetti": "^1.6.0",
106110
"crypto-js": "^4.2.0",
@@ -151,8 +155,6 @@
151155
"vite": "^6.1.6",
152156
"vue": "^3.5.13",
153157
"vue-tsc": "^2.2.0",
154-
"xterm": "^4.18.0",
155-
"xterm-addon-fit": "^0.5.0",
156158
"xterm-theme": "^1.1.0"
157159
},
158160
"optionalDependencies": {

src/main/app.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as path from 'path'
55
import * as os from 'os'
66
import * as fs from 'fs-extra'
77
import * as yargs from 'yargs'
8-
import httpServer from './server'
8+
import httpServer, { killPtyProcesses } from './server'
99
import store from './storage'
1010
import { APP_NAME } from './constant'
1111
import { getTrayMenus, getMainMenus } from './menus'
@@ -406,6 +406,7 @@ const quit = async () => {
406406
}
407407

408408
await ensureDocumentSaved()
409+
await killPtyProcesses()
409410

410411
win.destroy()
411412
app.quit()

src/main/server/index.ts

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,42 @@ const wrapper = async (ctx: any, next: any, fun: any) => {
729729
}
730730
}
731731

732+
const ptyProcesses: NodePty.IPty[] = []
733+
734+
export async function killPtyProcesses (pty?: NodePty.IPty) {
735+
const kill = async (ptyProcess: NodePty.IPty) => {
736+
const index = ptyProcesses.indexOf(ptyProcess)
737+
if (index >= 0) {
738+
ptyProcesses.splice(index, 1)
739+
} else {
740+
// already killed
741+
return
742+
}
743+
744+
const promise = Promise.race([
745+
new Promise<void>((resolve) => {
746+
ptyProcess.onExit(() => resolve())
747+
}),
748+
new Promise<void>((resolve) => {
749+
setTimeout(() => resolve(), 500)
750+
})
751+
])
752+
753+
ptyProcess.kill()
754+
755+
await promise
756+
}
757+
758+
if (pty) {
759+
await kill(pty)
760+
} else {
761+
for (const ptyProcess of [...ptyProcesses]) {
762+
await kill(ptyProcess)
763+
}
764+
ptyProcesses.length = 0
765+
}
766+
}
767+
732768
const server = (port = 3000) => {
733769
const app = new Koa()
734770

@@ -798,17 +834,20 @@ const server = (port = 3000) => {
798834
}
799835

800836
if (pty) {
837+
const env = JSON.parse(socket.handshake.query.env || '{}')
838+
801839
const ptyProcess = pty.spawn(shell.getShell(), [], {
802840
name: 'xterm-color',
803841
cols: 80,
804842
rows: 24,
805843
cwd: socket.handshake.query.cwd || HOME_DIR,
806-
env: process.env,
807-
useConpty: false,
844+
env: { ...process.env, ...env },
808845
})
809846

847+
ptyProcesses.push(ptyProcess)
848+
810849
const kill = () => {
811-
ptyProcess.kill()
850+
killPtyProcesses(ptyProcess)
812851
}
813852

814853
ptyProcess.onData((data: any) => socket.emit('output', data))

src/renderer/Main.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<SearchPanel />
1414
</template>
1515
<template v-slot:terminal>
16-
<Xterm @hide="hideXterm" />
16+
<Terminal @hide="hideXterm" />
1717
</template>
1818
<template v-slot:editor>
1919
<Editor />
@@ -53,7 +53,7 @@ import SvgIcon from '@fe/components/SvgIcon.vue'
5353
import TitleBar from '@fe/components/TitleBar.vue'
5454
import StatusBar from '@fe/components/StatusBar.vue'
5555
import Tree from '@fe/components/Tree.vue'
56-
import Xterm from '@fe/components/Xterm.vue'
56+
import Terminal from '@fe/components/Terminal.vue'
5757
import FileTabs from '@fe/components/FileTabs.vue'
5858
import Editor from '@fe/components/Editor.vue'
5959
import Previewer from '@fe/components/Previewer.vue'
@@ -78,7 +78,7 @@ export default defineComponent({
7878
TitleBar,
7979
StatusBar,
8080
Tree,
81-
Xterm,
81+
Terminal,
8282
FileTabs,
8383
Editor,
8484
Previewer,
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<template>
2+
<div class="terminal">
3+
<div class="hide" @click="$emit('hide')">
4+
<SvgIcon style="width: 20px; height: 20px" name="chevron-down" />
5+
</div>
6+
<x-term ref="refXterm" />
7+
</div>
8+
</template>
9+
10+
<script lang="ts">
11+
import { defineComponent, nextTick, onBeforeMount, onBeforeUnmount, ref } from 'vue'
12+
import { getLogger, sleep } from '@fe/utils'
13+
import { registerAction, removeAction } from '@fe/core/action'
14+
import { FLAG_DISABLE_XTERM } from '@fe/support/args'
15+
import { toggleXterm } from '@fe/services/layout'
16+
import type { Components } from '@fe/types'
17+
import SvgIcon from './SvgIcon.vue'
18+
import XTerm from './Xterm.vue'
19+
import store from '@fe/support/store'
20+
21+
const logger = getLogger('component-terminal')
22+
23+
export default defineComponent({
24+
name: 'terminal',
25+
components: { SvgIcon, XTerm },
26+
setup () {
27+
const refXterm = ref<Components.XTerm.Ref | null>(null)
28+
29+
function init (opts?: Components.XTerm.InitOpts) {
30+
refXterm.value?.init({
31+
...opts,
32+
cwd: opts?.cwd || store.state.currentRepo?.path || '',
33+
onDisconnect: () => {
34+
toggleXterm(false)
35+
},
36+
})
37+
}
38+
39+
function input (data: string, addNewLine?: boolean) {
40+
refXterm.value?.input(data, addNewLine)
41+
}
42+
43+
async function runInXterm (cmd: { code: string, start?: string, exit?: string } | string) {
44+
if (FLAG_DISABLE_XTERM) {
45+
logger.warn('terminal disabled')
46+
return
47+
}
48+
49+
toggleXterm(true)
50+
51+
await nextTick()
52+
53+
init()
54+
55+
if (typeof cmd === 'string') {
56+
cmd = { code: cmd }
57+
}
58+
59+
if (cmd.start) {
60+
input(cmd.start, true)
61+
// wait for child process ready.
62+
await sleep(400)
63+
}
64+
65+
cmd.code.split('\n').forEach(x => {
66+
input(x, true)
67+
})
68+
69+
if (cmd.exit) {
70+
input(cmd.exit, true)
71+
}
72+
}
73+
74+
onBeforeMount(() => {
75+
registerAction({ name: 'xterm.run', handler: runInXterm })
76+
registerAction({ name: 'xterm.init', handler: init })
77+
})
78+
79+
onBeforeUnmount(() => {
80+
removeAction('xterm.run')
81+
removeAction('xterm.init')
82+
})
83+
84+
return {
85+
refXterm,
86+
}
87+
},
88+
})
89+
</script>
90+
91+
<style scoped>
92+
.terminal {
93+
box-sizing: border-box;
94+
padding: 5px;
95+
background: var(--g-color-98);
96+
border: 1px solid var(--g-color-88);
97+
flex: 0 0 auto;
98+
width: 100%;
99+
height: 100%;
100+
padding-right: 0;
101+
padding-top: 0;
102+
border-right: 0;
103+
}
104+
105+
.hide {
106+
position: absolute;
107+
top: -6px;
108+
right: 0;
109+
z-index: 10;
110+
background: var(--g-color-75);
111+
border-bottom-left-radius: var(--g-border-radius);
112+
border-bottom-right-radius: var(--g-border-radius);
113+
width: 30px;
114+
height: 30px;
115+
display: flex;
116+
align-items: center;
117+
justify-content: center;
118+
cursor: pointer;
119+
transform: scaleY(0.6);
120+
border: 8px solid transparent;
121+
box-sizing: border-box;
122+
color: var(--g-color-20);
123+
opacity: 0;
124+
transition: opacity .2s;
125+
}
126+
127+
.terminal:hover .hide {
128+
opacity: 1;
129+
}
130+
131+
.hide:hover {
132+
background: var(--g-color-65);
133+
}
134+
</style>

0 commit comments

Comments
 (0)