feat: support blockly online debug
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
e68c17576a
commit
1a546470a5
@ -6,6 +6,7 @@ import { plugin as pluginApi, server, task } from '@ccms/api'
|
|||||||
import { plugin, interfaces, cmd } from '@ccms/plugin'
|
import { plugin, interfaces, cmd } from '@ccms/plugin'
|
||||||
import { inject, ContainerInstance, Container } from '@ccms/container'
|
import { inject, ContainerInstance, Container } from '@ccms/container'
|
||||||
import io, { Server as SocketIOServer, Socket as SocketIOSocket } from '@ccms/websocket'
|
import io, { Server as SocketIOServer, Socket as SocketIOSocket } from '@ccms/websocket'
|
||||||
|
import * as fs from '@ccms/common/dist/fs'
|
||||||
|
|
||||||
const suffixMap = {
|
const suffixMap = {
|
||||||
ts: 'typescript',
|
ts: 'typescript',
|
||||||
@ -25,6 +26,8 @@ export class MiaoConsole extends interfaces.Plugin {
|
|||||||
private task: task.TaskManager
|
private task: task.TaskManager
|
||||||
@inject(pluginApi.PluginManager)
|
@inject(pluginApi.PluginManager)
|
||||||
private pluginManager: pluginApi.PluginManager
|
private pluginManager: pluginApi.PluginManager
|
||||||
|
@inject(pluginApi.PluginFolder)
|
||||||
|
private pluginFolder: string;
|
||||||
|
|
||||||
private pipeline: any;
|
private pipeline: any;
|
||||||
private socketIOServer: SocketIOServer;
|
private socketIOServer: SocketIOServer;
|
||||||
@ -92,6 +95,24 @@ export class MiaoConsole extends interfaces.Plugin {
|
|||||||
client.on('edit', (file: string, fn) => {
|
client.on('edit', (file: string, fn) => {
|
||||||
fn && fn(base.read(file), suffixMap[file.split('.', 2)[1]])
|
fn && fn(base.read(file), suffixMap[file.split('.', 2)[1]])
|
||||||
})
|
})
|
||||||
|
client.on('save', (name: string, content: string, fn) => {
|
||||||
|
this.logger.console(`§6客户端 §b${client.id} §6请求更新插件 §a${name} §6...`)
|
||||||
|
let file = fs.concat(root, this.pluginFolder, name + '.js')
|
||||||
|
if (!fs.exists(file)) { return fn('§6插件 §a' + name + ' §6尚未安装 §c请先创建空文件 或安装插件!') }
|
||||||
|
try {
|
||||||
|
base.save(file, content)
|
||||||
|
this.pluginManager.reload(name);
|
||||||
|
fn('§6插件 §a' + name + ' §6更新成功!')
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error(error)
|
||||||
|
fn('§6插件 §a' + name + ' §4更新异常 错误: ' + error)
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
client.on('error', (error) => {
|
||||||
|
this.logger.console(`§6客户端 §b${client.id} §c触发异常: ${error}`)
|
||||||
|
this.logger.error(error)
|
||||||
|
})
|
||||||
client.on('disconnect', () => {
|
client.on('disconnect', () => {
|
||||||
this.logger.console(`§6客户端 §b${client.id} §c断开连接...`)
|
this.logger.console(`§6客户端 §b${client.id} §c断开连接...`)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user