Compare commits

...

3 Commits

Author SHA1 Message Date
9e7881745a Sticker CRUD 2024-09-26 21:22:34 +08:00
7151d71463 Sticker packs full update & delete 2024-09-25 23:11:53 +08:00
e5a5463b63 Basic sticker & pack overview [skip ci] 2024-09-25 22:29:05 +08:00
17 changed files with 1042 additions and 52 deletions

View File

@ -0,0 +1,28 @@
<template>
<v-menu>
<template v-slot:activator="{ props }">
<v-btn
size="small"
icon="mdi-translate"
v-bind="props"
/>
</template>
<v-list>
<v-list-item
class="w-48"
density="compact"
v-for="item in locales"
:key="item.code"
:value="item.code"
:active="locale == item.code"
@click.prevent.stop="setLocale(item.code)"
>
<v-list-item-title>{{ item.name }}</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
</template>
<script lang="ts" setup>
const { locale, locales, setLocale } = useI18n()
</script>

View File

@ -0,0 +1,182 @@
<template>
<v-expand-transition>
<v-alert v-if="error" variant="tonal" type="error" class="text-xs mb-3">
{{ t("errorOccurred", [error]) }}
</v-alert>
</v-expand-transition>
<v-data-table-server
density="compact"
:headers="dataDefinitions.stickers"
:items="stickers"
:items-length="pagination.stickers.total"
:loading="reverting.stickers"
v-model:items-per-page="pagination.stickers.pageSize"
@update:options="readStickers"
item-value="id"
>
<template v-slot:item="{ item }: { item: any }">
<tr>
<td>{{ item.id }}</td>
<td>
<div class="item-texture-cell">
<v-img
cover
aspect-ratio="1"
width="28"
height="28"
color="grey-lighten-2"
rounded="sm"
:src="`${config.public.solarNetworkApi}/cgi/uc/attachments/${item.attachment.rid}`"
>
<template #placeholder>
<div class="d-flex align-center justify-center fill-height">
<v-progress-circular
size="x-small"
width="3"
color="grey-lighten-4"
indeterminate
></v-progress-circular>
</div>
</template>
</v-img>
<v-code class="px-2 w-fit font-mono">
{{ item.attachment.rid }}
</v-code>
</div>
</td>
<td>{{ item.name }}</td>
<td>{{ props.packPrefix + item.alias }}</td>
<td>
<v-btn
v-bind="props"
variant="text"
size="x-small"
color="warning"
icon="mdi-pencil"
class="ms-[-8px]"
:to="`/creator/stickers/${item.pack_id}/${item.id}/edit`"
/>
<v-dialog max-width="480">
<template #activator="{ props }">
<v-btn
v-bind="props"
variant="text"
size="x-small"
color="error"
icon="mdi-delete"
:disabled="submitting"
/>
</template>
<template v-slot:default="{ isActive }">
<v-card :title="`Delete sticker #${item.id}?`">
<v-card-text>
This action will delete this sticker, all content used it will no longer show your sticker.
But the attachment will still exists.
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn
text="Cancel"
color="grey"
@click="isActive.value = false"
></v-btn>
<v-btn
text="Delete"
color="error"
@click="() => { deleteSticker(item); isActive.value = false }"
/>
</v-card-actions>
</v-card>
</template>
</v-dialog>
</td>
</tr>
</template>
</v-data-table-server>
</template>
<script setup lang="ts">
import { solarFetch } from "~/utils/request"
const config = useRuntimeConfig()
const { t } = useI18n()
const props = defineProps<{ packId: number, packPrefix?: string }>()
const error = ref<null | string>(null)
const dataDefinitions: { [id: string]: any[] } = {
stickers: [
{ align: "start", key: "id", title: "ID" },
{ align: "start", key: "attachment", title: "Texture" },
{ align: "start", key: "name", title: "Name" },
{ align: "start", key: "alias", title: "Alias" },
{ align: "start", key: "actions", title: "Actions", sortable: false },
],
}
const stickers = ref<any>([])
const reverting = reactive({ stickers: false })
const pagination = reactive({
stickers: { page: 1, pageSize: 5, total: 0 },
})
async function readStickers({ page, itemsPerPage }: { page?: number; itemsPerPage?: number }) {
if (itemsPerPage) pagination.stickers.pageSize = itemsPerPage
if (page) pagination.stickers.page = page
reverting.stickers = true
const res = await solarFetch(
"/cgi/uc/stickers?" +
new URLSearchParams({
pack: props.packId.toString(),
take: pagination.stickers.pageSize.toString(),
offset: ((pagination.stickers.page - 1) * pagination.stickers.pageSize).toString(),
}),
)
if (res.status !== 200) {
error.value = await res.text()
} else {
const data = await res.json()
stickers.value = data["data"]
pagination.stickers.total = data["count"]
}
reverting.stickers = false
}
onMounted(() => readStickers({}))
const submitting = ref(false)
async function deleteSticker(item: any) {
submitting.value = true
const res = await solarFetch(`/cgi/uc/stickers/${item.id}`, {
method: "DELETE",
})
if (res.status !== 200) {
error.value = await res.text()
} else {
await readStickers({})
}
submitting.value = false
}
</script>
<style scoped>
.item-texture-cell {
display: grid;
grid-template-columns: 28px auto;
gap: 6px;
width: fit-content;
}
</style>

