Add a login wall on a few windows, but still no auth / login logic

yet...
This commit is contained in:
yuanhau 2025-05-17 20:50:23 +08:00
parent 020251c706
commit a89fbd4fd7
9 changed files with 157 additions and 64 deletions

View file

@ -76,7 +76,7 @@ const stopDrag = () => {
>
<div
@mousedown="startDrag"
class="bg-gray-700 p-2 cursor-move flex justify-between items-center flex-shrink-0 text-white"
class="bg-gray-700 p-2 cursor-move flex justify-between items-center flex-shrink-0 text-white z-[50]"
>
<h3 class="font-semibold text-white">{{ title }}</h3>
<div class="flex flex-row gap-1">

View file

@ -15,6 +15,7 @@ import {
BotMessageSquare,
} from "lucide-vue-next";
import { Input } from "~/components/ui/input";
import blurPageBeforeLogin from "~/components/blurPageBeforeLogin.vue";
import { v4 as uuidv4 } from "uuid";
const { t } = useI18n();
const cookie = useCookie("lastChatId");
@ -53,6 +54,12 @@ onMounted(async () => {
} else {
const { data: checkUserChatId } = await useFetch(
"/api/ai/chat/actions/findUserChatId",
{
method: "POST",
body: {
userid: "393393",
},
},
);
cookieChatId.value = checkUserChatId.value;
}
@ -66,75 +73,80 @@ onMounted(async () => {
});
</script>
<template>
<div class="flex flex-col h-full">
<div>
<div
class="justify-center align-center text-center flex flex-col sticky top-0 pt-2 min-h-0 border rounded-2xl gray-500/80 backdrop-blur-sm"
>
<div class="flex flex-row justify-between p-2">
<h2 class="text-xl ml-4 text-bold">Chat Name</h2>
<div class="flex flex-row justify-center align-center text-center">
<div
class="flex flex-row justify-center align-center text-center gap-2"
>
<button
class="p-2 rounded-xl hover:bg-gray-300 transition-all duration-400"
<blurPageBeforeLogin>
<div class="flex flex-col h-full">
<div>
<div
class="justify-center align-center text-center flex flex-col sticky top-0 pt-2 min-h-0 border rounded-2xl gray-500/80 backdrop-blur-sm"
>
<div class="flex flex-row justify-between p-2">
<h2 class="text-xl ml-4 text-bold">Chat Name</h2>
<div class="flex flex-row justify-center align-center text-center">
<div
class="flex flex-row justify-center align-center text-center gap-2"
>
<History class="h-4 w-4" />
</button>
<button
class="p-2 rounded-xl hover:bg-gray-300 transition-all duration-400"
>
<Plus class="h-4 w-4" />
</button>
<button
class="p-2 rounded-xl hover:bg-gray-300 transition-all duration-400"
>
<History class="h-4 w-4" />
</button>
<button
class="p-2 rounded-xl hover:bg-gray-300 transition-all duration-400"
>
<Plus class="h-4 w-4" />
</button>
</div>
</div>
</div>
</div>
</div>
<div ref="chatContainerRef" class="flex-1 overflow-y-auto p-4 space-y-4">
<div
v-for="message in messages"
class="max-w-[80%] rounded-lg p-3 bg-gray-300/70 rounded-xl"
ref="chatContainerRef"
class="flex-1 overflow-y-auto p-4 space-y-4"
>
<div v-if="message.user" class="flex flex-row gap-2">
<User class="w-5 h-5" />{{ message.message }}
</div>
<div v-else class="flex flex-row gap-2">
<BotMessageSquare class="w-5 h-5" />{{ message.message }}
<div
v-for="message in messages"
class="max-w-[80%] rounded-lg p-3 bg-gray-300/70 rounded-xl"
>
<div v-if="message.user" class="flex flex-row gap-2">
<User class="w-5 h-5" />{{ message.message }}
</div>
<div v-else class="flex flex-row gap-2">
<BotMessageSquare class="w-5 h-5" />{{ message.message }}
</div>
</div>
</div>
</div>
<div
class="space-x-2 sticky bottom-0 border-t p-2 min-h-0 border rounded-xl gray-500/80 backdrop-blur-sm"
>
<div class="text-black w-full flex flex-row">
<Input
class="flex-1 rounded-xl"
placeholder="Type a message..."
v-model="inputMessage"
@keyup.enter="sendChatData($event)"
/>
<button
class="pl-2 pr-2 mr-1 ml-1 bg-black text-white rounded-full hover:bg-gray-700 hover:translate-y-[-4px] transition-all duration-300 disabled:cursor-not-allowed disabled:hover:translate-y-0 disabled:bg-color-500"
:disabled="!inputMessage?.trim()"
@click="sendChatData()"
v-if="!aiGenerating"
>
<Send class="w-5 h-5" />
</button>
<button
class="pl-2 pr-2 mr-1 ml-1 bg-black text-white rounded-full hover:bg-gray-700 hover:translate-y-[-4px] transition-all duration-300 disabled:cursor-not-allowed disabled:hover:translate-y-0 disabled:bg-color-500"
:disabled="!inputMessage?.trim()"
@click="sendChatData()"
v-else
>
<Square class="w-5 h-5" />
</button>
</div>
<span class="text-xs text-center justify-center align-center w-full"
>Note: AI might create imbalanced views.</span
<div
class="space-x-2 sticky bottom-0 border-t p-2 min-h-0 border rounded-xl gray-500/80 backdrop-blur-sm"
>
<div class="text-black w-full flex flex-row">
<Input
class="flex-1 rounded-xl"
placeholder="Type a message..."
v-model="inputMessage"
@keyup.enter="sendChatData($event)"
:disabled="aiGenerating"
/>
<button
class="pl-2 pr-2 mr-1 ml-1 bg-black text-white rounded-full hover:bg-gray-700 hover:translate-y-[-4px] transition-all duration-300 disabled:cursor-not-allowed disabled:hover:translate-y-0 disabled:bg-color-500"
:disabled="!inputMessage?.trim()"
@click="sendChatData()"
v-if="!aiGenerating"
>
<Send class="w-5 h-5" />
</button>
<button
class="pl-2 pr-2 mr-1 ml-1 bg-black text-white rounded-full hover:bg-gray-700 hover:translate-y-[-4px] transition-all duration-300 disabled:cursor-not-allowed disabled:hover:translate-y-0 disabled:bg-color-500"
@click=""
v-else
>
<Square class="w-5 h-5" />
</button>
</div>
<span class="text-xs text-center justify-center align-center w-full"
>Note: AI might create imbalanced views.</span
>
</div>
</div>
</div>
</div>
</blurPageBeforeLogin>
</template>

View file

@ -0,0 +1,9 @@
<script setup lang="ts">
import BlurPageBeforeLogin from "~/components/blurPageBeforeLogin.vue";
const { t } = useI18n();
</script>
<template>
<BlurPageBeforeLogin>
<div></div>
</BlurPageBeforeLogin>
</template>

View file

@ -0,0 +1,39 @@
<script setup lang="ts">
// Imports
const { t } = useI18n();
// Values
const allowed = ref(false);
const error = ref(false);
const errorMsg = ref("");
onMounted(async () => {
// Check Cookie
try {
const { data, error: sendError } = useFetch("/api/user/checkcookie");
if (sendError) {
error.value = true;
}
if (false) {
allowed.value = true;
} else {
allowed.value = false;
}
} catch (e) {
error.value = true;
errorMsg.value = e.message;
}
});
</script>
<template>
<div
class="flex flex-col bg-gray-200/50 text-black w-full h-full absolute inset-0 justify-center align-middle text-center z-[20] backdrop-blur-sm"
>
<div v-if="!allowed && !error" class="m-2">
{{ t("error") }}
</div>
<div v-if="error" class="m-2">
<span>{{ errorMsg ? errorMsg : t("systemerror") }}</span>
</div>
</div>
<slot></slot>
</template>