fix: log sharing in app + clearing (#5801)
* fix: log wiping app * fix: share modal rounded
This commit is contained in:
@@ -73,6 +73,12 @@ function invalidate(profilePathId: string): void {
|
|||||||
entry.logList = null
|
entry.logList = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function clearLive(profilePathId: string): Promise<void> {
|
||||||
|
const entry = getOrCreate(profilePathId)
|
||||||
|
entry.liveConsole.clear()
|
||||||
|
await clear_log_buffer(profilePathId).catch(() => {})
|
||||||
|
}
|
||||||
|
|
||||||
async function destroy(profilePathId: string): Promise<void> {
|
async function destroy(profilePathId: string): Promise<void> {
|
||||||
instances.delete(profilePathId)
|
instances.delete(profilePathId)
|
||||||
await clear_log_buffer(profilePathId).catch(() => {})
|
await clear_log_buffer(profilePathId).catch(() => {})
|
||||||
@@ -87,6 +93,7 @@ export function useInstanceConsole(profilePathId: string) {
|
|||||||
getHistoricalLogs: (instancePath: string) => getHistoricalLogs(profilePathId, instancePath),
|
getHistoricalLogs: (instancePath: string) => getHistoricalLogs(profilePathId, instancePath),
|
||||||
getHistoricalContent: (filename: string) => getHistoricalContent(profilePathId, filename),
|
getHistoricalContent: (filename: string) => getHistoricalContent(profilePathId, filename),
|
||||||
invalidate: () => invalidate(profilePathId),
|
invalidate: () => invalidate(profilePathId),
|
||||||
|
clearLive: () => clearLive(profilePathId),
|
||||||
destroy: () => destroy(profilePathId),
|
destroy: () => destroy(profilePathId),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ const {
|
|||||||
getHistoricalLogs,
|
getHistoricalLogs,
|
||||||
getHistoricalContent,
|
getHistoricalContent,
|
||||||
invalidate,
|
invalidate,
|
||||||
|
clearLive,
|
||||||
} = useInstanceConsole(profilePathId.value)
|
} = useInstanceConsole(profilePathId.value)
|
||||||
|
|
||||||
await hydrate()
|
await hydrate()
|
||||||
@@ -159,7 +160,8 @@ provideConsoleManager({
|
|||||||
showCommandInput: false,
|
showCommandInput: false,
|
||||||
loading: ref(false),
|
loading: ref(false),
|
||||||
onClear: () => {
|
onClear: () => {
|
||||||
activeConsole.value.clear()
|
if (!isLive.value) return
|
||||||
|
void clearLive()
|
||||||
},
|
},
|
||||||
onDelete: deleteSelectedLog,
|
onDelete: deleteSelectedLog,
|
||||||
deleteDisabled,
|
deleteDisabled,
|
||||||
|
|||||||
@@ -23,8 +23,50 @@ export class VerboseLoggingFeature extends AbstractFeature {
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.debug(`${prefix} ${context.url} FAILED`)
|
const details = formatErrorDetails(error)
|
||||||
|
console.debug(`${prefix} ${context.url} FAILED${details ? ` — ${details}` : ''}`)
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatErrorDetails(error: unknown): string {
|
||||||
|
if (!error || typeof error !== 'object') {
|
||||||
|
return typeof error === 'string' ? error : ''
|
||||||
|
}
|
||||||
|
|
||||||
|
const err = error as {
|
||||||
|
status?: number
|
||||||
|
statusCode?: number
|
||||||
|
statusText?: string
|
||||||
|
message?: string
|
||||||
|
data?: unknown
|
||||||
|
responseData?: unknown
|
||||||
|
originalError?: unknown
|
||||||
|
response?: { status?: number; statusText?: string; _data?: unknown }
|
||||||
|
}
|
||||||
|
|
||||||
|
const status = err.status ?? err.statusCode ?? err.response?.status
|
||||||
|
const statusText = err.statusText ?? err.response?.statusText
|
||||||
|
const data = err.responseData ?? err.data ?? err.response?._data
|
||||||
|
|
||||||
|
const parts: string[] = []
|
||||||
|
if (status !== undefined) {
|
||||||
|
parts.push(statusText ? `${status} ${statusText}` : String(status))
|
||||||
|
}
|
||||||
|
if (data !== undefined) {
|
||||||
|
parts.push(`body: ${safeStringify(data)}`)
|
||||||
|
} else if (err.message) {
|
||||||
|
parts.push(err.message)
|
||||||
|
}
|
||||||
|
return parts.join(' ')
|
||||||
|
}
|
||||||
|
|
||||||
|
function safeStringify(value: unknown): string {
|
||||||
|
if (typeof value === 'string') return value
|
||||||
|
try {
|
||||||
|
return JSON.stringify(value)
|
||||||
|
} catch {
|
||||||
|
return String(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -60,10 +60,18 @@ export class TauriModrinthClient extends XHRUploadClient {
|
|||||||
|
|
||||||
let body: BodyInit | null | undefined = undefined
|
let body: BodyInit | null | undefined = undefined
|
||||||
if (options.body) {
|
if (options.body) {
|
||||||
if (typeof options.body === 'object' && !(options.body instanceof FormData)) {
|
const raw = options.body
|
||||||
body = JSON.stringify(options.body)
|
if (
|
||||||
|
typeof raw === 'object' &&
|
||||||
|
!(raw instanceof FormData) &&
|
||||||
|
!(raw instanceof URLSearchParams) &&
|
||||||
|
!(raw instanceof Blob) &&
|
||||||
|
!(raw instanceof ArrayBuffer) &&
|
||||||
|
!ArrayBuffer.isView(raw as ArrayBufferView)
|
||||||
|
) {
|
||||||
|
body = JSON.stringify(raw)
|
||||||
} else {
|
} else {
|
||||||
body = options.body as BodyInit
|
body = raw as BodyInit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ defineExpose({
|
|||||||
v-tooltip="'Copy Link'"
|
v-tooltip="'Copy Link'"
|
||||||
type="button"
|
type="button"
|
||||||
aria-label="Copy Link"
|
aria-label="Copy Link"
|
||||||
class="flex h-10 w-full cursor-pointer items-center justify-between gap-2 rounded-lg border-none bg-button-bg px-3 pr-1.5 text-primary transition-all hover:bg-button-bg-hover hover:brightness-125 active:scale-95"
|
class="flex h-10 w-full cursor-pointer items-center justify-between gap-2 rounded-xl border-none bg-button-bg px-3 pr-1.5 text-primary transition-all hover:bg-button-bg-hover hover:brightness-125 active:scale-95"
|
||||||
@click="copyText"
|
@click="copyText"
|
||||||
>
|
>
|
||||||
<span class="cursor-pointer truncate text-left font-semibold text-primary">
|
<span class="cursor-pointer truncate text-left font-semibold text-primary">
|
||||||
@@ -195,8 +195,8 @@ defineExpose({
|
|||||||
</button>
|
</button>
|
||||||
<ButtonStyled v-if="link">
|
<ButtonStyled v-if="link">
|
||||||
<a :href="url" target="_blank" rel="noopener noreferrer" aria-label="Open in new tab">
|
<a :href="url" target="_blank" rel="noopener noreferrer" aria-label="Open in new tab">
|
||||||
<ExternalIcon aria-hidden="true" />
|
|
||||||
Open in new tab
|
Open in new tab
|
||||||
|
<ExternalIcon aria-hidden="true" />
|
||||||
</a>
|
</a>
|
||||||
</ButtonStyled>
|
</ButtonStyled>
|
||||||
<div v-if="socialButtons" class="flex flex-row gap-2">
|
<div v-if="socialButtons" class="flex flex-row gap-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user