56
layouts/creator-hub.vue Normal file
View File

@ -0,0 +1,56 @@
<template>
<v-app-bar flat color="primary" scroll-behavior="hide" scroll-threshold="800">
<v-container fluid class="mx-auto d-flex align-center justify-center px-8">
<v-tooltip>
<template #activator="{ props }">
<div @click="openDrawer = !openDrawer" v-bind="props" class="cursor-pointer">
<v-img class="me-4 ms-1" width="32" height="32" alt="Logo" :src="Logo" />
</div>
</template>
Open / close drawer
</v-tooltip>
<nuxt-link to="/dev" exact>
<h2 class="mt-1">Creator Hub</h2>
</nuxt-link>
<v-spacer></v-spacer>
<locale-select />
<user-menu />
</v-container>
</v-app-bar>
<v-navigation-drawer v-model="openDrawer" location="left" width="300" floating>
<v-list density="compact" nav color="primary">
<v-list-item title="Back" prepend-icon="mdi-arrow-left" to="/" exact />
</v-list>
<v-divider class="border-opacity-50 my-1" />
<v-list density="compact" nav color="primary">
<v-list-item title="Stickers" prepend-icon="mdi-sticker-emoji" to="/creator/stickers" exact />
</v-list>
<v-divider class="border-opacity-50 mb-4 mt-1" />
<copyright no-centered service="capital" class="px-5" />
<footer-links class="px-5 mt-3" />
</v-navigation-drawer>
<v-main>
<slot />
</v-main>
</template>
<script setup lang="ts">
import Logo from "../assets/logo-w-shadow.png"
const { t } = useI18n()
const openDrawer = ref(false)
useHead({
titleTemplate: "%s | Solsynth Creator Hub"
})
</script>

View File

@ -17,29 +17,7 @@
<v-spacer></v-spacer>
<v-menu>
<template v-slot:activator="{ props }">
<v-btn
size="small"
icon="mdi-translate"
v-bind="props"
/>
</template>
<v-list>
<v-list-item
class="w-48"
density="compact"
v-for="item in locales"
:key="item.code"
:value="item.code"
:active="locale == item.code"
@click.prevent.stop="setLocale(item.code)"
>
<v-list-item-title>{{ item.name }}</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
<locale-select />
<user-menu />
</v-container>
</v-app-bar>
@ -56,7 +34,7 @@
<v-list density="compact" nav color="primary">
<v-list-item title="Developer Portal" prepend-icon="mdi-code-tags" to="/dev" exact />
<v-list-item title="Creator Hub" prepend-icon="mdi-pencil" disabled exact />
<v-list-item title="Creator Hub" prepend-icon="mdi-pencil" to="/creator" exact />
</v-list>
<v-divider class="border-opacity-50 mb-4 mt-0.5" />
@ -74,7 +52,7 @@
<script setup lang="ts">
import Logo from "../assets/logo-w-shadow.png"
const { locale, locales, setLocale, t } = useI18n()
const { t } = useI18n()
const openDrawer = ref(false)
</script>

View File

