mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-24 05:24:23 +00:00
Compare commits
3 commits
846c27293d
...
bf4e695676
Author | SHA1 | Date | |
---|---|---|---|
bf4e695676 | |||
87d5620e34 | |||
5f37fb5049 |
2 changed files with 31 additions and 17 deletions
|
@ -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,21 @@ const aiSummary = async () => {
|
||||||
isGenerating.value = false;
|
isGenerating.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const starArticle = async () => {
|
||||||
|
const buildUrl = `/user/${slug}/fav`;
|
||||||
|
const req = await fetch(buildUrl);
|
||||||
|
const res = await req.json();
|
||||||
|
if (res.status === "success") {
|
||||||
|
staredStatus.value = res.starred;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
const req = await fetch(`/user/${slug}/star`);
|
||||||
|
const res = await req.json();
|
||||||
|
staredStatus.value = res;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
|
@ -173,17 +189,25 @@ const aiSummary = async () => {
|
||||||
<div v-else>{{ summaryText }}</div>
|
<div v-else>{{ summaryText }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col bg-gray-500">
|
<!--<div class="flex flex-col bg-gray-500">
|
||||||
<!--Similar articles-->
|
<!--Similar articles-->
|
||||||
<div class="flex flex-row" v-for="item in likeart">
|
<!--<div class="flex flex-row" v-for="item in likeart">
|
||||||
<img /><!--Image-->
|
<img /><!--Image-->
|
||||||
<div class="flex flex-col">
|
<!--<div class="flex flex-col">
|
||||||
<h2>title</h2>
|
<h2>title</h2>
|
||||||
<span>description</span>
|
<span>description</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>-->
|
||||||
<button><StarIcon /></button>
|
<button
|
||||||
|
@click="starArticle"
|
||||||
|
:class="[
|
||||||
|
'duration-300 transition-all',
|
||||||
|
{ 'fill-blue-500 text-blue-500': staredStatus },
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<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,8 +15,8 @@ try {
|
||||||
if (sendError.value) {
|
if (sendError.value) {
|
||||||
error.value = true;
|
error.value = true;
|
||||||
}
|
}
|
||||||
if (data.requested_action === "KEEP_LOGIN") {
|
if (data.value.requested_action === "CONTINUE") {
|
||||||
if (data.userAccount && data.userAccount.length !== 0) {
|
if (data.value.userAccount && data.value.userAccount.length !== 0) {
|
||||||
allowed.value = true;
|
allowed.value = true;
|
||||||
} else {
|
} else {
|
||||||
allowed.value = false;
|
allowed.value = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue