feat: the other profile buttons

This commit is contained in:
2025-03-14 00:23:47 +00:00
parent fd27000c05
commit 90ba27c967
11 changed files with 112 additions and 33 deletions

View File

@ -4,6 +4,7 @@ import Button from 'primevue/button';
import InputText from 'primevue/inputtext';
import * as path from '@tauri-apps/api/path';
import { open } from '@tauri-apps/plugin-shell';
import { invoke } from '../invoke';
import { useGeneralStore, usePrfStore } from '../stores';
import { ProfileMeta } from '../types';
@ -19,7 +20,7 @@ if (props.p === undefined) {
throw new Error('Invalid ProfileListEntry');
}
const rename = async (event: KeyboardEvent) => {
const renameProfile = async (event: KeyboardEvent) => {
if (event.key !== 'Enter') {
return;
}
@ -32,14 +33,28 @@ const rename = async (event: KeyboardEvent) => {
typeof event.target.value === 'string'
) {
const value = event.target.value
.trim()
.replaceAll(' ', '-')
.replaceAll('..', '')
.replaceAll('\\', '')
.replaceAll('/', '');
if (value.length > 0) {
await prf.rename(props.p!, value);
}
}
};
const duplicateProfile = async () => {
await invoke('duplicate_profile', { profile: props.p });
await prf.reloadList();
};
const deleteProfile = async () => {
await invoke('delete_profile', { profile: props.p });
await prf.reloadList();
await prf.reload();
};
</script>
<template>
@ -60,7 +75,7 @@ const rename = async (event: KeyboardEvent) => {
<InputText
:model-value="p!.name"
@vue:mounted="$event?.el?.focus()"
@keyup="rename"
@keyup="renameProfile"
@focusout="isEditing = false"
>
</InputText></div
@ -73,7 +88,7 @@ const rename = async (event: KeyboardEvent) => {
size="small"
class="self-center ml-2"
style="width: 2rem; height: 2rem"
:disabled="true"
@click="deleteProfile"
/>
<Button
rounded
@ -83,7 +98,7 @@ const rename = async (event: KeyboardEvent) => {
size="small"
class="self-center"
style="width: 2rem; height: 2rem"
:disabled="true"
@click="duplicateProfile"
/>
<Button
rounded