mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
fix: 关闭终端启动QQ
This commit is contained in:
@@ -25,6 +25,43 @@ export default function FileEditModal({
|
|||||||
onSave,
|
onSave,
|
||||||
onContentChange
|
onContentChange
|
||||||
}: FileEditModalProps) {
|
}: FileEditModalProps) {
|
||||||
|
// 根据文件后缀返回对应语言
|
||||||
|
const getLanguage = (filePath: string) => {
|
||||||
|
if (filePath.endsWith('.js')) return 'javascript'
|
||||||
|
if (filePath.endsWith('.ts')) return 'typescript'
|
||||||
|
if (filePath.endsWith('.tsx')) return 'tsx'
|
||||||
|
if (filePath.endsWith('.jsx')) return 'jsx'
|
||||||
|
if (filePath.endsWith('.vue')) return 'vue'
|
||||||
|
if (filePath.endsWith('.svelte')) return 'svelte'
|
||||||
|
if (filePath.endsWith('.json')) return 'json'
|
||||||
|
if (filePath.endsWith('.html')) return 'html'
|
||||||
|
if (filePath.endsWith('.css')) return 'css'
|
||||||
|
if (filePath.endsWith('.scss')) return 'scss'
|
||||||
|
if (filePath.endsWith('.less')) return 'less'
|
||||||
|
if (filePath.endsWith('.md')) return 'markdown'
|
||||||
|
if (filePath.endsWith('.yaml') || filePath.endsWith('.yml')) return 'yaml'
|
||||||
|
if (filePath.endsWith('.xml')) return 'xml'
|
||||||
|
if (filePath.endsWith('.sql')) return 'sql'
|
||||||
|
if (filePath.endsWith('.sh')) return 'shell'
|
||||||
|
if (filePath.endsWith('.bat')) return 'bat'
|
||||||
|
if (filePath.endsWith('.php')) return 'php'
|
||||||
|
if (filePath.endsWith('.java')) return 'java'
|
||||||
|
if (filePath.endsWith('.c')) return 'c'
|
||||||
|
if (filePath.endsWith('.cpp')) return 'cpp'
|
||||||
|
if (filePath.endsWith('.h')) return 'h'
|
||||||
|
if (filePath.endsWith('.hpp')) return 'hpp'
|
||||||
|
if (filePath.endsWith('.go')) return 'go'
|
||||||
|
if (filePath.endsWith('.py')) return 'python'
|
||||||
|
if (filePath.endsWith('.rb')) return 'ruby'
|
||||||
|
if (filePath.endsWith('.cs')) return 'csharp'
|
||||||
|
if (filePath.endsWith('.swift')) return 'swift'
|
||||||
|
if (filePath.endsWith('.vb')) return 'vb'
|
||||||
|
if (filePath.endsWith('.lua')) return 'lua'
|
||||||
|
if (filePath.endsWith('.pl')) return 'perl'
|
||||||
|
if (filePath.endsWith('.r')) return 'r'
|
||||||
|
return 'plaintext'
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal size="full" isOpen={isOpen} onClose={onClose}>
|
<Modal size="full" isOpen={isOpen} onClose={onClose}>
|
||||||
<ModalContent>
|
<ModalContent>
|
||||||
@@ -39,6 +76,7 @@ export default function FileEditModal({
|
|||||||
value={file?.content || ''}
|
value={file?.content || ''}
|
||||||
onChange={onContentChange}
|
onChange={onContentChange}
|
||||||
options={{ wordWrap: 'on' }}
|
options={{ wordWrap: 'on' }}
|
||||||
|
language={file?.path ? getLanguage(file.path) : 'plaintext'}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
|
@@ -89,7 +89,11 @@ class TerminalManager {
|
|||||||
instance.sockets.delete(ws);
|
instance.sockets.delete(ws);
|
||||||
if (instance.sockets.size === 0 && !instance.isClosing) {
|
if (instance.sockets.size === 0 && !instance.isClosing) {
|
||||||
instance.isClosing = true;
|
instance.isClosing = true;
|
||||||
instance.pty.kill();
|
if (os.platform() === 'win32') {
|
||||||
|
process.kill(instance.pty.pid);
|
||||||
|
} else {
|
||||||
|
instance.pty.kill();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -145,7 +149,11 @@ class TerminalManager {
|
|||||||
if (instance) {
|
if (instance) {
|
||||||
if (!instance.isClosing) {
|
if (!instance.isClosing) {
|
||||||
instance.isClosing = true;
|
instance.isClosing = true;
|
||||||
instance.pty.kill();
|
if (os.platform() === 'win32') {
|
||||||
|
process.kill(instance.pty.pid);
|
||||||
|
} else {
|
||||||
|
instance.pty.kill();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
instance.sockets.forEach((ws) => ws.close());
|
instance.sockets.forEach((ws) => ws.close());
|
||||||
this.terminals.delete(id);
|
this.terminals.delete(id);
|
||||||
|
Reference in New Issue
Block a user