@ -16,29 +16,7 @@
<v-spacer></v-spacer>
<v-menu>
<template v-slot:activator="{ props }">
<v-btn
size="small"
icon="mdi-translate"
v-bind="props"
/>
</template>
<v-list>
<v-list-item
class="w-48"
density="compact"
v-for="item in locales"
:key="item.code"
:value="item.code"
:active="locale == item.code"
@click.prevent.stop="setLocale(item.code)"
>
<v-list-item-title>{{ item.name }}</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
<locale-select />
<user-menu />
</v-container>
</v-app-bar>
@ -69,7 +47,7 @@
<script setup lang="ts">
import Logo from "../assets/logo-w-shadow.png"
const { locale, locales, setLocale, t } = useI18n()
const { t } = useI18n()
const openDrawer = ref(false)
useHead({

24
pages/creator/index.vue Normal file
View File

@ -0,0 +1,24 @@
<template>
<v-container fluid class="h-[calc(100vh-80px)] flex flex-col justify-center items-center text-center">
<v-icon icon="mdi-brush" size="64" />
<div class="text-2xl">Hello, creator!</div>
<div class="max-w-[320px]">Switch page using navigator above to get start creating contents on Solar Network.</div>
<div class="text-xs font-mono text-grey mt-5">
@{{ auth.userinfo?.name }} · {{ auth.userinfo?.id.toString().padStart(8, "0") }}
</div>
</v-container>
</template>
<script setup lang="ts">
definePageMeta({
layout: "creator-hub",
middleware: ["auth"],
})
useHead({
title: "Landing",
})
const auth = useUserinfo()
</script>

View File

@ -0,0 +1,178 @@
<template>
<v-container class="px-12">
<div class="flex justify-between items-center mt-5">
<div class="flex items-end gap-2">
<h1 class="text-2xl">Edit sticker: {{ data?.name ?? "Loading" }}</h1>
</div>
<div class="flex gap-2">
<v-btn
color="grey"
text="Cancel"
prepend-icon="mdi-arrow-left"
variant="tonal"
to="/creator/stickers"
/>
</div>
</div>
<v-expand-transition>
<v-alert v-if="error" variant="tonal" type="error" class="text-xs mt-5 mb-3">
{{ t("errorOccurred", [error]) }}
</v-alert>
</v-expand-transition>
<v-form class="mt-5" @submit.prevent="submit">
<v-row>
<v-col cols="12">
<v-card title="Pack info" prepend-icon="mdi-sticker-emoji" density="compact">
<v-card-text class="mt-2">
<p class="text-lg"><b>{{ pack?.name ?? "Loading..." }}</b></p>
<p>{{ pack?.description ?? "Please stand by..." }}</p>
</v-card-text>
</v-card>
</v-col>
<v-col cols="12" md="6">
<v-text-field
label="Name"
name="name"
variant="outlined"
persistent-hint
hint="A human friendly name for user to recognize this sticker"
v-model="stickerName"
/>
</v-col>
<v-col cols="12" md="6">
<v-text-field
label="Alias"
name="alias"
variant="outlined"
persistent-hint
hint="A placeholder of this sticker, will prepend pack's prefix"
v-model="stickerAlias"
>
<template #prepend-inner>
<p class="ms-1 me-[-5px] text-grey">{{ pack?.prefix }}</p>
</template>
</v-text-field>
</v-col>
<v-col cols="12">
<v-text-field
label="Attachment"
name="attachment_id"
variant="outlined"
persistent-hint
v-model="attachmentRid"
>
<template #details>
<p class="order-first v-messages">
The texture / image of this sticker, you can upload one from
<nuxt-link to="/gallery/new?pool=c3RpY2tlcg" target="_blank" class="underline">here</nuxt-link>
</p>
</template>
<template #prepend-inner>
<v-img
cover
aspect-ratio="1"
width="28"
height="28"
color="grey-lighten-2"
rounded="sm"
:src="attachmentRid.length > 0 ? `${config.public.solarNetworkApi}/cgi/uc/attachments/${attachmentRid}` : `example.com/not-found`"
>
<template #placeholder>
<div class="d-flex align-center justify-center fill-height" v-if="attachmentRid.length > 0">
<v-progress-circular
size="x-small"
width="3"
color="grey-lighten-4"
indeterminate
></v-progress-circular>
</div>
<div class="d-flex align-center justify-center fill-height" v-else>
<v-icon icon="mdi-image-broken-variant" class="block" size="18" />
</div>
</template>
</v-img>
</template>
</v-text-field>
</v-col>
</v-row>
<div class="flex justify-end">
<v-btn type="submit" text="Save changes" append-icon="mdi-content-save" :disabled="data == null"
:loading="submitting" />
</div>
</v-form>
</v-container>
</template>
<script setup lang="ts">
definePageMeta({
layout: "creator-hub",
middleware: ["auth"],
})
useHead({
title: "Edit Sticker",
})
const { t } = useI18n()
const route = useRoute()
const config = useRuntimeConfig()
const data = ref<any>(null)
const pack = ref<any>(null)
const attachmentRid = ref<string>("")
const stickerName = ref<string>("")
const stickerAlias = ref<string>("")
async function readPack() {
const res = await solarFetch(`/cgi/uc/stickers/packs/${route.params.id}`)
if (res.status != 200) {
error.value = await res.text()
} else {
pack.value = await res.json()
}
}
async function readSticker() {
const res = await solarFetch(`/cgi/uc/stickers/${route.params.sticker}`)
if (res.status != 200) {
error.value = await res.text()
} else {
data.value = await res.json()
stickerName.value = data.value?.name
stickerAlias.value = data.value?.alias
attachmentRid.value = data.value?.attachment.rid
}
}
onMounted(() => Promise.all([readPack(), readSticker()]))
const error = ref<null | string>(null)
const submitting = ref(false)
async function submit(evt: SubmitEvent) {
const data = Object.fromEntries(new FormData(evt.target as HTMLFormElement).entries())
if (!data.name) return
submitting.value = true
const res = await solarFetch(`/cgi/uc/stickers/packs/${route.params.id}`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data),
})
if (res.status != 200) {
error.value = await res.text()
} else {
navigateTo("/creator/stickers")
}
submitting.value = false
}
</script>

