in studio/components/tab/index.tsx [34:92]
setup() {
const { t } = useLocale()
const dialog = useDialog()
const fileStore = useFileStore()
const {
setCurrentLogHeight,
getEditorHeight,
getLogHeight,
setFileLogHeight
} = useLogHeight()
const webSocketStore = useWebSocketStore()
const { isFullscreen, toggleFullscreen } = useFullscreen()
const updateContent = (value: number) => {
fileStore.changeTab(value)
setCurrentLogHeight()
}
const onClose = (fileId: number) => {
fileStore.closeFile(fileId)
webSocketStore.close(fileId)
setFileLogHeight(fileId, 0)
}
const handleClose = (fileId: number) => {
const file = fileStore.getFile(fileId)
if (file.content !== file.oldContent) {
dialog.warning({
title: t('close_tips'),
content: t('close_content'),
action: () => (
<NSpace>
<NButton
onClick={async () => {
saveFile(file.id, { content: file.content })
fileStore.updateContent(file)
dialog.destroyAll()
}}
>
{t('save')}
</NButton>
<NButton
onClick={() => {
onClose(fileId)
dialog.destroyAll()
}}
>
{t('force_close')}
</NButton>
<NButton onClick={() => dialog.destroyAll()} type='primary'>
{t('cannel')}
</NButton>
</NSpace>
)
})
} else {
onClose(fileId)
}
}