forked from akanyan/STARTLINER
feat: refresh+start button
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
import { Ref, computed, ref } from 'vue';
|
||||
import Button from 'primevue/button';
|
||||
import ConfirmDialog from 'primevue/confirmdialog';
|
||||
import ContextMenu from 'primevue/contextmenu';
|
||||
import ScrollPanel from 'primevue/scrollpanel';
|
||||
import { useConfirm } from 'primevue/useconfirm';
|
||||
import { listen } from '@tauri-apps/api/event';
|
||||
@ -15,7 +16,7 @@ const confirmDialog = useConfirm();
|
||||
type StartStatus = 'ready' | 'preparing' | 'running';
|
||||
const startStatus: Ref<StartStatus> = ref('ready');
|
||||
|
||||
const startline = async (force: boolean) => {
|
||||
const startline = async (force: boolean, refresh: boolean) => {
|
||||
startStatus.value = 'preparing';
|
||||
|
||||
if (!force) {
|
||||
@ -38,7 +39,7 @@ const startline = async (force: boolean) => {
|
||||
message: message.join('\n'),
|
||||
header: 'Start check failed',
|
||||
accept: () => {
|
||||
startline(true);
|
||||
startline(true, refresh);
|
||||
},
|
||||
});
|
||||
startStatus.value = 'ready';
|
||||
@ -47,7 +48,7 @@ const startline = async (force: boolean) => {
|
||||
}
|
||||
try {
|
||||
await invoke('save_current_profile');
|
||||
await invoke('startline');
|
||||
await invoke('startline', { refresh });
|
||||
} catch (_) {
|
||||
startStatus.value = 'ready';
|
||||
}
|
||||
@ -87,9 +88,29 @@ listen('launch-end', () => {
|
||||
const messageSplit = (message: any) => {
|
||||
return message.message?.split('\n');
|
||||
};
|
||||
|
||||
const menuItems = [
|
||||
{
|
||||
label: 'Refresh and start',
|
||||
icon: 'pi pi-sync',
|
||||
command: async () => await startline(false, true),
|
||||
},
|
||||
{
|
||||
label: 'Start unchecked',
|
||||
icon: 'pi pi-exclamation-circle',
|
||||
command: async () => await startline(true, false),
|
||||
},
|
||||
];
|
||||
const menu = ref();
|
||||
|
||||
const showContextMenu = (event: Event) => {
|
||||
event.preventDefault();
|
||||
menu.value.show(event);
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ContextMenu ref="menu" :model="menuItems" />
|
||||
<ConfirmDialog>
|
||||
<template #container="{ message, acceptCallback, rejectCallback }">
|
||||
<div
|
||||
@ -138,7 +159,8 @@ const messageSplit = (message: any) => {
|
||||
aria-label="start"
|
||||
size="small"
|
||||
class="m-2.5"
|
||||
@click="startline(false)"
|
||||
@click="startline(false, false)"
|
||||
@contextmenu="showContextMenu"
|
||||
/>
|
||||
<Button
|
||||
v-else-if="startStatus === 'preparing'"
|
||||
|
Reference in New Issue
Block a user