|
| 1 | +<script setup> |
| 2 | +import GlassCard from "@ogw_front/components/GlassCard"; |
| 3 | +import { importExtensionFile } from "@ogw_front/utils/extension"; |
| 4 | +import { useAppStore } from "@ogw_front/stores/app"; |
| 5 | +
|
| 6 | +import { useExtensions } from "@vease/composables/extensions"; |
| 7 | +
|
| 8 | +const { extension } = defineProps({ |
| 9 | + extension: { |
| 10 | + type: Object, |
| 11 | + default: undefined, |
| 12 | + }, |
| 13 | +}); |
| 14 | +
|
| 15 | +const MESSAGE_TIMEOUT = 5000; |
| 16 | +
|
| 17 | +const { downloadExtension } = useExtensions(); |
| 18 | +const appStore = useAppStore(); |
| 19 | +
|
| 20 | +const installing = ref(false); |
| 21 | +const installError = ref(""); |
| 22 | +const installSuccess = ref(""); |
| 23 | +const installed = computed(() => { |
| 24 | + if (!appStore.getExtension(extension.id)) { |
| 25 | + return false; |
| 26 | + } |
| 27 | + return true; |
| 28 | +}); |
| 29 | +console.log({ installed }); |
| 30 | +
|
| 31 | +async function installSelectedExtension() { |
| 32 | + if (!extension) { |
| 33 | + return; |
| 34 | + } |
| 35 | +
|
| 36 | + installError.value = ""; |
| 37 | + installSuccess.value = ""; |
| 38 | + installing.value = true; |
| 39 | +
|
| 40 | + try { |
| 41 | + const file = await downloadExtension(extension.id); |
| 42 | + console.log({ file }); |
| 43 | + await importExtensionFile(file); |
| 44 | + installSuccess.value = "Extension installed successfully!"; |
| 45 | + } catch (error) { |
| 46 | + console.error(error); |
| 47 | + installError.value = error.message || "Failed to install extension."; |
| 48 | + } finally { |
| 49 | + installing.value = false; |
| 50 | + setTimeout(() => { |
| 51 | + installSuccess.value = ""; |
| 52 | + installError.value = ""; |
| 53 | + }, MESSAGE_TIMEOUT); |
| 54 | + } |
| 55 | +} |
| 56 | +</script> |
| 57 | +<template> |
| 58 | + <GlassCard |
| 59 | + variant="ui" |
| 60 | + padding="pa-0" |
| 61 | + class="d-flex flex-column fill-height border-white border-opacity-10 relative overflow-hidden" |
| 62 | + style="min-height: 0" |
| 63 | + > |
| 64 | + <template v-if="extension"> |
| 65 | + <v-sheet color="rgba(0,0,0,0.2)" class="pa-6 pa-sm-8 border-b border-white border-opacity-10"> |
| 66 | + <v-sheet |
| 67 | + color="transparent" |
| 68 | + class="d-flex flex-column flex-sm-row align-center align-sm-start text-center text-sm-left" |
| 69 | + > |
| 70 | + <v-avatar |
| 71 | + color="rgba(255,255,255,0.05)" |
| 72 | + size="96" |
| 73 | + rounded="xl" |
| 74 | + class="mb-4 mb-sm-0 mr-sm-6 border border-white border-opacity-10 shadow-sm glass-icon flex-shrink-0" |
| 75 | + > |
| 76 | + <v-icon icon="mdi-puzzle" size="48" color="white"></v-icon> |
| 77 | + </v-avatar> |
| 78 | + |
| 79 | + <v-sheet color="transparent" class="flex-grow-1 w-100" style="min-width: 0"> |
| 80 | + <v-sheet |
| 81 | + color="transparent" |
| 82 | + class="d-flex flex-column flex-sm-row align-center mb-2 justify-center justify-sm-start" |
| 83 | + > |
| 84 | + <h1 |
| 85 | + class="text-h5 text-sm-h4 font-weight-bold text-white mb-2 mb-sm-0 mr-sm-4" |
| 86 | + style="word-break: break-word" |
| 87 | + > |
| 88 | + {{ extension.id }} |
| 89 | + </h1> |
| 90 | + <v-chip size="small" variant="outlined" color="white" class="font-weight-medium"> |
| 91 | + v{{ extension.version }} |
| 92 | + </v-chip> |
| 93 | + </v-sheet> |
| 94 | + |
| 95 | + <v-sheet color="transparent" class="text-subtitle-1 text-white opacity-80 mb-4"> |
| 96 | + Marketplace Extension |
| 97 | + </v-sheet> |
| 98 | + |
| 99 | + <v-sheet |
| 100 | + color="transparent" |
| 101 | + class="d-flex align-center justify-center justify-sm-start ga-3 mt-4" |
| 102 | + > |
| 103 | + <v-btn |
| 104 | + color="white" |
| 105 | + variant="elevated" |
| 106 | + prepend-icon="mdi-download" |
| 107 | + elevation="4" |
| 108 | + rounded="pill" |
| 109 | + class="text-none px-6 font-weight-bold text-black" |
| 110 | + :loading="installing" |
| 111 | + @click="installSelectedExtension" |
| 112 | + :disabled="installed" |
| 113 | + > |
| 114 | + <span v-if="installed">Already installed</span> |
| 115 | + <span v-else>Install Extension</span> |
| 116 | + </v-btn> |
| 117 | + </v-sheet> |
| 118 | + |
| 119 | + <v-slide-y-transition> |
| 120 | + <v-alert |
| 121 | + v-if="installSuccess" |
| 122 | + type="success" |
| 123 | + density="compact" |
| 124 | + variant="tonal" |
| 125 | + class="mt-4 text-caption" |
| 126 | + > |
| 127 | + {{ installSuccess }} |
| 128 | + </v-alert> |
| 129 | + </v-slide-y-transition> |
| 130 | + |
| 131 | + <v-slide-y-transition> |
| 132 | + <v-alert |
| 133 | + v-if="installError" |
| 134 | + type="error" |
| 135 | + density="compact" |
| 136 | + variant="tonal" |
| 137 | + class="mt-4 text-caption" |
| 138 | + > |
| 139 | + {{ installError }} |
| 140 | + </v-alert> |
| 141 | + </v-slide-y-transition> |
| 142 | + </v-sheet> |
| 143 | + </v-sheet> |
| 144 | + </v-sheet> |
| 145 | + |
| 146 | + <v-sheet |
| 147 | + color="transparent" |
| 148 | + class="flex-grow-1 pa-6 pa-sm-8 overflow-y-auto custom-scrollbar" |
| 149 | + > |
| 150 | + <h3 class="text-h6 font-weight-semibold text-white mb-4 d-flex align-center"> |
| 151 | + <v-icon icon="mdi-file-document-outline" class="mr-2" size="24"></v-icon> |
| 152 | + Details |
| 153 | + </h3> |
| 154 | + <v-sheet color="transparent" class="readme-content text-body-1 text-white opacity-80"> |
| 155 | + <v-sheet |
| 156 | + v-if="extension.readme" |
| 157 | + color="transparent" |
| 158 | + style="white-space: pre-wrap; line-height: 1.6" |
| 159 | + > |
| 160 | + {{ extension.readme }} |
| 161 | + </v-sheet> |
| 162 | + <v-sheet v-else color="transparent" class="text-center py-10 opacity-60"> |
| 163 | + <p>No README provided for this extension.</p> |
| 164 | + </v-sheet> |
| 165 | + </v-sheet> |
| 166 | + </v-sheet> |
| 167 | + </template> |
| 168 | + |
| 169 | + <v-sheet |
| 170 | + v-else |
| 171 | + color="transparent" |
| 172 | + class="fill-height d-flex flex-column align-center justify-center text-center pa-6" |
| 173 | + > |
| 174 | + <v-sheet |
| 175 | + class="mx-auto mb-6 d-flex align-center justify-center" |
| 176 | + rounded="circle" |
| 177 | + color="rgba(255,255,255,0.05)" |
| 178 | + width="120" |
| 179 | + height="120" |
| 180 | + > |
| 181 | + <v-icon icon="mdi-storefront-outline" size="64" color="white" class="opacity-80"></v-icon> |
| 182 | + </v-sheet> |
| 183 | + <h2 class="text-h5 font-weight-medium text-white mb-2">Marketplace</h2> |
| 184 | + <p class="text-body-1 text-white opacity-70"> |
| 185 | + Select an extension from the list to view its details and install it. |
| 186 | + </p> |
| 187 | + </v-sheet> |
| 188 | + </GlassCard> |
| 189 | +</template> |
| 190 | + |
| 191 | +<style scoped> |
| 192 | +.glass-icon { |
| 193 | + backdrop-filter: blur(10px); |
| 194 | +} |
| 195 | +
|
| 196 | +.custom-scrollbar::-webkit-scrollbar { |
| 197 | + width: 8px; |
| 198 | +} |
| 199 | +.custom-scrollbar::-webkit-scrollbar-track { |
| 200 | + background: transparent; |
| 201 | +} |
| 202 | +.custom-scrollbar::-webkit-scrollbar-thumb { |
| 203 | + background: rgba(255, 255, 255, 0.1); |
| 204 | + border-radius: 4px; |
| 205 | +} |
| 206 | +.custom-scrollbar::-webkit-scrollbar-thumb:hover { |
| 207 | + background: rgba(255, 255, 255, 0.2); |
| 208 | +} |
| 209 | +</style> |
0 commit comments