Auth retrying, std logs (#879)

This commit is contained in:
Wyatt Verchere
2023-11-17 20:49:32 -08:00
committed by GitHub
parent 01ab507e3a
commit 25662d1402
20 changed files with 379 additions and 114 deletions

View File

@@ -61,8 +61,14 @@ const os = ref('')
defineExpose({
initialize: async () => {
isLoading.value = false
const { native_decorations, theme, opt_out_analytics, collapsed_navigation, advanced_rendering, fully_onboarded } =
await get()
const {
native_decorations,
theme,
opt_out_analytics,
collapsed_navigation,
advanced_rendering,
fully_onboarded,
} = await get()
// video should play if the user is not on linux, and has not onboarded
os.value = await getOS()
videoPlaying.value = !fully_onboarded && os.value !== 'Linux'
@@ -71,7 +77,7 @@ defineExpose({
showOnboarding.value = !fully_onboarded
nativeDecorations.value = native_decorations
if (os !== "MacOS") appWindow.setDecorations(native_decorations)
if (os.value !== 'MacOS') appWindow.setDecorations(native_decorations)
themeStore.setThemeState(theme)
themeStore.collapsedNavigation = collapsed_navigation

View File

@@ -24,7 +24,10 @@
:class="{ expanded: mode === 'expanded', isolated: mode === 'isolated' }"
>
<div v-if="selectedAccount" class="selected account">
<Avatar size="xs" :src="`https://crafatar.com/avatars/${selectedAccount.id}?size=128&overlay`" />
<Avatar
size="xs"
:src="`https://crafatar.com/avatars/${selectedAccount.id}?size=128&overlay`"
/>
<div>
<h4>{{ selectedAccount.username }}</h4>
<p>Selected</p>

View File

@@ -50,6 +50,11 @@ export async function delete_logs(profilePath) {
new_file: bool <- the cursor was too far, meaning that the file was likely rotated/reset. This signals to the frontend to clear the log and start over with this struct.
}
*/
// From latest.log directly
export async function get_latest_log_cursor(profilePath, cursor) {
return await invoke('plugin:logs|logs_get_latest_log_cursor', { profilePath, cursor })
}
// For std log (from modrinth app written latest_stdout.log, contains stdout and stderr)
export async function get_std_log_cursor(profilePath, cursor) {
return await invoke('plugin:logs|logs_get_std_log_cursor', { profilePath, cursor })
}

View File

@@ -18,7 +18,7 @@ import { invoke } from '@tauri-apps/api/tauri'
export async function create(name, gameVersion, modloader, loaderVersion, icon, noWatch) {
//Trim string name to avoid "Unable to find directory"
name = name.trim();
name = name.trim()
return await invoke('plugin:profile_create|profile_create', {
name,
gameVersion,

View File

@@ -246,9 +246,7 @@ async function refreshDir() {
<div v-if="getOS() != 'MacOS'" class="adjacent-input">
<label for="native-decorations">
<span class="label__title">Native decorations</span>
<span class="label__description"
>Use system window frame (app restart required).</span
>
<span class="label__description">Use system window frame (app restart required).</span>
</label>
<Toggle
id="native-decorations"

View File

@@ -102,7 +102,7 @@ import {
delete_logs_by_filename,
get_logs,
get_output_by_filename,
get_latest_log_cursor,
get_std_log_cursor,
} from '@/helpers/logs.js'
import { computed, nextTick, onBeforeUnmount, onMounted, onUnmounted, ref, watch } from 'vue'
import dayjs from 'dayjs'
@@ -216,14 +216,14 @@ const processedLogs = computed(() => {
return processed
})
async function getLiveLog() {
async function getLiveStdLog() {
if (route.params.id) {
const uuids = await get_uuids_by_profile_path(route.params.id).catch(handleError)
let returnValue
if (uuids.length === 0) {
returnValue = emptyText.join('\n')
} else {
const logCursor = await get_latest_log_cursor(
const logCursor = await get_std_log_cursor(
props.instance.path,
currentLiveLogCursor.value
).catch(handleError)
@@ -240,34 +240,42 @@ async function getLiveLog() {
}
async function getLogs() {
return (await get_logs(props.instance.path, true).catch(handleError)).reverse().map((log) => {
if (log.filename == 'latest.log') {
log.name = 'Latest Log'
} else {
let filename = log.filename.split('.')[0]
let day = dayjs(filename.slice(0, 10))
if (day.isValid()) {
if (day.isToday()) {
log.name = 'Today'
} else if (day.isYesterday()) {
log.name = 'Yesterday'
} else {
log.name = day.format('MMMM D, YYYY')
}
// Displays as "Today-1", "Today-2", etc, matching minecraft log naming but with the date
log.name = log.name + filename.slice(10)
return (await get_logs(props.instance.path, true).catch(handleError))
.reverse()
.filter(
(log) =>
log.filename !== 'latest_stdout.log' &&
log.filename !== 'latest_stdout' &&
log.stdout !== ''
)
.map((log) => {
if (log.filename == 'latest.log') {
log.name = 'Latest Log'
} else {
log.name = filename
let filename = log.filename.split('.')[0]
let day = dayjs(filename.slice(0, 10))
if (day.isValid()) {
if (day.isToday()) {
log.name = 'Today'
} else if (day.isYesterday()) {
log.name = 'Yesterday'
} else {
log.name = day.format('MMMM D, YYYY')
}
// Displays as "Today-1", "Today-2", etc, matching minecraft log naming but with the date
log.name = log.name + filename.slice(10)
} else {
log.name = filename
}
}
}
log.stdout = 'Loading...'
return log
})
log.stdout = 'Loading...'
return log
})
}
async function setLogs() {
const [liveLog, allLogs] = await Promise.all([getLiveLog(), getLogs()])
logs.value = [liveLog, ...allLogs]
const [liveStd, allLogs] = await Promise.all([getLiveStdLog(), getLogs()])
logs.value = [liveStd, ...allLogs]
}
const copyLog = () => {
@@ -426,7 +434,7 @@ function handleUserScroll() {
interval.value = setInterval(async () => {
if (logs.value.length > 0) {
logs.value[0] = await getLiveLog()
logs.value[0] = await getLiveStdLog()
const scroll = logContainer.value.getScroll()
// Allow resetting of userScrolled if the user scrolls to the bottom

View File

@@ -542,7 +542,7 @@ const ascending = ref(true)
const sortColumn = ref('Name')
const currentPage = ref(1)
watch(searchFilter, () => currentPage.value = 1)
watch(searchFilter, () => (currentPage.value = 1))
const selected = computed(() =>
Array.from(selectionMap.value)