View File

@ -0,0 +1,118 @@
<template>
<v-container class="px-12">
<div class="flex justify-between items-center mt-5">
<div class="flex items-end gap-2">
<h1 class="text-2xl">Edit sticker pack: {{ data?.name ?? "Loading" }}</h1>
</div>
<div class="flex gap-2">
<v-btn
color="grey"
text="Cancel"
prepend-icon="mdi-arrow-left"
variant="tonal"
to="/creator/stickers"
/>
</div>
</div>
<v-expand-transition>
<v-alert v-if="error" variant="tonal" type="error" class="text-xs mt-5 mb-3">
{{ t("errorOccurred", [error]) }}
</v-alert>
</v-expand-transition>
<v-form class="mt-5" @submit.prevent="submit">
<v-row>
<v-col cols="12" md="6">
<v-text-field
label="Name"
name="name"
variant="outlined"
persistent-hint
hint="A human friendly name for user to recognize this sticker pack"
:model-value="data?.name"
/>
</v-col>
<v-col cols="12" md="6">
<v-text-field
label="Prefix"
name="prefix"
variant="outlined"
persistent-hint
hint="A prefix for every sticker in this pack, will add before sticker's alias"
:model-value="data?.prefix"
/>
</v-col>
<v-col cols="12">
<v-textarea
auto-grow
rows="3"
label="Description"
name="description"
variant="outlined"
persistent-hint
hint="A description for user to know about this sticker pack"
:model-value="data?.description"
/>
</v-col>
</v-row>
<div class="flex justify-end">
<v-btn type="submit" text="Save changes" append-icon="mdi-content-save" :disabled="data == null"
:loading="submitting" />
</div>
</v-form>
</v-container>
</template>
<script setup lang="ts">
definePageMeta({
layout: "creator-hub",
middleware: ["auth"],
})
useHead({
title: "Edit Sticker Pack",
})
const { t } = useI18n()
const route = useRoute()
const data = ref<any>(null)
async function readPack() {
const res = await solarFetch(`/cgi/uc/stickers/packs/${route.params.id}`)
if (res.status != 200) {
error.value = await res.text()
} else {
data.value = await res.json()
}
}
onMounted(() => readPack())
const error = ref<null | string>(null)
const submitting = ref(false)
async function submit(evt: SubmitEvent) {
const data = Object.fromEntries(new FormData(evt.target as HTMLFormElement).entries())
if (!data.name) return
submitting.value = true
const res = await solarFetch(`/cgi/uc/stickers/packs/${route.params.id}`, {
method: "PUT",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data),
})
if (res.status != 200) {
error.value = await res.text()
} else {
navigateTo("/creator/stickers")
}
submitting.value = false
}
</script>

