Remove legacy component & Update validating system using localstorage.

This commit is contained in:
yuanhau 2025-05-30 15:49:59 +08:00
parent b716a0ed5c
commit c5c614c75d
7 changed files with 141 additions and 86 deletions

View file

@ -23,7 +23,6 @@ const emit = defineEmits([
"openNewsSourcePage",
"windowopener",
]);
const staticid = computed(() => props.staticid);
const openNewWindow = (itemId: string) => {
emit("windowopener", "aboutNewsOrg");
@ -285,10 +284,7 @@ const openPublisher = (text: string) => {
<div>
<div>
<h3 class="text-lg">類似文章</h3>
<div
class="space-y-2"
>
<div class="space-y-2">
<div
v-for="similar in useArgFindRel(item.title, item.publisher)"
:key="similar.item.id"
@ -302,8 +298,12 @@ const openPublisher = (text: string) => {
</div>
</div>
</div>
<div v-if="checkIfEmpty(item.title)" class="text-gray-500 text-sm">找不到類似文章</div>
<div
v-if="checkIfEmpty(item.title)"
class="text-gray-500 text-sm"
>
找不到類似文章
</div>
</div>
<!--<div v-for="item in findRel(item.title)">
{{ item }}

View file

@ -1,13 +1,32 @@
<script setup lang="ts">
const logoutAction = () => {
const user = ref();
const userToken = localStorage.getItem("token");
const { t, locale } = useI18n();
onMounted(async () => {
const req = await fetch("/api/user/validateUserToken", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
token: userToken,
lang: locale,
page: "settings",
}),
});
const res = req.json();
user.value = res;
});
}
const logoutAction = () => {};
</script>
<template>
<div>
<div class="bg-gray-400 p-2 m-2 w-full">
<div class="justify-center align-center text-center">
<div class="">Greetings, {{ user }}</div>
<div class="bg-gray-200/70 p-2 m-2 w-full">
<button @click="logoutAction">Logout</button>
</div>
<hr/>
<hr />
<div class="justiy-center align-center text-center">Settings v0.0.1</div>
</div>
</template>

View file

@ -1,6 +1,6 @@
<script setup lang="ts">
// Imports
const { t } = useI18n();
const { t, locale } = useI18n();
// Values
const allowed = ref(false);
const error = ref(false);
@ -9,7 +9,21 @@ const emit = defineEmits(["windowopener", "error", "loadValue"]);
try {
// await :(
const { data, error: sendError } = await useFetch("/api/user/checkcookie");
const token = localStorage.getItem("token");
const { data, error: sendError } = await useFetch(
"/api/user/validateUserToken",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
token: token,
lang: locale,
page: "a_window_application_using_blurPageBeforeLogin_component",
}),
},
);
if (sendError.value) {
error.value = true;
}