You've already forked AstralRinth
forked from didirus/AstralRinth
feat: normalize paths + add share for crash reports (#5071)
This commit is contained in:
@@ -199,7 +199,11 @@ defineEmits<{
|
|||||||
}>()
|
}>()
|
||||||
|
|
||||||
const isLogFile = computed(() => {
|
const isLogFile = computed(() => {
|
||||||
return props.editingFilePath?.startsWith('logs') || props.editingFilePath?.endsWith('.log')
|
return (
|
||||||
|
props.editingFilePath?.startsWith('logs') ||
|
||||||
|
props.editingFilePath?.startsWith('crash-reports') ||
|
||||||
|
props.editingFilePath?.endsWith('.log')
|
||||||
|
)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -92,18 +92,23 @@ async function loadFileContent(file: { name: string; type: string; path: string
|
|||||||
try {
|
try {
|
||||||
window.scrollTo(0, 0)
|
window.scrollTo(0, 0)
|
||||||
const extension = getFileExtension(file.name)
|
const extension = getFileExtension(file.name)
|
||||||
|
const normalizedPath = file.path.startsWith('/') ? file.path : `/${file.path}`
|
||||||
|
|
||||||
if (file.type === 'file' && isImageFile(extension)) {
|
if (file.type === 'file' && isImageFile(extension)) {
|
||||||
const content = await client.kyros.files_v0.downloadFile(file.path)
|
const content = await client.kyros.files_v0.downloadFile(normalizedPath)
|
||||||
isEditingImage.value = true
|
isEditingImage.value = true
|
||||||
imagePreview.value = content
|
imagePreview.value = content
|
||||||
} else {
|
} else {
|
||||||
isEditingImage.value = false
|
isEditingImage.value = false
|
||||||
const cachedContent = queryClient.getQueryData<string>(['file-content', serverId, file.path])
|
const cachedContent = queryClient.getQueryData<string>([
|
||||||
|
'file-content',
|
||||||
|
serverId,
|
||||||
|
normalizedPath,
|
||||||
|
])
|
||||||
if (cachedContent) {
|
if (cachedContent) {
|
||||||
fileContent.value = cachedContent
|
fileContent.value = cachedContent
|
||||||
} else {
|
} else {
|
||||||
const content = await client.kyros.files_v0.downloadFile(file.path)
|
const content = await client.kyros.files_v0.downloadFile(normalizedPath)
|
||||||
fileContent.value = await content.text()
|
fileContent.value = await content.text()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,7 +153,8 @@ async function saveFileContent(exit: boolean = true) {
|
|||||||
if (!props.file) return
|
if (!props.file) return
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await client.kyros.files_v0.updateFile(props.file.path, fileContent.value)
|
const normalizedPath = props.file.path.startsWith('/') ? props.file.path : `/${props.file.path}`
|
||||||
|
await client.kyros.files_v0.updateFile(normalizedPath, fileContent.value)
|
||||||
|
|
||||||
if (exit) {
|
if (exit) {
|
||||||
await queryClient.invalidateQueries({ queryKey: ['servers', 'detail', serverId] })
|
await queryClient.invalidateQueries({ queryKey: ['servers', 'detail', serverId] })
|
||||||
|
|||||||
Reference in New Issue
Block a user