Add I18N into the confirm quit option & you can now view articles from clicking on the "View article" button (but for now you can not view dynamic articles & also chnaged the path from /_assets/ to /n3a_assets/ & Made the title as the navbar thing

This commit is contained in:
吳元皓 2025-05-29 15:32:10 +08:00
parent 10158a390c
commit 937f8ad531
6 changed files with 87 additions and 46 deletions

View File

@ -18,9 +18,17 @@ async function CheckKidUnfriendlyContent(title: string, words: any[]) {
}
}
const emit = defineEmits(["close", "min", "restore"]);
const emit = defineEmits([
"openArticles",
"openNewsSourcePage",
"windowopener",
]);
const staticid = computed(() => props.staticid);
const openNewWindow = (itemId: string) => {
emit("windowopener", "aboutNewsOrg");
};
const contentArray = ref([]);
const errorr = ref(false);
const switchTabs = ref(false);
@ -163,11 +171,13 @@ const useArgFindRel = (title) => {
return similarities.sort((a, b) => b.similarity - a.similarity).slice(0, 3);
};
const openNews = (url: string) => {
console.log(url);
const openNews = (url: string, titleName: string) => {
emit("openArticles", url, titleName);
};
const openPublisher = (text: string) => {};
const openPublisher = (text: string) => {
emit("openNewsSourcePage", text);
};
</script>
<template>
<div class="justify-center align-center text-center">
@ -247,7 +257,7 @@ const openPublisher = (text: string) => {};
<Tooltip>
<TooltipTrigger>
<button
@click="openNews(item.url.hash)"
@click="openNews(item.url.hash, item.title)"
class="flex flex-row p-1 bg-sky-300/50 hover:bg-sky-400/50 shadow-lg backdrop-blur-sm rounded transition-all duration-200"
>
<ScanEyeIcon class="w-6 h-6 p-1" /><span>觀看文章</span>
@ -262,22 +272,24 @@ const openPublisher = (text: string) => {};
<div>
<div>
<h3 class="text-lg">類似文章</h3>
<div v-if="useArgFindRel(item.title).length > 0" class="space-y-2">
<div
v-if="useArgFindRel(item.title).length > 0"
class="space-y-2"
>
<div
v-for="similar in useArgFindRel(item.title)"
:key="similar.item.id"
class="p-2 bg-gray-100 rounded text-sm cursor-pointer hover:bg-gray-200"
@click="openNews(similar.item.url.hash)"
@click="openNews(similar.item.url.hash, item.title)"
>
<div class="font-medium">{{ similar.title }}</div>
<div class="text-gray-500 text-xs">
相似度: {{ (similar.similarity * 100).toFixed(1) }}% | {{ similar.item.publisher }}
相似度: {{ (similar.similarity * 100).toFixed(1) }}% |
{{ similar.item.publisher }}
</div>
</div>
</div>
<div v-else class="text-gray-500 text-sm">
找不到類似文章
</div>
<div v-else class="text-gray-500 text-sm">找不到類似文章</div>
</div>
<!--<div v-for="item in findRel(item.title)">
{{ item }}

View File

@ -74,7 +74,8 @@
"starred": "Starred",
"terminal": "Terminal",
"aboutNewsOrg": "About this news organization",
"newsview": "News View"
"newsview": "News View",
"areyousure": "Are you sure?",
},
"tools": {
"title": "Tools",

View File

@ -74,7 +74,8 @@
"starred": "收藏",
"terminal": "終端機",
"aboutNewsOrg": "關於這個新聞來源",
"newsview": "新聞"
"newsview": "新聞",
"areyousure": "你確定?"
},
"tools": {
"title": "工具",

View File

@ -22,8 +22,10 @@ export default defineNuxtConfig({
cors: true,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS",
"Access-Control-Allow-Headers": "Content-Type, Authorization, X-Requested-With",
"Access-Control-Allow-Methods":
"GET,HEAD,PUT,PATCH,POST,DELETE,OPTIONS",
"Access-Control-Allow-Headers":
"Content-Type, Authorization, X-Requested-With",
},
},
"/api/cached/**": { swr: 3600 },
@ -58,7 +60,7 @@ export default defineNuxtConfig({
},
app: {
buildAssetsDir: "/_assets/",
buildAssetsDir: "/_n3a_assets/",
head: {
title: "",
htmlAttrs: {

View File

@ -227,7 +227,7 @@ onMounted(() => {
const openWindow = (windowName?: string) => {
if (windowName === "leave") {
if (confirm("Are you sure?")) {
if (confirm(t("app.areyousure"))) {
router.push(localePath("/home"));
} else {
return;
@ -239,7 +239,9 @@ const openWindow = (windowName?: string) => {
};
const unMinWindow = (windowName?: string) => {
hiddenWindows.value = hiddenWindows.value.filter(window => window.name !== windowName);
hiddenWindows.value = hiddenWindows.value.filter(
(window) => window.name !== windowName,
);
console.log(windowName);
};
@ -261,7 +263,7 @@ onMounted(async () => {
}
});
const findAndOpenWindow = (windowName: string) => {
const findAndOpenWindow = (windowName: string, windowTitle?: string) => {
const app = associAppWindow.find((app) => app.name === windowName);
// Prevent dual logins
@ -290,7 +292,7 @@ const findAndOpenWindow = (windowName: string) => {
absoluteId: abosluteId,
component: windowComponent,
name: windowName,
title: app.title,
title: windowTitle || app.title,
width: app.width || "600px",
height: app.height || "400px",
black: app.black || false,
@ -299,13 +301,13 @@ const findAndOpenWindow = (windowName: string) => {
// Add to navbar
const windowNameVal2 =
globalWindowVal.value.get(windowName).windowCount === 1
? windowName
: windowName +
? app.title
: app.title +
"(" +
globalWindowVal.value.get(windowName).windowCount +
")";
currentNavBar.value.push({
name: windowNameVal2,
name: windowTitle || windowNameVal2,
icon: "anything",
action: "idk",
flash: true,
@ -348,8 +350,12 @@ const openNewWindowViaApp = (windowId: string) => {
};
const toggleMinWindow = (windowUUId: string) => {
const windowInfo = currentNavBar.value.find(item => item.windowAssociated === windowUUId);
const activeWindow = activeWindows.value.find(window => window.absoluteId === windowUUId);
const windowInfo = currentNavBar.value.find(
(item) => item.windowAssociated === windowUUId,
);
const activeWindow = activeWindows.value.find(
(window) => window.absoluteId === windowUUId,
);
// Add logic to store hidden windows.
if (windowInfo && activeWindow) {
hiddenWindows.value.push({
@ -362,10 +368,11 @@ const toggleMinWindow = (windowUUId: string) => {
height: activeWindow.height,
black: activeWindow.black || false,
lastpositionw: "",
lastpositionh: ""
lastpositionh: "",
});
//activeWindows.value = activeWindows.value.filter(window => window.absoluteId !== windowUUId);
}
console.log(hiddenWindows.value);
};
// Title
@ -420,14 +427,31 @@ watchEffect((cleanupFn) => {
cleanupFn(() => clearTimeout(timmmer));
});
const openArticles = async (slug: string) => {
openArticlesArray.value.push({
id: openArticlesId.value,
slug: slug,
});
openArticlesId.value += 1;
const openArticles = async (slug: string, titleName: string) => {
openingAppViaAnApp.value = true;
passedValues.value = slug;
const titleNameFinal = titleName + "&nbsp;" + t("app.newsview");
findAndOpenWindow("newsView", titleName);
setTimeout(() => {
openingAppViaAnApp.value = false;
passedValues.value = null;
}, 1000);
};
const openNewsSourcePage = async (slug: string, titleName: string) => {
openingAppViaAnApp.value = true;
passedValues.value = slug;
const titleNameFinal = titleName + "&nbsp;" + t("app.aboutNewsOrg");
findAndOpenWindow("aboutNewsOrg", titleNameFinal);
setTimeout(() => {
openingAppViaAnApp.value = false;
passedValues.value = null;
}, 1000);
};
// Not used?
const getStaticArticleId = () => {
storeStaticArticleId.value += 1;
return storeStaticArticleId.value;
@ -550,6 +574,7 @@ const getStaticArticleId = () => {
@windowopener="openNewWindowViaApp($event)"
@loadValue=""
@openArticles="openArticles"
@openNewsSourcePage="openNewsSourcePage"
:staticid="getStaticArticleId"
:values="passedValues"
/>