fixed ssr badly
This commit is contained in:
@@ -52,10 +52,6 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script async setup lang="ts">
|
||||
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { useGlobalStore } from '~/stores/store';
|
||||
import { io } from 'socket.io-client'
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
:to="'/channel/@me/' + dm.id">
|
||||
<div
|
||||
class="mx-2 my-4 hover:bg-[hsl(223,calc(1*6.9%),25.8%)] px-2 py-2 w-[calc(240px-1rem)] max-h-10 h-10 overflow-ellipsis rounded-md transition-colors">
|
||||
{{ (dm.name).split('-').filter((e: string) => e !== user.id)[0] }}
|
||||
{{ (dm.name).split('-').find((e: string) => e !== user.id) }}
|
||||
</div>
|
||||
</nuxt-link>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="flex h-screen max-h-screen text-white">
|
||||
<div v-if="user.id" class="flex h-screen max-h-screen text-white">
|
||||
<Nav :user="user"/>
|
||||
<Sidebar :server="activeServer"
|
||||
:user="user" />
|
||||
@@ -10,7 +10,9 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Nav, Sidebar } from '~/.nuxt/components'
|
||||
import { useGlobalStore } from '~/stores/store'
|
||||
import { IUser } from '~/types'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -24,7 +26,7 @@ export default {
|
||||
const userStore = useGlobalStore()
|
||||
const sessionToken = useCookie('sessionToken')
|
||||
if (userStore.user.id === undefined && sessionToken.value) {
|
||||
const user = await $fetch('/api/getCurrentUser')
|
||||
const user: IUser = await $fetch('/api/getCurrentUser')
|
||||
|
||||
if (!user) return;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// https://v3.nuxtjs.org/api/configuration/nuxt.config
|
||||
|
||||
export default {
|
||||
ssr: false,
|
||||
ssr: true,
|
||||
app: {
|
||||
head: {
|
||||
meta: [
|
||||
|
||||
@@ -7,7 +7,7 @@ const route = useRoute()
|
||||
|
||||
const server: IChannel = await $fetch(`/api/channels/${route.params.id}`)
|
||||
|
||||
const realServer = useGlobalStore().user.servers.find((e) => e.channels.some((el) => el.id == route.params.id))
|
||||
const realServer = useGlobalStore().user.servers.filter((e) => e.channels.some((el) => el.id == route.params.id))[0]
|
||||
|
||||
if (realServer) {
|
||||
useGlobalStore().addServer(realServer);
|
||||
|
||||
@@ -10,11 +10,11 @@ export const useGlobalStore = defineStore('global', {
|
||||
this.user = user;
|
||||
},
|
||||
addServer(server: IServer) {
|
||||
if (this.user.servers.find((e) => e.id === server.id)) return;
|
||||
if (!this.user.servers || this.user.servers.find((e) => e.id === server.id)) return;
|
||||
this.user.servers.push(server)
|
||||
},
|
||||
addDM(dmChannel: IChannel) {
|
||||
if (this.user.channels.includes(dmChannel)) return;
|
||||
if (!this.user.channels || this.user.channels.find((e) => e.id === dmChannel.id)) return;
|
||||
this.user.channels.push(dmChannel)
|
||||
},
|
||||
setActive(type: string, serverId: string) {
|
||||
@@ -22,6 +22,7 @@ export const useGlobalStore = defineStore('global', {
|
||||
this.activeServer = {}
|
||||
return;
|
||||
}
|
||||
if (!this.user.channels || !this.user.servers) return;
|
||||
|
||||
type = (type === 'dm') ? 'channels' : 'servers'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user