feat: improve ArtCraft integration and configurable file opening
This commit is contained in:
1 parent
3bc62d2b69
commit
80bc2c458d
60 files changed
+1738
-232
No files matched your search
@@ -1,8 +1,4 @@
|
||||
<template>
|
||||
<button type="button" class="action" @click="open('newDir')">
|
||||
<AppIcon name="folder" /><span>{{ t("sidebar.newFolder") }}</span>
|
||||
</button>
|
||||
<div class="context-menu-separator" />
|
||||
<button
|
||||
v-for="template in templates"
|
||||
:key="template.id"
|
||||
@@ -10,10 +6,22 @@
|
||||
class="action"
|
||||
@click="open('newFile', template.id)"
|
||||
>
|
||||
<AppIcon :name="template.icon" /><span>{{
|
||||
t("createTypes." + template.id)
|
||||
<img
|
||||
v-if="template.craft"
|
||||
class="create-app-icon"
|
||||
:src="baseURL + '/static/img/artcraft/' + template.craft + '.webp'"
|
||||
alt=""
|
||||
/><AppIcon v-else :name="template.icon" /><span>{{
|
||||
template.craft
|
||||
? (addons.items.find((item) => item.id === template.craft)?.name ||
|
||||
template.craft) +
|
||||
" (" +
|
||||
template.extension +
|
||||
")"
|
||||
: t("createTypes." + template.id)
|
||||
}}</span>
|
||||
</button>
|
||||
<CreateMenu v-if="!craftOnly && hasCraftTemplates" craft-only />
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from "vue-i18n";
|
||||
@@ -22,9 +30,12 @@ import { fileTemplates } from "@/utils/file-templates";
|
||||
import { computed, onMounted } from "vue";
|
||||
import { useAddonsStore } from "@/stores/addons";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
import CreateMenu from "./CreateMenu.vue";
|
||||
import { baseURL } from "@/utils/constants";
|
||||
const props = defineProps<{ craftOnly?: boolean }>();
|
||||
const addons = useAddonsStore(),
|
||||
auth = useAuthStore();
|
||||
const templates = computed(() =>
|
||||
const availableTemplates = computed(() =>
|
||||
fileTemplates.filter(
|
||||
(template) =>
|
||||
!template.craft ||
|
||||
@@ -33,6 +44,14 @@ const templates = computed(() =>
|
||||
auth.user?.perm.download)
|
||||
)
|
||||
);
|
||||
const templates = computed(() =>
|
||||
availableTemplates.value.filter(
|
||||
(template) => !!template.craft === !!props.craftOnly
|
||||
)
|
||||
);
|
||||
const hasCraftTemplates = computed(() =>
|
||||
availableTemplates.value.some((template) => template.craft)
|
||||
);
|
||||
onMounted(() => {
|
||||
addons.refresh().catch(() => {});
|
||||
});
|
||||
@@ -43,3 +62,11 @@ function open(prompt: string, template?: string) {
|
||||
layout.showHover({ prompt, props: { template } });
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.create-app-icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
object-fit: contain;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user