View File

@ -0,0 +1,158 @@
<template>
<v-container class="px-12">
<div class="flex justify-between items-center mt-5">
<div class="flex items-end gap-2">
<h1 class="text-2xl">Create a new sticker</h1>
</div>
<div class="flex gap-2">
<v-btn
color="grey"
text="Cancel"
prepend-icon="mdi-arrow-left"
variant="tonal"
to="/creator/stickers"
/>
</div>
</div>
<v-expand-transition>
<v-alert v-if="error" variant="tonal" type="error" class="text-xs mt-5 mb-3">
{{ t("errorOccurred", [error]) }}
</v-alert>
</v-expand-transition>
<v-form class="mt-5" @submit.prevent="submit">
<v-row>
<v-col cols="12">
<v-card title="Pack info" prepend-icon="mdi-sticker-emoji" density="compact">
<v-card-text class="mt-2">
<p class="text-lg"><b>{{ data?.name ?? "Loading..." }}</b></p>
<p>{{ data?.description ?? "Please stand by..." }}</p>
</v-card-text>
</v-card>
</v-col>
<v-col cols="12" md="6">
<v-text-field
label="Name"
name="name"
variant="outlined"
persistent-hint
hint="A human friendly name for user to recognize this sticker"
/>
</v-col>
<v-col cols="12" md="6">
<v-text-field
label="Alias"
name="alias"
variant="outlined"
persistent-hint
hint="A placeholder of this sticker, will prepend pack's prefix"
/>
</v-col>
<v-col cols="12">
<v-text-field
label="Attachment"
name="attachment_id"
variant="outlined"
persistent-hint
v-model="attachmentRid"
>
<template #details>
<p class="order-first v-messages">
The texture / image of this sticker, you can upload one from
<nuxt-link to="/gallery/new?pool=c3RpY2tlcg" target="_blank" class="underline">here</nuxt-link>
</p>
</template>
<template #prepend-inner>
<v-img
cover
aspect-ratio="1"
width="28"
height="28"
color="grey-lighten-2"
rounded="sm"
:src="attachmentRid.length > 0 ? `${config.public.solarNetworkApi}/cgi/uc/attachments/${attachmentRid}` : `example.com/not-found`"
>
<template #placeholder>
<div class="d-flex align-center justify-center fill-height" v-if="attachmentRid.length > 0">
<v-progress-circular
size="x-small"
width="3"
color="grey-lighten-4"
indeterminate
></v-progress-circular>
</div>
<div class="d-flex align-center justify-center fill-height" v-else>
<v-icon icon="mdi-image-broken-variant" class="block" size="18"/>
</div>
</template>
</v-img>
</template>
</v-text-field>
</v-col>
</v-row>
<div class="flex justify-end">
<v-btn type="submit" text="Create" append-icon="mdi-plus" :disabled="data == null" :loading="submitting" />
</div>
</v-form>
</v-container>
</template>
<script setup lang="ts">
definePageMeta({
layout: "creator-hub",
middleware: ["auth"],
})
useHead({
title: "New Sticker",
})
const { t } = useI18n()
const route = useRoute()
const config = useRuntimeConfig()
const attachmentRid = ref<string>("")
const data = ref<any>(null)
async function readPack() {
const res = await solarFetch(`/cgi/uc/stickers/packs/${route.params.id}`)
if (res.status != 200) {
error.value = await res.text()
} else {
data.value = await res.json()
}
}
onMounted(() => readPack())
const error = ref<null | string>(null)
const submitting = ref(false)
async function submit(evt: SubmitEvent) {
const data = Object.fromEntries(new FormData(evt.target as HTMLFormElement).entries())
if (!data.name) return
submitting.value = true
const res = await solarFetch("/cgi/uc/stickers", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
pack_id: route.params.id,
...data,
}),
})
if (res.status != 200) {
error.value = await res.text()
} else {
navigateTo("/creator/stickers")
}
submitting.value = false
}
</script>

View File

