mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 15:51:01 +08:00
Update news view to check if the user has faved a news article or not &
the star button finally do something for the two weeks that is there. Also done SOME user auth logic (aka revert bac kthe changes)
This commit is contained in:
parent
846c27293d
commit
5f37fb5049
@ -31,6 +31,7 @@ const isGenerating = ref(false);
|
|||||||
const summaryText = ref("");
|
const summaryText = ref("");
|
||||||
const { locale } = useI18n();
|
const { locale } = useI18n();
|
||||||
const likeart = ref([]);
|
const likeart = ref([]);
|
||||||
|
const staredStatus = ref(false);
|
||||||
// Translating logic
|
// Translating logic
|
||||||
const translateText = ref(false);
|
const translateText = ref(false);
|
||||||
const translatedBefore = ref(false);
|
const translatedBefore = ref(false);
|
||||||
@ -105,6 +106,20 @@ const aiSummary = async () => {
|
|||||||
isGenerating.value = false;
|
isGenerating.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const starArticle = async () => {
|
||||||
|
const req = await fetch(`/user/${slug}/fav`);
|
||||||
|
const res = await req.json();
|
||||||
|
if (req.status === success) {
|
||||||
|
staredStatus.value = req.starred;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
const req = await fetch(`/user/${slug}/star`);
|
||||||
|
const res = await req.json();
|
||||||
|
staredStatus.value = req;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
@ -183,7 +198,12 @@ const aiSummary = async () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button><StarIcon /></button>
|
<button
|
||||||
|
@click="starArticle"
|
||||||
|
:class="'duration-300 transition-all' + {staredStatus && 'fill-blue-500 text-blue-500'"
|
||||||
|
>
|
||||||
|
<StarIcon />
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -7,16 +7,6 @@ const error = ref(false);
|
|||||||
const errorMsg = ref("");
|
const errorMsg = ref("");
|
||||||
const emit = defineEmits(["windowopener", "error", "loadValue"]);
|
const emit = defineEmits(["windowopener", "error", "loadValue"]);
|
||||||
|
|
||||||
/**
|
|
||||||
* return {
|
|
||||||
userAccount: fetchViaSQL[0].username,
|
|
||||||
firstName: fetchViaSQL[0].firstName,
|
|
||||||
requested_action: "CONTINUE",
|
|
||||||
current_spot: "KEEP_LOGIN",
|
|
||||||
email: fetchViaSQL[0].email,
|
|
||||||
avatarURL: fetchViaSQL[0].avatarurl,
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
try {
|
try {
|
||||||
// 喔 我沒有加 await :( 難怪有問題
|
// 喔 我沒有加 await :( 難怪有問題
|
||||||
const { data, error: sendError } = await useFetch(
|
const { data, error: sendError } = await useFetch(
|
||||||
@ -25,7 +15,7 @@ try {
|
|||||||
if (sendError.value) {
|
if (sendError.value) {
|
||||||
error.value = true;
|
error.value = true;
|
||||||
}
|
}
|
||||||
if (data.requested_action === "KEEP_LOGIN") {
|
if (data.requested_action === "CONTINUE") {
|
||||||
if (data.userAccount && data.userAccount.length !== 0) {
|
if (data.userAccount && data.userAccount.length !== 0) {
|
||||||
allowed.value = true;
|
allowed.value = true;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user