feat: new config format
This commit is contained in:
113
src/components/ProfileListEntry.vue
Normal file
113
src/components/ProfileListEntry.vue
Normal file
@ -0,0 +1,113 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
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 { useGeneralStore, usePrfStore } from '../stores';
|
||||
import { ProfileMeta } from '../types';
|
||||
|
||||
const prf = usePrfStore();
|
||||
const general = useGeneralStore();
|
||||
const isEditing = ref(false);
|
||||
|
||||
const props = defineProps({
|
||||
p: Object as () => ProfileMeta,
|
||||
});
|
||||
|
||||
if (props.p === undefined) {
|
||||
throw new Error('Invalid ProfileListEntry');
|
||||
}
|
||||
|
||||
const rename = async (event: KeyboardEvent) => {
|
||||
if (event.key !== 'Enter') {
|
||||
return;
|
||||
}
|
||||
|
||||
isEditing.value = false;
|
||||
|
||||
if (
|
||||
event.target !== null &&
|
||||
'value' in event.target &&
|
||||
typeof event.target.value === 'string'
|
||||
) {
|
||||
const value = event.target.value
|
||||
.replaceAll('..', '')
|
||||
.replaceAll('\\', '')
|
||||
.replaceAll('/', '');
|
||||
if (value.length > 0) {
|
||||
await prf.rename(props.p!, value);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-row flex-wrap align-middle gap-2">
|
||||
<Button
|
||||
:disabled="
|
||||
prf.current?.game === p!.game && prf.current?.name === p!.name
|
||||
"
|
||||
:class="
|
||||
(p!.game === 'chunithm' ? 'chunithm-button' : 'ongeki-button') +
|
||||
' ' +
|
||||
'self-center profile-button'
|
||||
"
|
||||
@click="prf.switchTo(p!.game, p!.name)"
|
||||
>
|
||||
<div v-if="!isEditing">{{ p!.name }}</div>
|
||||
<div v-else>
|
||||
<InputText
|
||||
:model-value="p!.name"
|
||||
@vue:mounted="$event?.el?.focus()"
|
||||
@keyup="rename"
|
||||
@focusout="isEditing = false"
|
||||
>
|
||||
</InputText></div
|
||||
></Button>
|
||||
<Button
|
||||
rounded
|
||||
icon="pi pi-trash"
|
||||
severity="danger"
|
||||
aria-label="remove"
|
||||
size="small"
|
||||
class="self-center ml-2"
|
||||
style="width: 2rem; height: 2rem"
|
||||
:disabled="true"
|
||||
/>
|
||||
<Button
|
||||
rounded
|
||||
icon="pi pi-clone"
|
||||
severity="help"
|
||||
aria-label="duplicate"
|
||||
size="small"
|
||||
class="self-center"
|
||||
style="width: 2rem; height: 2rem"
|
||||
:disabled="true"
|
||||
/>
|
||||
<Button
|
||||
rounded
|
||||
icon="pi pi-pencil"
|
||||
severity="help"
|
||||
aria-label="rename"
|
||||
size="small"
|
||||
class="self-center"
|
||||
style="width: 2rem; height: 2rem"
|
||||
@click="isEditing = true"
|
||||
/>
|
||||
<Button
|
||||
rounded
|
||||
icon="pi pi-folder"
|
||||
severity="help"
|
||||
aria-label="open-directory"
|
||||
size="small"
|
||||
class="self-center"
|
||||
style="width: 2rem; height: 2rem"
|
||||
@click="
|
||||
path
|
||||
.join(general.dataDir, `profile-${p!.game}-${p!.name}`)
|
||||
.then(open)
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
Reference in New Issue
Block a user