@ -0,0 +1,173 @@
<template>
<v-container class="px-12">
<div class="flex justify-between items-center mt-5">
<div class="flex items-end gap-2">
<h1 class="text-2xl">Stickers & packs</h1>
</div>
<div class="flex gap-2">
<v-btn
color="primary"
text="New"
append-icon="mdi-plus"
variant="tonal"
to="/creator/stickers/new"
/>
</div>
</div>
<v-expand-transition>
<v-alert v-if="error" variant="tonal" type="error" class="text-xs mt-5 mb-3">
{{ t("errorOccurred", [error]) }}
</v-alert>
</v-expand-transition>
<div class="mt-5">
<v-expansion-panels>
<v-expansion-panel
v-for="item in data"
:key="'sticker-pack#'+item.id"
>
<template #title>
<div class="flex items-center gap-2">
<p>{{ item.name }}</p>
<v-chip size="x-small" class="font-mono" rounded color="primary">#{{ item.id }}</v-chip>
</div>
</template>
<template #text>
<v-row>
<v-col cols="12">
<p><b>Description</b></p>
<p>{{ item.description }}</p>
</v-col>
<v-col cols="12" md="6" lg="4">
<p><b>Pack Prefix</b></p>
<v-code class="font-mono mt-0.5 px-3 w-fit">
<span v-if="item.prefix.length == 0"><i>no prefix</i></span>
<span v-else>{{ item.prefix }}</span>
</v-code>
</v-col>
<v-col cols="12" md="6" lg="4">
<p><b>Actions</b></p>
<div class="flex mx-[-10px]">
<v-btn
variant="text"
size="x-small"
color="info"
icon="mdi-sticker-plus"
:to="`/creator/stickers/${item.id}/new`"
/>
<v-btn
variant="text"
size="x-small"
color="warning"
icon="mdi-pencil"
:to="`/creator/stickers/${item.id}/edit`"
/>
<v-dialog max-width="480">
<template #activator="{ props }">
<v-btn
v-bind="props"
variant="text"
size="x-small"
color="error"
icon="mdi-delete"
:disabled="submitting"
/>
</template>
<template v-slot:default="{ isActive }">
<v-card :title="`Delete sticker pack #${item.id}?`">
<v-card-text>
This action will delete the stickers belongs to it and cannot be undone.
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn
text="Cancel"
color="grey"
@click="isActive.value = false"
></v-btn>
<v-btn
text="Delete"
color="error"
@click="() => { deletePack(item); isActive.value = false }"
/>
</v-card-actions>
</v-card>
</template>
</v-dialog>
</div>
</v-col>
<v-col cols="12">
<p><b>Stickers</b></p>
<v-card variant="outlined" class="mx-[-0.5ch] mt-1">
<creator-stickers-data-table :pack-id="item.id" :pack-prefix="item.prefix" />
</v-card>
</v-col>
</v-row>
</template>
</v-expansion-panel>
</v-expansion-panels>
</div>
</v-container>
</template>
<script setup lang="ts">
import { solarFetch } from "~/utils/request"
definePageMeta({
layout: "creator-hub",
middleware: ["auth"],
})
useHead({
title: "Stickers",
})
const { t } = useI18n()
const loading = ref(false)
const error = ref<null | string>(null)
const data = ref<any[]>([])
async function readPacks() {
loading.value = true
const res = await solarFetch(`/cgi/uc/stickers/packs?take=10&offset=${data.value.length}`)
if (res.status != 200) {
error.value = await res.text()
} else {
const out = await res.json()
data.value.push(...out["data"])
}
loading.value = false
}
onMounted(() => readPacks())
const submitting = ref(false)
async function deletePack(item: any) {
submitting.value = true
const res = await solarFetch(`/cgi/uc/stickers/packs/${item.id}`, {
method: "DELETE",
})
if (res.status !== 200) {
error.value = await res.text()
} else {
data.value = []
await readPacks()
}
submitting.value = false
}
</script>

View File

