mirror of
https://github.com/purocean/yn.git
synced 2026-10-12 23:31:39 +08:00
内置终端增加自定义shell功能
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import * as fs from 'fs'
|
||||
import * as os from 'os'
|
||||
import * as path from 'path'
|
||||
import * as Koa from 'koa'
|
||||
import * as bodyParser from 'koa-body'
|
||||
@@ -15,6 +14,7 @@ import dataRepository from './repository'
|
||||
import run from './run'
|
||||
import convert from './convert'
|
||||
import plantuml from './plantuml'
|
||||
import shell from './shell'
|
||||
|
||||
const result = (status = 'ok', message = '操作成功', data: any = null) => {
|
||||
return { status, message, data }
|
||||
@@ -203,7 +203,7 @@ const server = (port = 3000) => {
|
||||
const io = require('socket.io')(server, {path: '/ws'})
|
||||
|
||||
io.on('connection', (socket: any) => {
|
||||
const ptyProcess = pty.spawn(os.platform() === 'win32' ? 'cmd.exe' : 'bash', [], {
|
||||
const ptyProcess = pty.spawn(shell.getShell(), [], {
|
||||
name: 'xterm-color',
|
||||
cols: 80,
|
||||
rows: 24,
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import config from './config'
|
||||
import * as os from 'os'
|
||||
|
||||
const configKey = 'shell'
|
||||
|
||||
const defaultVal = os.platform() === 'win32' ? 'cmd.exe' : 'bash'
|
||||
|
||||
const getShell = () => {
|
||||
return config.get(configKey, defaultVal)
|
||||
}
|
||||
|
||||
export default {
|
||||
getShell,
|
||||
}
|
||||
Reference in New Issue
Block a user