Compare commits
10 Commits
72ca5e9b77
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
7170a6214b
|
|||
|
c946d019b3
|
|||
|
01dcf193dd
|
|||
|
f236e818af
|
|||
|
2636c58d37
|
|||
|
093b5bf9a9
|
|||
|
302d5cb293
|
|||
|
0523df45cf
|
|||
|
b295012340
|
|||
|
2c395e36d3
|
1
.dockerignore
Normal file
1
.dockerignore
Normal file
@@ -0,0 +1 @@
|
||||
node_modules/
|
||||
32
Dockerfile
Normal file
32
Dockerfile
Normal file
@@ -0,0 +1,32 @@
|
||||
# Stage 1: Build the application
|
||||
FROM oven/bun:1 as builder
|
||||
WORKDIR /app
|
||||
|
||||
# Copy dependency definition files
|
||||
COPY package.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN bun install
|
||||
|
||||
# Copy the rest of the application code
|
||||
COPY . .
|
||||
|
||||
# Build the Nuxt application
|
||||
RUN bun run build
|
||||
|
||||
# Stage 2: Create the production image
|
||||
FROM node:20-slim as runner
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the built output from the builder stage
|
||||
COPY --from=builder /app/.output ./.output
|
||||
|
||||
# Set environment variables for the Nuxt server
|
||||
ENV HOST=0.0.0.0
|
||||
ENV PORT=3000
|
||||
|
||||
# Expose the port the app runs on
|
||||
EXPOSE 3000
|
||||
|
||||
# The command to run the application
|
||||
CMD ["node", ".output/server/index.mjs"]
|
||||
@@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<naive-config>
|
||||
<n-global-style />
|
||||
<n-dialog-provider>
|
||||
<n-notification-provider>
|
||||
<naive-notification />
|
||||
|
||||
4
app/components.d.ts
vendored
4
app/components.d.ts
vendored
@@ -35,6 +35,7 @@ declare module 'vue' {
|
||||
NEmpty: typeof import('naive-ui')['NEmpty']
|
||||
NForm: typeof import('naive-ui')['NForm']
|
||||
NFormItem: typeof import('naive-ui')['NFormItem']
|
||||
NGlobalStyle: typeof import('naive-ui')['NGlobalStyle']
|
||||
NIcon: typeof import('naive-ui')['NIcon']
|
||||
NImage: typeof import('naive-ui')['NImage']
|
||||
NImagePreview: typeof import('naive-ui')['NImagePreview']
|
||||
@@ -48,6 +49,7 @@ declare module 'vue' {
|
||||
NMessageProvider: typeof import('naive-ui')['NMessageProvider']
|
||||
NModal: typeof import('naive-ui')['NModal']
|
||||
NNotificationProvider: typeof import('naive-ui')['NNotificationProvider']
|
||||
NPopover: typeof import('naive-ui')['NPopover']
|
||||
NProgress: typeof import('naive-ui')['NProgress']
|
||||
NRadio: typeof import('naive-ui')['NRadio']
|
||||
NRadioGroup: typeof import('naive-ui')['NRadioGroup']
|
||||
@@ -92,6 +94,7 @@ declare global {
|
||||
const NEmpty: typeof import('naive-ui')['NEmpty']
|
||||
const NForm: typeof import('naive-ui')['NForm']
|
||||
const NFormItem: typeof import('naive-ui')['NFormItem']
|
||||
const NGlobalStyle: typeof import('naive-ui')['NGlobalStyle']
|
||||
const NIcon: typeof import('naive-ui')['NIcon']
|
||||
const NImage: typeof import('naive-ui')['NImage']
|
||||
const NImagePreview: typeof import('naive-ui')['NImagePreview']
|
||||
@@ -105,6 +108,7 @@ declare global {
|
||||
const NMessageProvider: typeof import('naive-ui')['NMessageProvider']
|
||||
const NModal: typeof import('naive-ui')['NModal']
|
||||
const NNotificationProvider: typeof import('naive-ui')['NNotificationProvider']
|
||||
const NPopover: typeof import('naive-ui')['NPopover']
|
||||
const NProgress: typeof import('naive-ui')['NProgress']
|
||||
const NRadio: typeof import('naive-ui')['NRadio']
|
||||
const NRadioGroup: typeof import('naive-ui')['NRadioGroup']
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
<audio
|
||||
v-else-if="itemType == 'audio'"
|
||||
class="w-full h-auto"
|
||||
class="w-full"
|
||||
:src="remoteSource"
|
||||
controls
|
||||
/>
|
||||
|
||||
@@ -31,8 +31,7 @@
|
||||
</n-carousel>
|
||||
</div>
|
||||
|
||||
<!-- Mixed content: vertical scrollable -->
|
||||
<div v-else class="space-y-4 max-h-96 overflow-y-auto">
|
||||
<div v-else class="space-y-4 flex flex-col">
|
||||
<attachment-item
|
||||
v-for="attachment in attachments"
|
||||
:key="attachment.id"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="flex flex-col gap-2">
|
||||
<div class="flex flex-col gap-3">
|
||||
<pub-select v-model:value="publisher" />
|
||||
<n-input
|
||||
v-model:value="content"
|
||||
@@ -8,11 +8,11 @@
|
||||
@keydown.meta.enter.exact="submit"
|
||||
@keydown.ctrl.enter.exact="submit"
|
||||
/>
|
||||
<div class="flex justify-between">
|
||||
<div class="flex justify-end">
|
||||
<n-button type="primary" :loading="submitting" @click="submit">
|
||||
Post
|
||||
<template #icon>
|
||||
<span class="mdi mdi-send"></span>
|
||||
<n-icon :component="SendIcon" />
|
||||
</template>
|
||||
</n-button>
|
||||
</div>
|
||||
@@ -20,8 +20,9 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { useSolarNetwork } from '~/composables/useSolarNetwork'
|
||||
import { SendIcon } from "lucide-vue-next"
|
||||
import { ref } from "vue"
|
||||
import { useSolarNetwork } from "~/composables/useSolarNetwork"
|
||||
|
||||
// Interface for uploaded files in the editor
|
||||
interface UploadedFile {
|
||||
@@ -30,10 +31,10 @@ interface UploadedFile {
|
||||
type: string
|
||||
}
|
||||
|
||||
const emits = defineEmits(['posted'])
|
||||
const emits = defineEmits(["posted"])
|
||||
|
||||
const publisher = ref<string | undefined>()
|
||||
const content = ref('')
|
||||
const content = ref("")
|
||||
|
||||
const fileList = ref<UploadedFile[]>([])
|
||||
|
||||
@@ -43,21 +44,21 @@ async function submit() {
|
||||
submitting.value = true
|
||||
const api = useSolarNetwork()
|
||||
await api(`/sphere/posts?pub=${publisher.value}`, {
|
||||
method: 'POST',
|
||||
method: "POST",
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
"content-type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
content: content.value,
|
||||
attachments: fileList.value
|
||||
.filter((e) => e.url != null)
|
||||
.map((e) => e.url!.split('/').reverse()[0]),
|
||||
}),
|
||||
.map((e) => e.url!.split("/").reverse()[0])
|
||||
})
|
||||
})
|
||||
|
||||
submitting.value = false
|
||||
content.value = ''
|
||||
content.value = ""
|
||||
fileList.value = []
|
||||
emits('posted')
|
||||
emits("posted")
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,23 +1,78 @@
|
||||
<template>
|
||||
<n-card title="Post your reply" size="small" embedded>
|
||||
<n-input
|
||||
type="textarea"
|
||||
placeholder="Talk about this post for a bit."
|
||||
size="large"
|
||||
:rows="5"
|
||||
auto-grow
|
||||
></n-input>
|
||||
<div class="flex justify-end mt-3">
|
||||
<n-button type="primary">
|
||||
<template #icon>
|
||||
<n-icon :component="SendIcon" />
|
||||
<n-card title="Quick Reply" size="small" embedded>
|
||||
<div class="flex flex-col gap-2 mb-1">
|
||||
<pub-select v-model:value="publisher" />
|
||||
<n-input
|
||||
v-model:value="content"
|
||||
type="textarea"
|
||||
placeholder="Talk about this post for a bit."
|
||||
size="large"
|
||||
:rows="3"
|
||||
auto-grow
|
||||
@keydown.meta.enter.exact="submit"
|
||||
@keydown.ctrl.enter.exact="submit"
|
||||
>
|
||||
<template #suffix>
|
||||
<div class="flex items-end h-full py-3">
|
||||
<n-button text :loading="submitting" @click="submit">
|
||||
<template #icon>
|
||||
<n-icon :component="SendIcon" />
|
||||
</template>
|
||||
</n-button>
|
||||
</div>
|
||||
</template>
|
||||
Send
|
||||
</n-button>
|
||||
</n-input>
|
||||
</div>
|
||||
</n-card>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { SendIcon } from "lucide-vue-next"
|
||||
import { ref } from "vue"
|
||||
import { useSolarNetwork } from "~/composables/useSolarNetwork"
|
||||
|
||||
// Interface for uploaded files in the editor
|
||||
interface UploadedFile {
|
||||
name: string
|
||||
url: string
|
||||
type: string
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
repliedPostId: string
|
||||
}>()
|
||||
|
||||
const emits = defineEmits(["posted"])
|
||||
|
||||
const publisher = ref<string | undefined>()
|
||||
const content = ref("")
|
||||
|
||||
const fileList = ref<UploadedFile[]>([])
|
||||
|
||||
const submitting = ref(false)
|
||||
|
||||
async function submit() {
|
||||
if (!content.value.trim()) return
|
||||
|
||||
submitting.value = true
|
||||
const api = useSolarNetwork()
|
||||
await api(`/sphere/posts?pub=${publisher.value}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"content-type": "application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
content: content.value,
|
||||
replied_post_id: props.repliedPostId,
|
||||
attachments: fileList.value
|
||||
.filter((e) => e.url != null)
|
||||
.map((e) => e.url!.split("/").reverse()[0])
|
||||
})
|
||||
})
|
||||
|
||||
submitting.value = false
|
||||
content.value = ""
|
||||
fileList.value = []
|
||||
emits("posted")
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
<template>
|
||||
<div class="replies-list">
|
||||
<post-quick-reply v-if="!props.hideQuickReply" class="mb-4" />
|
||||
<post-quick-reply
|
||||
v-if="!props.hideQuickReply"
|
||||
:replied-post-id="props.params.postId"
|
||||
@posted="refresh"
|
||||
class="mb-4"
|
||||
/>
|
||||
|
||||
<!-- Error State -->
|
||||
<n-alert
|
||||
|
||||
@@ -1,65 +1,74 @@
|
||||
<template>
|
||||
<n-select
|
||||
:options="pubStore.publishers"
|
||||
label-field="nick"
|
||||
value-field="name"
|
||||
:value="props.value"
|
||||
@update:value="(v) => emits('update:value', v)"
|
||||
:render-label="renderLabel"
|
||||
:render-tag="renderTag"
|
||||
/>
|
||||
<n-config-provider :theme-overrides="{ common: { borderRadius: '8px' } }">
|
||||
<n-select
|
||||
:options="pubStore.publishers"
|
||||
label-field="nick"
|
||||
value-field="name"
|
||||
:value="props.value"
|
||||
@update:value="(v) => emits('update:value', v)"
|
||||
:render-label="renderLabel"
|
||||
:render-tag="renderTag"
|
||||
/>
|
||||
</n-config-provider>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { usePubStore } from '~/stores/pub'
|
||||
import { watch, h } from 'vue'
|
||||
import type { SelectRenderLabel, SelectRenderTag } from 'naive-ui'
|
||||
import { usePubStore } from "~/stores/pub"
|
||||
import { watch, h } from "vue"
|
||||
import type { SelectRenderLabel, SelectRenderTag } from "naive-ui"
|
||||
|
||||
const pubStore = usePubStore()
|
||||
const apiBase = useSolarNetworkUrl()
|
||||
|
||||
const props = defineProps<{ value: string | undefined }>()
|
||||
const emits = defineEmits(['update:value'])
|
||||
const emits = defineEmits(["update:value"])
|
||||
|
||||
const renderLabel: SelectRenderLabel = (option) => {
|
||||
return h('div', { class: 'flex items-center' }, [
|
||||
const pubData = pubStore.publishers.filter((p) => p.id == option.id)[0]
|
||||
return h("div", { class: "flex items-center" }, [
|
||||
h(NAvatar, {
|
||||
src: option.picture ? `${apiBase.value}/drive/files/${option.picture.id}` : undefined,
|
||||
size: 'small',
|
||||
class: 'mr-2'
|
||||
round: true,
|
||||
src: pubData?.picture?.id
|
||||
? `${apiBase}/drive/files/${pubData.picture!.id}`
|
||||
: undefined,
|
||||
size: "small",
|
||||
class: "mr-2"
|
||||
}),
|
||||
h('div', null, [
|
||||
h('div', null, option.nick as string),
|
||||
h('div', { class: 'text-xs text-gray-500' }, `@${option.name as string}`)
|
||||
h("div", null, [
|
||||
h("div", null, pubData!.nick),
|
||||
h("div", { class: "text-xs opacity-80" }, `@${pubData!.name as string}`)
|
||||
])
|
||||
])
|
||||
}
|
||||
|
||||
const renderTag: SelectRenderTag = ({ option }) => {
|
||||
const pubData = pubStore.publishers.filter((p) => p.id == option.id)[0]
|
||||
return h(
|
||||
'div',
|
||||
"div",
|
||||
{
|
||||
class: 'flex items-center'
|
||||
class: "flex items-center"
|
||||
},
|
||||
[
|
||||
h(NAvatar, {
|
||||
src: option.picture ? `${apiBase.value}/drive/files/${option.picture.id}` : undefined,
|
||||
size: 'small',
|
||||
class: 'mr-2'
|
||||
round: true,
|
||||
src: pubData?.picture?.id
|
||||
? `${apiBase}/drive/files/${pubData.picture!.id}`
|
||||
: undefined,
|
||||
size: "small",
|
||||
class: "mr-2"
|
||||
}),
|
||||
option.nick as string
|
||||
]
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
watch(
|
||||
pubStore,
|
||||
(value) => {
|
||||
if (!props.value && value.publishers) {
|
||||
emits('update:value', pubStore.publishers[0]?.name)
|
||||
emits("update:value", pubStore.publishers[0]?.name)
|
||||
}
|
||||
},
|
||||
{ deep: true, immediate: true },
|
||||
{ deep: true, immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
80
app/components/VerificationMark.vue
Normal file
80
app/components/VerificationMark.vue
Normal file
@@ -0,0 +1,80 @@
|
||||
<template>
|
||||
<n-popover trigger="hover" placement="top">
|
||||
<template #trigger>
|
||||
<div
|
||||
class="rounded-4xl aspect-square flex items-center justify-center mb-1"
|
||||
:style="`background-color: ${verificationColor}; width: ${
|
||||
props.size ?? 16
|
||||
}px; height: ${props.size ?? 16}px`"
|
||||
>
|
||||
<component
|
||||
:is="verificationIcon"
|
||||
fill="white"
|
||||
stroke="white"
|
||||
style="padding: 0.2rem"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<div class="max-w-xs">
|
||||
<div class="font-bold">{{ mark.title || "No title" }}</div>
|
||||
<div class="text-sm mt-1">{{ mark.description || "No description" }}</div>
|
||||
</div>
|
||||
</n-popover>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue"
|
||||
import type { SnVerification } from "~/types/api/publisher"
|
||||
import {
|
||||
Wrench,
|
||||
BadgeCheck,
|
||||
ShieldCheck,
|
||||
Landmark,
|
||||
Palette,
|
||||
Code,
|
||||
Drama
|
||||
} from "lucide-vue-next"
|
||||
|
||||
interface Props {
|
||||
mark: SnVerification
|
||||
size?: number
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
// Icon mapping based on verification type
|
||||
const verificationIcons = [
|
||||
Wrench, // 0: build_circle equivalent
|
||||
BadgeCheck, // 1: verified
|
||||
ShieldCheck, // 2: verified (alternative)
|
||||
Landmark, // 3: account_balance
|
||||
Palette, // 4: palette
|
||||
Code, // 5: code
|
||||
Drama // 6: masks
|
||||
]
|
||||
|
||||
// Color mapping based on verification type
|
||||
const verificationColors = [
|
||||
"#14b8a6", // teal
|
||||
"#03a9f4", // lightBlue
|
||||
"#3f51b5", // indigo
|
||||
"#f44336", // red
|
||||
"#ff9800", // orange
|
||||
"#2196f3", // blue
|
||||
"#448aff" // blueAccent
|
||||
]
|
||||
|
||||
const verificationIcon = computed(() => {
|
||||
const type = props.mark.type
|
||||
return type >= 0 && type < verificationIcons.length
|
||||
? verificationIcons[type]
|
||||
: BadgeCheck
|
||||
})
|
||||
|
||||
const verificationColor = computed(() => {
|
||||
const type = props.mark.type
|
||||
return type >= 0 && type < verificationColors.length
|
||||
? verificationColors[type]
|
||||
: "#2196f3"
|
||||
})
|
||||
</script>
|
||||
83
app/components/VerificationStatusCard.vue
Normal file
83
app/components/VerificationStatusCard.vue
Normal file
@@ -0,0 +1,83 @@
|
||||
<template>
|
||||
<div v-if="mark" class="verification-card">
|
||||
<div class="flex items-start">
|
||||
<n-icon
|
||||
:component="verificationIcon"
|
||||
:size="32"
|
||||
:color="verificationColor"
|
||||
class="shrink-0"
|
||||
/>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<div class="font-bold text-base">{{ mark.title || "No title" }}</div>
|
||||
<div class="text-sm mt-1">{{ mark.description || "No description" }}</div>
|
||||
<div class="text-xs mt-1.5 opacity-80">
|
||||
Verified by<br />{{ mark.verifiedBy || "No one verified it" }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue"
|
||||
import type { SnVerification } from "~/types/api/publisher"
|
||||
import {
|
||||
Wrench,
|
||||
BadgeCheck,
|
||||
ShieldCheck,
|
||||
Landmark,
|
||||
Palette,
|
||||
Code,
|
||||
Drama
|
||||
} from "lucide-vue-next"
|
||||
|
||||
interface Props {
|
||||
mark: SnVerification
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
||||
// Icon mapping based on verification type
|
||||
const verificationIcons = [
|
||||
Wrench, // 0: build_circle equivalent
|
||||
BadgeCheck, // 1: verified
|
||||
ShieldCheck, // 2: verified (alternative)
|
||||
Landmark, // 3: account_balance
|
||||
Palette, // 4: palette
|
||||
Code, // 5: code
|
||||
Drama // 6: masks
|
||||
]
|
||||
|
||||
// Color mapping based on verification type
|
||||
const verificationColors = [
|
||||
"#14b8a6", // teal
|
||||
"#03a9f4", // lightBlue
|
||||
"#3f51b5", // indigo
|
||||
"#f44336", // red
|
||||
"#ff9800", // orange
|
||||
"#2196f3", // blue
|
||||
"#448aff" // blueAccent
|
||||
]
|
||||
|
||||
const verificationIcon = computed(() => {
|
||||
const type = props.mark.type
|
||||
return type >= 0 && type < verificationIcons.length
|
||||
? verificationIcons[type]
|
||||
: BadgeCheck
|
||||
})
|
||||
|
||||
const verificationColor = computed(() => {
|
||||
const type = props.mark.type
|
||||
return type >= 0 && type < verificationColors.length
|
||||
? verificationColors[type]
|
||||
: "#2196f3"
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.verification-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
</style>
|
||||
@@ -20,7 +20,8 @@ export const useSolarNetwork = () => {
|
||||
console.log(`[useSolarNetwork] onRequest for ${request} on ${side}`)
|
||||
|
||||
if (devToken) {
|
||||
options.headers = new Headers(options.headers)
|
||||
console.log("[useSolarNetwork] Using dev token...")
|
||||
options.headers.delete("Cookie")
|
||||
options.headers.set("Authorization", `Bearer ${devToken}`)
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
import IconLight from "~/assets/images/cloudy-lamb.png"
|
||||
|
||||
import type { MenuOption } from "naive-ui"
|
||||
import { NIcon } from "naive-ui"
|
||||
import { computed, h } from "vue"
|
||||
import { useRouter, useRoute, RouterLink } from "vue-router"
|
||||
import {
|
||||
|
||||
@@ -166,6 +166,16 @@
|
||||
:show-indicator="false"
|
||||
/>
|
||||
</n-card>
|
||||
|
||||
<n-card
|
||||
v-if="user?.profile?.verification"
|
||||
size="small"
|
||||
:class="cardClass"
|
||||
:style="cardStyle"
|
||||
:content-style="cardContentStyle"
|
||||
>
|
||||
<verification-status-card :mark="user.profile.verification" />
|
||||
</n-card>
|
||||
</div>
|
||||
<div>
|
||||
<n-card
|
||||
@@ -252,7 +262,7 @@ try {
|
||||
console.error("Failed to fetch user:", error.value)
|
||||
notFound.value = true
|
||||
} else if (data.value) {
|
||||
user.value = data.value
|
||||
user.value = keysToCamel(data.value)
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to fetch user:", err)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="container mx-auto px-5">
|
||||
<div class="layout">
|
||||
<div class="main">
|
||||
<div class="main pt-4">
|
||||
<n-infinite-scroll
|
||||
style="overflow: auto"
|
||||
:distance="0"
|
||||
@@ -37,7 +37,7 @@
|
||||
</div>
|
||||
</n-infinite-scroll>
|
||||
</div>
|
||||
<div class="sidebar flex flex-col gap-3">
|
||||
<div class="sidebar flex flex-col gap-3 pt-4">
|
||||
<div v-if="!userStore.isAuthenticated">
|
||||
<n-card>
|
||||
<h2 class="card-title">About</h2>
|
||||
@@ -54,11 +54,9 @@
|
||||
</p>
|
||||
</n-card>
|
||||
</div>
|
||||
<div v-else class="card w-full bg-base-100 shadow-xl">
|
||||
<div class="card-body">
|
||||
<post-editor @posted="refreshActivities" />
|
||||
</div>
|
||||
</div>
|
||||
<n-card v-else class="w-full">
|
||||
<post-editor @posted="refreshActivities" />
|
||||
</n-card>
|
||||
<sidebar-footer class="max-lg:hidden" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -180,7 +178,7 @@ async function refreshActivities() {
|
||||
@media (min-width: 1280px) {
|
||||
.sidebar {
|
||||
position: sticky;
|
||||
top: calc(68px + 8px);
|
||||
top: calc(64px);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -30,6 +30,15 @@
|
||||
v-html="htmlBio"
|
||||
></article>
|
||||
</n-card>
|
||||
|
||||
<n-card
|
||||
v-if="user.verification"
|
||||
:class="cardClass"
|
||||
:style="cardStyle"
|
||||
:content-style="cardContentStyle"
|
||||
>
|
||||
<verification-status-card :mark="user.verification" />
|
||||
</n-card>
|
||||
</div>
|
||||
<div class="main">
|
||||
<!-- Filter Section -->
|
||||
|
||||
595
app/pages/realms/[slug].vue
Normal file
595
app/pages/realms/[slug].vue
Normal file
@@ -0,0 +1,595 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- Invite Variant: Centered Card -->
|
||||
<div v-if="isInviteMode">
|
||||
<div
|
||||
class="fixed inset-0 transition-all duration-500"
|
||||
:style="pageStyle"
|
||||
/>
|
||||
|
||||
<div
|
||||
class="relative flex items-center justify-center min-h-layout overflow-auto p-4"
|
||||
>
|
||||
<n-card
|
||||
:class="[
|
||||
'w-full',
|
||||
'max-w-[480px]',
|
||||
{ 'backdrop-blur-2xl': realmBackground },
|
||||
{ 'shadow-xl': realmBackground }
|
||||
]"
|
||||
size="large"
|
||||
:style="
|
||||
realmBackground ? 'background-color: rgba(255, 255, 255, 0.1)' : ''
|
||||
"
|
||||
:content-style="
|
||||
realmBackground ? 'background-color: transparent' : ''
|
||||
"
|
||||
>
|
||||
<div v-if="realm" class="p-4">
|
||||
<div class="flex flex-col items-center text-center">
|
||||
<n-avatar :src="realmPicture" :size="80" class="mb-4">
|
||||
<n-icon v-if="!realmPicture" :component="Users" :size="40" />
|
||||
</n-avatar>
|
||||
|
||||
<div class="flex gap-2 items-center">
|
||||
<h2 class="text-2xl font-bold mb-2">{{ realm.name }}</h2>
|
||||
<verification-mark
|
||||
v-if="realm.verification"
|
||||
:mark="realm.verification"
|
||||
:size="20"
|
||||
/>
|
||||
</div>
|
||||
<p v-if="realm.description" class="text-base mb-4 opacity-80">
|
||||
{{ realm.description }}
|
||||
</p>
|
||||
|
||||
<div class="flex gap-2 mb-6">
|
||||
<n-tag :bordered="false" type="info">
|
||||
{{ realm.isCommunity ? "Community" : "Organization" }}
|
||||
</n-tag>
|
||||
<n-tag
|
||||
:bordered="false"
|
||||
:type="realm.isPublic ? 'success' : 'warning'"
|
||||
>
|
||||
{{ realm.isPublic ? "Public" : "Private" }}
|
||||
</n-tag>
|
||||
</div>
|
||||
|
||||
<n-card
|
||||
v-if="realm.verification"
|
||||
class="text-left mb-4 w-full"
|
||||
:style="
|
||||
realmBackground
|
||||
? 'background-color: rgba(255, 255, 255, 0.1)'
|
||||
: ''
|
||||
"
|
||||
:content-style="
|
||||
realmBackground ? 'background-color: transparent' : ''
|
||||
"
|
||||
>
|
||||
<verification-status-card :mark="realm.verification" />
|
||||
</n-card>
|
||||
|
||||
<n-button
|
||||
text-color="white"
|
||||
type="primary"
|
||||
block
|
||||
size="large"
|
||||
:loading="isJoining"
|
||||
:disabled="isMember"
|
||||
@click="handleJoin"
|
||||
>
|
||||
<template #icon>
|
||||
<n-icon :component="UserPlus" />
|
||||
</template>
|
||||
Join Realm
|
||||
</n-button>
|
||||
|
||||
<n-alert
|
||||
v-if="isMember"
|
||||
type="info"
|
||||
title="Already Joined"
|
||||
class="mt-4"
|
||||
>
|
||||
You already joined this realm,
|
||||
<nuxt-link
|
||||
:to="`/realms/${route.params.slug}`"
|
||||
class="underline font-bold"
|
||||
>
|
||||
go to the realm page instead.
|
||||
</nuxt-link>
|
||||
</n-alert>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="notFound" class="flex justify-center p-8">
|
||||
<n-empty description="Realm not found">
|
||||
<template #icon>
|
||||
<n-icon :component="Users" />
|
||||
</template>
|
||||
</n-empty>
|
||||
</div>
|
||||
<div v-else class="flex justify-center p-8">
|
||||
<n-spin size="large" />
|
||||
</div>
|
||||
</n-card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Regular View: Full Realm Page -->
|
||||
<div v-else>
|
||||
<div class="fixed inset-0 blur-md" :style="pageStyle" />
|
||||
<img
|
||||
:src="realmBackground"
|
||||
class="w-full max-h-48 object-cover object-top"
|
||||
:style="{ aspectRatio: '16/7', opacity: headerOpacity }"
|
||||
/>
|
||||
<div v-if="realm" class="relative min-h-layout">
|
||||
<div class="container mx-auto p-4 sm:p-8">
|
||||
<div class="layout">
|
||||
<div class="sidebar flex flex-col gap-3">
|
||||
<n-card
|
||||
:class="cardClass"
|
||||
:style="cardStyle"
|
||||
:content-style="cardContentStyle"
|
||||
>
|
||||
<div class="flex items-center gap-4 mb-4">
|
||||
<n-avatar size="large" round :src="realmPicture">
|
||||
<n-icon
|
||||
v-if="!realmPicture"
|
||||
:component="Users"
|
||||
:size="28"
|
||||
/>
|
||||
</n-avatar>
|
||||
<div>
|
||||
<div class="flex gap-2 items-center">
|
||||
<div class="text-xl font-bold">
|
||||
{{ realm.name }}
|
||||
</div>
|
||||
<verification-mark
|
||||
v-if="realm.verification"
|
||||
:mark="realm.verification"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="text-sm opacity-80">@{{ realm.slug }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="realm.description" class="text-sm mb-4">
|
||||
{{ realm.description }}
|
||||
</p>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<n-tag :bordered="false" type="info">
|
||||
{{ realm.isCommunity ? "Community" : "Organization" }}
|
||||
</n-tag>
|
||||
<n-tag
|
||||
:bordered="false"
|
||||
:type="realm.isPublic ? 'success' : 'warning'"
|
||||
>
|
||||
{{ realm.isPublic ? "Public" : "Private" }}
|
||||
</n-tag>
|
||||
</div>
|
||||
</n-card>
|
||||
|
||||
<n-card
|
||||
v-if="realm.verification"
|
||||
:class="cardClass"
|
||||
:style="cardStyle"
|
||||
:content-style="cardContentStyle"
|
||||
>
|
||||
<verification-status-card :mark="realm.verification" />
|
||||
</n-card>
|
||||
|
||||
<div v-if="realm.isPublic && !isMember">
|
||||
<n-button
|
||||
type="primary"
|
||||
block
|
||||
size="large"
|
||||
:loading="isJoining"
|
||||
@click="handleJoin"
|
||||
>
|
||||
<template #icon>
|
||||
<n-icon :component="UserPlus" />
|
||||
</template>
|
||||
Join Realm
|
||||
</n-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="main">
|
||||
<!-- Filter Section -->
|
||||
<n-card
|
||||
class="mb-4"
|
||||
:class="cardClass"
|
||||
:style="cardStyle"
|
||||
:content-style="cardContentStyle"
|
||||
>
|
||||
<n-tabs v-model:value="activeCategoryTab" type="segment">
|
||||
<n-tab name="all">All</n-tab>
|
||||
<n-tab name="posts">Posts</n-tab>
|
||||
<n-tab name="articles">Articles</n-tab>
|
||||
</n-tabs>
|
||||
|
||||
<div class="mx-4">
|
||||
<div
|
||||
class="grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-2 mt-4"
|
||||
>
|
||||
<div
|
||||
class="flex items-center gap-2 cursor-pointer"
|
||||
@click="cycleIncludeReplies"
|
||||
>
|
||||
<n-icon :component="Reply" />
|
||||
<n-checkbox
|
||||
:checked="includeReplies !== false"
|
||||
:indeterminate="includeReplies === null"
|
||||
@update:checked="cycleIncludeReplies"
|
||||
>
|
||||
Include replies
|
||||
</n-checkbox>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<n-icon :component="Paperclip" />
|
||||
<n-checkbox v-model:checked="mediaOnly">
|
||||
Media only
|
||||
</n-checkbox>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<n-icon :component="ArrowUpDown" />
|
||||
<n-checkbox v-model:checked="orderDesc">
|
||||
Descending order
|
||||
</n-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="flex items-center cursor-pointer mt-4"
|
||||
@click="showAdvancedFilters = !showAdvancedFilters"
|
||||
>
|
||||
<n-icon :component="Filter" />
|
||||
<span class="ml-2 font-medium">Advanced filters</span>
|
||||
<n-icon class="ml-auto">
|
||||
<ChevronDown v-if="!showAdvancedFilters" />
|
||||
<ChevronUp v-else />
|
||||
</n-icon>
|
||||
</div>
|
||||
|
||||
<n-collapse-transition :show="showAdvancedFilters">
|
||||
<div class="mt-4 flex flex-col gap-3">
|
||||
<n-input
|
||||
v-model:value="queryTerm"
|
||||
placeholder="Search posts"
|
||||
>
|
||||
<template #prefix>
|
||||
<n-icon :component="Search" />
|
||||
</template>
|
||||
</n-input>
|
||||
|
||||
<n-config-provider
|
||||
:theme-overrides="{ common: { borderRadius: '8px' } }"
|
||||
>
|
||||
<n-select
|
||||
v-model:value="order"
|
||||
placeholder="Sort by"
|
||||
:options="[
|
||||
{ label: 'Date', value: 'date' },
|
||||
{ label: 'Popularity', value: 'popularity' }
|
||||
]"
|
||||
/>
|
||||
</n-config-provider>
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||
<n-date-picker
|
||||
v-model:value="periodStart"
|
||||
type="date"
|
||||
placeholder="From date"
|
||||
clearable
|
||||
/>
|
||||
<n-date-picker
|
||||
v-model:value="periodEnd"
|
||||
type="date"
|
||||
placeholder="To date"
|
||||
clearable
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</n-collapse-transition>
|
||||
</div>
|
||||
</n-card>
|
||||
|
||||
<post-list :key="filterKey" :params="postListParams" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="notFound"
|
||||
class="relative flex justify-center items-center h-full"
|
||||
>
|
||||
<n-empty description="The realm you're trying to access is not found.">
|
||||
<template #icon>
|
||||
<n-icon :component="Users" />
|
||||
</template>
|
||||
</n-empty>
|
||||
</div>
|
||||
<div v-else class="relative flex justify-center items-center h-full">
|
||||
<n-spin size="large" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from "vue"
|
||||
import { useWindowScroll } from "@vueuse/core"
|
||||
import { useMarkdownProcessor } from "~/composables/useMarkdownProcessor"
|
||||
import type { SnRealm } from "~/types/api"
|
||||
import type { PostListParams } from "~/composables/usePostList"
|
||||
import PostList from "~/components/Post/PostList.vue"
|
||||
import {
|
||||
Reply,
|
||||
Paperclip,
|
||||
ArrowUpDown,
|
||||
Filter,
|
||||
Search,
|
||||
ChevronDown,
|
||||
ChevronUp,
|
||||
Users,
|
||||
UserPlus
|
||||
} from "lucide-vue-next"
|
||||
|
||||
const route = useRoute()
|
||||
const message = useMessage()
|
||||
const api = useSolarNetwork()
|
||||
|
||||
const notFound = ref<boolean>(false)
|
||||
const realm = ref<SnRealm | null>(null)
|
||||
const isJoining = ref(false)
|
||||
const isMember = ref(false)
|
||||
const checkingMembership = ref(false)
|
||||
|
||||
// Check if we're in invite mode
|
||||
const isInviteMode = computed(() => {
|
||||
return !!route.query.invite
|
||||
})
|
||||
|
||||
// Use useFetch with the correct API URL to avoid router conflicts
|
||||
const apiBase = useSolarNetworkUrl()
|
||||
const apiBaseServer = useSolarNetworkUrl()
|
||||
|
||||
try {
|
||||
const { data, error } = await useFetch<SnRealm>(
|
||||
`${apiBaseServer}/id/realms/${route.params.slug}`,
|
||||
{ server: true }
|
||||
)
|
||||
|
||||
if (error.value) {
|
||||
console.error("Failed to fetch realm:", error.value)
|
||||
notFound.value = true
|
||||
} else if (data.value) {
|
||||
realm.value = keysToCamel(data.value)
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Failed to fetch realm:", err)
|
||||
notFound.value = true
|
||||
}
|
||||
|
||||
const realmBackground = computed(() => {
|
||||
return realm.value?.background
|
||||
? `${apiBase}/drive/files/${realm.value.background.id}?original=true`
|
||||
: undefined
|
||||
})
|
||||
const realmPicture = computed(() => {
|
||||
return realm.value?.picture
|
||||
? `${apiBase}/drive/files/${realm.value.picture.id}`
|
||||
: undefined
|
||||
})
|
||||
|
||||
const { y: scrollY } = useWindowScroll()
|
||||
const scrollThreshold = 192 // max-h-48 is 12rem = 192px
|
||||
|
||||
const backgroundOpacity = computed(() => {
|
||||
return Math.max(0, Math.min(scrollY.value / scrollThreshold, 1))
|
||||
})
|
||||
|
||||
const headerOpacity = computed(() => {
|
||||
return 1 - backgroundOpacity.value
|
||||
})
|
||||
|
||||
const pageStyle = computed(() => {
|
||||
if (!realmBackground.value) return {}
|
||||
return {
|
||||
backgroundImage: `linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)), url('${realmBackground.value}')`,
|
||||
backgroundSize: "cover",
|
||||
backgroundPosition: "center",
|
||||
backgroundRepeat: "no-repeat",
|
||||
backgroundAttachment: "fixed",
|
||||
opacity: isInviteMode.value ? 1 : backgroundOpacity.value
|
||||
}
|
||||
})
|
||||
|
||||
const cardClass = computed(() => ({
|
||||
"backdrop-blur-2xl": !!realmBackground.value,
|
||||
"shadow-xl": !!realmBackground.value
|
||||
}))
|
||||
|
||||
const cardStyle = computed(() =>
|
||||
realmBackground.value
|
||||
? "background-color: var(--n-color-modal)"
|
||||
: "background-color: var(--n-color)"
|
||||
)
|
||||
|
||||
const cardContentStyle = computed(() =>
|
||||
realmBackground.value ? "background-color: transparent" : ""
|
||||
)
|
||||
|
||||
// Filter state
|
||||
const activeCategoryTab = ref("all")
|
||||
const includeReplies = ref<boolean | null>(null)
|
||||
const mediaOnly = ref(false)
|
||||
const orderDesc = ref(true)
|
||||
const showAdvancedFilters = ref(false)
|
||||
const queryTerm = ref("")
|
||||
const order = ref<string | null>(null)
|
||||
const periodStart = ref<number | null>(null)
|
||||
const periodEnd = ref<number | null>(null)
|
||||
|
||||
const postListParams = computed<PostListParams>(() => {
|
||||
const params: PostListParams = {
|
||||
realm: route.params.slug as string,
|
||||
includeReplies: includeReplies.value ?? undefined,
|
||||
mediaOnly: mediaOnly.value,
|
||||
orderDesc: orderDesc.value,
|
||||
queryTerm: queryTerm.value || undefined,
|
||||
order: order.value ?? undefined,
|
||||
periodStart: periodStart.value
|
||||
? Math.floor(periodStart.value / 1000)
|
||||
: undefined,
|
||||
periodEnd: periodEnd.value ? Math.floor(periodEnd.value / 1000) : undefined
|
||||
}
|
||||
|
||||
if (activeCategoryTab.value === "posts") {
|
||||
params.type = 0
|
||||
} else if (activeCategoryTab.value === "articles") {
|
||||
params.type = 1
|
||||
}
|
||||
|
||||
return params
|
||||
})
|
||||
|
||||
const filterKey = computed(() => {
|
||||
return JSON.stringify(postListParams.value)
|
||||
})
|
||||
|
||||
const cycleIncludeReplies = () => {
|
||||
if (includeReplies.value === null) {
|
||||
includeReplies.value = true
|
||||
} else if (includeReplies.value === true) {
|
||||
includeReplies.value = false
|
||||
} else {
|
||||
includeReplies.value = null
|
||||
}
|
||||
}
|
||||
|
||||
// Check membership status
|
||||
async function checkMembership() {
|
||||
if (!realm.value) return
|
||||
|
||||
checkingMembership.value = true
|
||||
try {
|
||||
await api(`/id/realms/${realm.value.slug}/members/me`, {
|
||||
method: "GET"
|
||||
})
|
||||
isMember.value = true
|
||||
} catch (err) {
|
||||
// 404 means not a member
|
||||
isMember.value = false
|
||||
} finally {
|
||||
checkingMembership.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// Handle join realm
|
||||
async function handleJoin() {
|
||||
if (!realm.value) return
|
||||
|
||||
isJoining.value = true
|
||||
try {
|
||||
await api(`/id/realms/${realm.value.slug}/members/me`, {
|
||||
method: "POST"
|
||||
})
|
||||
message.success(`Successfully joined ${realm.value.name}!`)
|
||||
isMember.value = true
|
||||
// Redirect to the realm page without invite query if in invite mode
|
||||
if (isInviteMode.value) {
|
||||
await navigateTo(`/realms/${realm.value.slug}`)
|
||||
}
|
||||
} catch (err) {
|
||||
message.error(err instanceof Error ? err.message : String(err))
|
||||
} finally {
|
||||
isJoining.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// Check membership on mount
|
||||
onMounted(() => {
|
||||
if (realm.value) {
|
||||
checkMembership()
|
||||
}
|
||||
})
|
||||
|
||||
definePageMeta({
|
||||
title: "Realms",
|
||||
alias: ["/r/:slug()"]
|
||||
})
|
||||
|
||||
useHead({
|
||||
title: computed(() => {
|
||||
if (notFound.value) {
|
||||
return "Realm not found"
|
||||
}
|
||||
if (realm.value) {
|
||||
return realm.value.name
|
||||
}
|
||||
return "Loading realm..."
|
||||
}),
|
||||
meta: computed(() => {
|
||||
if (realm.value) {
|
||||
const description =
|
||||
realm.value.description || `Join ${realm.value.name} on Solar Network.`
|
||||
return [{ name: "description", content: description }]
|
||||
}
|
||||
return []
|
||||
})
|
||||
})
|
||||
|
||||
defineOgImage({
|
||||
component: "ImageCard",
|
||||
// @ts-ignore
|
||||
title: computed(() => (realm.value ? realm.value.name : "Realm")),
|
||||
description: computed(() =>
|
||||
realm.value
|
||||
? realm.value.description || `Join ${realm.value.name} on Solar Network.`
|
||||
: ""
|
||||
),
|
||||
avatarUrl: computed(() => realmPicture.value),
|
||||
backgroundImage: computed(() => realmBackground.value)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.layout {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.main {
|
||||
order: 2;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
order: 1;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
@media (min-width: 960px) {
|
||||
.layout {
|
||||
grid-template-columns: 1fr 2fr;
|
||||
}
|
||||
|
||||
.main {
|
||||
order: unset;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
order: unset;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
.sidebar {
|
||||
position: sticky;
|
||||
top: calc(var(--header-height) + 8px);
|
||||
align-self: start;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,73 +1,21 @@
|
||||
<template>
|
||||
<div class="d-flex align-center justify-center fill-height">
|
||||
<v-card max-width="400" title="Magic Spell" prepend-icon="mdi-magic-staff" class="pa-2">
|
||||
<v-card-text>
|
||||
<v-alert v-if="done" type="success" class="mb-4">
|
||||
The magic spell has been applied successfully. Now you can close this
|
||||
tab and back to the Solar Network!
|
||||
</v-alert>
|
||||
<v-alert
|
||||
v-else-if="!!error"
|
||||
type="error"
|
||||
title="Something went wrong"
|
||||
class="mb-4"
|
||||
>{{ error }}</v-alert
|
||||
>
|
||||
<div v-else-if="!!spell">
|
||||
<p class="mb-2">
|
||||
Magic spell for {{ spellTypes[spell.type] ?? "unknown" }}
|
||||
</p>
|
||||
<div class="d-flex align-center gap-2 mb-2">
|
||||
<v-icon size="18">mdi-account-circle</v-icon>
|
||||
<strong>@{{ spell.account.name }}</strong>
|
||||
</div>
|
||||
<div class="d-flex align-center gap-2 mb-2">
|
||||
<v-icon size="18">mdi-play</v-icon>
|
||||
<span>Available at</span>
|
||||
<strong>{{
|
||||
new Date(spell.createdAt ?? spell.affectedAt).toLocaleString()
|
||||
}}</strong>
|
||||
</div>
|
||||
<div v-if="spell.expiredAt" class="d-flex align-center gap-2 mb-4">
|
||||
<v-icon size="18">mdi-calendar</v-icon>
|
||||
<span>Until</span>
|
||||
<strong>{{ spell.expiredAt.toString() }}</strong>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<v-text-field
|
||||
v-if="spell.type == 3"
|
||||
v-model="newPassword"
|
||||
label="New password"
|
||||
type="password"
|
||||
density="comfortable"
|
||||
></v-text-field>
|
||||
<v-btn color="primary" :loading="submitting" @click="applySpell">
|
||||
<v-icon left>mdi-check</v-icon>
|
||||
Apply
|
||||
</v-btn>
|
||||
</div>
|
||||
</div>
|
||||
<v-progress-circular
|
||||
v-else
|
||||
indeterminate
|
||||
size="32"
|
||||
class="mt-4"
|
||||
></v-progress-circular>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from "vue"
|
||||
import { useRoute } from "vue-router"
|
||||
import { Wand2, User, Clock, Calendar, Check } from "lucide-vue-next"
|
||||
import { useSolarNetwork } from "~/composables/useSolarNetwork"
|
||||
|
||||
const route = useRoute()
|
||||
const api = useSolarNetwork()
|
||||
|
||||
useHead({
|
||||
title: "Magic Spell"
|
||||
})
|
||||
|
||||
const spellWord: string =
|
||||
typeof route.params.word === "string"
|
||||
? route.params.word
|
||||
: route.params.word?.join("/") || ""
|
||||
|
||||
interface SnSpell {
|
||||
type: number
|
||||
account: {
|
||||
@@ -77,13 +25,13 @@ interface SnSpell {
|
||||
affectedAt: string
|
||||
expiredAt?: string
|
||||
}
|
||||
|
||||
const spell = ref<SnSpell | null>(null)
|
||||
const error = ref<string | null>(null)
|
||||
|
||||
const newPassword = ref<string>()
|
||||
|
||||
const submitting = ref(false)
|
||||
const done = ref(false)
|
||||
const loading = ref(true)
|
||||
|
||||
const spellTypes = [
|
||||
"Account Activation",
|
||||
@@ -93,14 +41,17 @@ const spellTypes = [
|
||||
"Contact Method Verification"
|
||||
]
|
||||
|
||||
const api = useSolarNetwork()
|
||||
|
||||
async function fetchSpell() {
|
||||
loading.value = true
|
||||
try {
|
||||
const resp = await api(`/id/spells/${encodeURIComponent(spellWord)}`)
|
||||
const resp = await api<SnSpell>(
|
||||
`/id/spells/${encodeURIComponent(spellWord)}`
|
||||
)
|
||||
spell.value = resp
|
||||
} catch (err: unknown) {
|
||||
error.value = err instanceof Error ? err.message : String(err)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,8 +68,114 @@ async function applySpell() {
|
||||
done.value = true
|
||||
} catch (err: unknown) {
|
||||
error.value = err instanceof Error ? err.message : String(err)
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => fetchSpell())
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="relative flex items-center justify-center min-h-layout px-4">
|
||||
<n-card class="w-full max-w-md shadow-lg" size="large">
|
||||
<div v-if="done" class="py-4">
|
||||
<n-result
|
||||
status="success"
|
||||
title="Spell Applied"
|
||||
description="The magic spell has been applied successfully. Now you can close this tab and return to the Solar Network!"
|
||||
>
|
||||
</n-result>
|
||||
</div>
|
||||
|
||||
<div v-else-if="error">
|
||||
<n-alert title="Something went wrong" type="error" class="mb-4">
|
||||
{{ error }}
|
||||
</n-alert>
|
||||
</div>
|
||||
|
||||
<div v-else-if="loading" class="flex justify-center py-12">
|
||||
<n-spin size="large" />
|
||||
</div>
|
||||
|
||||
<div v-else-if="spell" class="flex flex-col gap-6">
|
||||
<!-- Header -->
|
||||
<div
|
||||
class="flex items-center gap-3 pb-4 border-b border-gray-100 dark:border-gray-800"
|
||||
>
|
||||
<div class="p-2 bg-amber-100 dark:bg-amber-900/30 rounded-lg">
|
||||
<n-icon :component="Wand2" class="text-amber-500" :size="24" />
|
||||
</div>
|
||||
<div>
|
||||
<h2 class="text-xl font-bold">Magic Spell</h2>
|
||||
<p class="text-sm text-gray-500">
|
||||
{{ spellTypes[spell.type] ?? "Unknown Spell" }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Details -->
|
||||
<div class="space-y-4">
|
||||
<div class="flex items-center gap-3">
|
||||
<n-icon :component="User" class="text-gray-400" :size="20" />
|
||||
<div class="flex flex-col">
|
||||
<span class="text-xs text-gray-500 uppercase tracking-wider"
|
||||
>Account</span
|
||||
>
|
||||
<span class="font-medium">@{{ spell.account.name }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-3">
|
||||
<n-icon :component="Clock" class="text-gray-400" :size="20" />
|
||||
<div class="flex flex-col">
|
||||
<span class="text-xs text-gray-500 uppercase tracking-wider"
|
||||
>Available at</span
|
||||
>
|
||||
<span class="font-medium">{{
|
||||
new Date(spell.createdAt ?? spell.affectedAt).toLocaleString()
|
||||
}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="spell.expiredAt" class="flex items-center gap-3">
|
||||
<n-icon :component="Calendar" class="text-gray-400" :size="20" />
|
||||
<div class="flex flex-col">
|
||||
<span class="text-xs text-gray-500 uppercase tracking-wider"
|
||||
>Expires</span
|
||||
>
|
||||
<span class="font-medium">{{
|
||||
new Date(spell.expiredAt).toLocaleString()
|
||||
}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Action -->
|
||||
<div class="mt-2 space-y-4">
|
||||
<n-input
|
||||
v-if="spell.type == 3"
|
||||
v-model:value="newPassword"
|
||||
type="password"
|
||||
show-password-on="click"
|
||||
placeholder="New password"
|
||||
size="large"
|
||||
/>
|
||||
|
||||
<n-button
|
||||
type="primary"
|
||||
class="w-full"
|
||||
size="large"
|
||||
:loading="submitting"
|
||||
@click="applySpell"
|
||||
>
|
||||
<template #icon>
|
||||
<n-icon :component="Check" />
|
||||
</template>
|
||||
Apply Spell
|
||||
</n-button>
|
||||
</div>
|
||||
</div>
|
||||
</n-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -5,7 +5,17 @@ export default defineNuxtPlugin(() => {
|
||||
console.log(`[AUTH PLUGIN] Running on ${side}`)
|
||||
const userStore = useUserStore()
|
||||
|
||||
// Prevent fetching if it's already in progress
|
||||
// Fix hydration mismatch: if isLoading is true on client, it's likely a stale state
|
||||
// from SSR where the fetch didn't complete before the response was sent.
|
||||
// Reset it to allow the client to fetch properly.
|
||||
if (import.meta.client && userStore.isLoading) {
|
||||
console.log(
|
||||
`[AUTH PLUGIN] Detected stale isLoading state on ${side}. Resetting to allow fetch.`
|
||||
)
|
||||
userStore.isLoading = false
|
||||
}
|
||||
|
||||
// Prevent fetching if it's already in progress (server-side only now)
|
||||
if (userStore.isLoading) {
|
||||
console.log(
|
||||
`[AUTH PLUGIN] User fetch already in progress on ${side}. Skipping.`
|
||||
@@ -21,4 +31,3 @@ export default defineNuxtPlugin(() => {
|
||||
userStore.fetchUser()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ export const useUserStore = defineStore("user", () => {
|
||||
console.error("Failed to fetch user... ", e)
|
||||
}
|
||||
|
||||
console.log(`[UserStore] Logged as @${user.value!.name}`)
|
||||
// console.log(`[UserStore] Logged as @${user.value!.name}`)
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
currentFetchPromise.value = null
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
// Re-export all types from separate files for easy importing
|
||||
export type { SnFileMeta, SnCloudFile as SnAttachment, SnPost } from './post'
|
||||
export type { SnVerification, SnPublisher } from './publisher'
|
||||
export type { SnActivity } from './activity'
|
||||
export type { SnWalletOrder, OrderStatus } from './order'
|
||||
export type { SnVersion } from './version'
|
||||
export type { SnAccountLink, SnAccountBadge, SnAccountPerkSubscription, SnAccountProfile, SnAccount } from './user'
|
||||
export type { GeoIpLocation, SnAuthChallenge, SnAuthSession, SnAuthFactor, SnAccountConnection } from './geo'
|
||||
export * from "./post"
|
||||
export * from "./publisher"
|
||||
export * from "./activity"
|
||||
export * from "./order"
|
||||
export * from "./version"
|
||||
export * from "./user"
|
||||
export * from "./geo"
|
||||
export * from "./realm"
|
||||
|
||||
19
app/types/api/realm.ts
Normal file
19
app/types/api/realm.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { SnCloudFile } from "./post"
|
||||
import type { SnVerification as SnVerificationMark } from "./publisher"
|
||||
|
||||
export interface SnRealm {
|
||||
id: string
|
||||
slug: string
|
||||
name: string
|
||||
description?: string
|
||||
isCommunity: boolean
|
||||
isPublic: boolean
|
||||
picture?: SnCloudFile
|
||||
background?: SnCloudFile
|
||||
verification?: SnVerificationMark
|
||||
accountId: string
|
||||
resourceIdentifier: string
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
deletedAt?: Date
|
||||
}
|
||||
15
docker-compose.yml
Normal file
15
docker-compose.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
services:
|
||||
app:
|
||||
# This will build the Dockerfile in the current directory.
|
||||
# Alternatively, you can specify the image from a registry.
|
||||
# Replace 'your-github-username' with your actual GitHub username or organization.
|
||||
image: ghcr.io/solsynth/floating-island:latest
|
||||
build: .
|
||||
# This maps the .env file from your project root into the container.
|
||||
env_file:
|
||||
- .env
|
||||
# This maps port 3000 on your host to port 3000 in the container.
|
||||
ports:
|
||||
- "3000:3000"
|
||||
# This ensures the container restarts automatically unless it's stopped manually.
|
||||
restart: unless-stopped
|
||||
Reference in New Issue
Block a user