@ -0,0 +1,99 @@
<template>
<v-container class="px-12">
<div class="flex justify-between items-center mt-5">
<div class="flex items-end gap-2">
<h1 class="text-2xl">Create a new sticker pack</h1>
</div>
<div class="flex gap-2">
<v-btn
color="grey"
text="Cancel"
prepend-icon="mdi-arrow-left"
variant="tonal"
to="/creator/stickers"
/>
</div>
</div>
<v-expand-transition>
<v-alert v-if="error" variant="tonal" type="error" class="text-xs mt-5 mb-3">
{{ t("errorOccurred", [error]) }}
</v-alert>
</v-expand-transition>
<v-form class="mt-5" @submit.prevent="submit">
<v-row>
<v-col cols="12" md="6">
<v-text-field
label="Name"
name="name"
variant="outlined"
persistent-hint
hint="A human friendly name for user to recognize this sticker pack"
/>
</v-col>
<v-col cols="12" md="6">
<v-text-field
label="Prefix"
name="prefix"
variant="outlined"
persistent-hint
hint="A prefix for every sticker in this pack, will add before sticker's alias"
/>
</v-col>
<v-col cols="12">
<v-textarea
auto-grow
rows="3"
label="Description"
name="description"
variant="outlined"
persistent-hint
hint="A description for user to know about this sticker pack"
/>
</v-col>
</v-row>
<div class="flex justify-end">
<v-btn type="submit" text="Create" append-icon="mdi-plus" :loading="submitting" />
</div>
</v-form>
</v-container>
</template>
<script setup lang="ts">
definePageMeta({
layout: "creator-hub",
middleware: ["auth"],
})
useHead({
title: "New Sticker Pack",
})
const { t } = useI18n()
const error = ref<null | string>(null)
const submitting = ref(false)
async function submit(evt: SubmitEvent) {
const data = Object.fromEntries(new FormData(evt.target as HTMLFormElement).entries())
if (!data.name) return
submitting.value = true
const res = await solarFetch("/cgi/uc/stickers/packs", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(data),
})
if (res.status != 200) {
error.value = await res.text()
} else {
navigateTo('/creator/stickers')
}
submitting.value = false
}
</script>

View File

@ -45,6 +45,7 @@
size="x-small"
color="info"
icon="mdi-key"
class="ms-[-8px]"
/>
</template>
</dev-bot-token-dialog>
@ -99,6 +100,7 @@ import { solarFetch } from "~/utils/request"
definePageMeta({
layout: "dev-portal",
middleware: ["auth"],
})
useHead({

View File

@ -61,6 +61,7 @@
<script setup lang="ts">
definePageMeta({
layout: "dev-portal",
middleware: ["auth"],
})
useHead({

View File

@ -5,7 +5,7 @@
<div class="max-w-[320px]">Switch page using navigator above to get start developing with Solar Network.</div>
<div class="text-xs font-mono text-grey mt-5">
@{{ auth.userinfo?.name }} · {{ auth.userinfo?.id.toString().padStart(8, '0') }}
@{{ auth.userinfo?.name }} · {{ auth.userinfo?.id.toString().padStart(8, "0") }}
</div>
</v-container>
</template>
@ -13,6 +13,7 @@
<script setup lang="ts">
definePageMeta({
layout: "dev-portal",
middleware: ["auth"],
})
useHead({

View File

@ -10,7 +10,7 @@
<v-select
label="Storage pool"
variant="underlined"
variant="solo"
:items="poolOptions"
item-title="label"
item-value="value"
@ -80,10 +80,21 @@ useHead({
})
const { t } = useI18n()
const route = useRoute()
onMounted(() => {
if (route.query.pool) {
pool.value = atob(decodeURIComponent(route.query.pool.toString()))
if (pool.value == "dedicated") {
pool.value = poolOptions[0].value
}
}
})
const poolOptions = [
{ label: "Interactive", description: "Public indexable, no lifecycle.", value: "interactive" },
{ label: "Messaging", description: "Has lifecycle, will delete after 14 days.", value: "messaging" },
{ label: "Sticker", description: "Public indexable, privilege required.", value: "sticker", disabled: true },
{ label: "Dedicated Pool", description: "Your own configuration, coming soon.", value: "dedicated", disabled: true },
]

View File

@ -32,7 +32,7 @@
</v-card-text>
</v-card>
<v-card class="w-28 aspect-square cursor-not-allowed" disabled>
<v-card class="w-28 aspect-square cursor-not-allowed" to="/creator">
<v-card-text class="flex flex-col justify-center items-center text-center h-full">
<v-icon icon="mdi-pencil" size="32" />
<span class="text-sm mt-1.75">Creator Hub</span>

View File

@ -1,5 +1,8 @@
User-agent: *
Disallow: /embed
Disallow: /dev
Disallow: /creator
Disallow: /users/me
Allow: /
Sitemap: https://solsynth.dev/sitemap.xml