Enhanced the user page (prev login page) Added translations into the Tools subpage of the wbesite && added a basic check (that I have not tested yet in my dev enviroment,)

This commit is contained in:
yuanhau 2025-05-27 14:17:45 +08:00
parent eb6c131163
commit a09416db53
8 changed files with 182 additions and 69 deletions

View file

@ -70,6 +70,29 @@ watch(
},
{ immediate: true },
);
const findRel = (title: string) => {
return tf(title);
}
const tf = (text: string) => {
const words = text.toLowerCase().split('');
// const words = text.toLowerCase().match(/[\u4e00-\u9fff]|[a-zA-Z0-9]+/g) || [];
const freqMap = new Map();
for (const word of words) {
if (word.trim()) {
freqMap.set(word, (freqMap.get(word) || 0) + 1);
}
}
const tfVector = <any>{};
for (const [term, count] of freqMap) {
tfVector[term] = count / words.length;
}
return tfVector;
}
</script>
<template>
<div class="justify-center align-center text-center">
@ -127,9 +150,16 @@ watch(
})
}}
</p>
<p :class="getCheckResult(item.title) ? 'hidden' : ''">
<div>
<h3 class="text-lg">類似文章</h3>
<div>{{ findRel(item.title) }}</div>
<!--<div v-for="item in findRel(item.title)">
{{ item }}
</div>-->
</div>
<!--<p :class="getCheckResult(item.title) ? 'hidden' : ''">
{{ item.shortDescription }}
</p>
</p>-->
</div>
</button>
</div>

View file

@ -34,11 +34,10 @@ const submitUserPassword = async () => {
console.log(res);
userAccount.value = "";
} else {
error.value = true;
errormsg.value = res.error
error.value = true;
errormsg.value = res.error;
}
userPassword.value = "";
};
</script>
<template>
@ -49,30 +48,32 @@ const submitUserPassword = async () => {
v-if="!success"
>
<span class="text-2xl text-bold mb-0">Login / Register</span>
<span class="mb-4 text-sm mt-0">We will create a account for you if you don't have one.</span>
<span class="mb-4 text-sm mt-0"
>We will create a account for you if you don't have one.</span
>
<div class="">
<Input
type="text"
placeholder="Username"
class="mb-2 p-2 border rounded"
v-model="userAccount"
required
/>
<Input
type="password"
placeholder="Password"
class="p-2 border rounded mb-2"
v-model="userPassword"
required
/>
<Input
type="text"
placeholder="Username"
class="mb-2 p-2 border rounded"
v-model="userAccount"
required
/>
<Input
type="password"
placeholder="Password"
class="p-2 border rounded mb-2"
v-model="userPassword"
required
/>
</div>
<span v-if="error" class="text-red-600 text-xs m-2">Error: {{ errormsg }}</span>
<span v-if="error" class="text-red-600 text-xs m-2"
>Error: {{ errormsg }}</span
>
<button class="bg-black text-white p-2 rounded transition duration-200">
Log In
</button>
</form>
<div v-else>
Hi! ${user}
</div>
<div v-else>Hi! ${user}</div>
</div>
</template>