mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-24 00:01:03 +08:00
Clean the code via prettier.
This commit is contained in:
parent
57aa0aba18
commit
eaa9b15b2d
@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useThrottleFn } from '@vueuse/core'
|
import { useThrottleFn } from "@vueuse/core";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
title: string;
|
title: string;
|
||||||
@ -10,44 +10,52 @@ const props = defineProps<{
|
|||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits(["close", "min", "maximize", "restore"]);
|
const emit = defineEmits(["close", "min", "maximize", "restore"]);
|
||||||
const title = computed(() => props.title || 'Draggable Window');
|
const title = computed(() => props.title || "Draggable Window");
|
||||||
|
|
||||||
|
|
||||||
const isDragging = ref(false);
|
const isDragging = ref(false);
|
||||||
const position = ref({
|
const position = ref({
|
||||||
x: props.initialX || Math.floor(window.innerWidth / 2 - (parseInt(props.width || '400') / 2)),
|
x:
|
||||||
y: props.initialY || Math.floor(window.innerHeight / 2 - (parseInt(props.height || '300') / 2)),
|
props.initialX ||
|
||||||
|
Math.floor(window.innerWidth / 2 - parseInt(props.width || "400") / 2),
|
||||||
|
y:
|
||||||
|
props.initialY ||
|
||||||
|
Math.floor(window.innerHeight / 2 - parseInt(props.height || "300") / 2),
|
||||||
});
|
});
|
||||||
|
|
||||||
const offset = ref({ x: 0, y: 0 });
|
const offset = ref({ x: 0, y: 0 });
|
||||||
|
|
||||||
const doDrag = useThrottleFn((e: MouseEvent) => {
|
const doDrag = useThrottleFn((e: MouseEvent) => {
|
||||||
if (!isDragging.value) return
|
if (!isDragging.value) return;
|
||||||
|
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
position.value = {
|
position.value = {
|
||||||
x: Math.max(0, Math.min(window.innerWidth - 400, e.clientX - offset.value.x)),
|
x: Math.max(
|
||||||
y: Math.max(0, Math.min(window.innerHeight - 300, e.clientY - offset.value.y))
|
0,
|
||||||
}
|
Math.min(window.innerWidth - 400, e.clientX - offset.value.x),
|
||||||
})
|
),
|
||||||
|
y: Math.max(
|
||||||
|
0,
|
||||||
|
Math.min(window.innerHeight - 300, e.clientY - offset.value.y),
|
||||||
|
),
|
||||||
|
};
|
||||||
|
});
|
||||||
}, 16);
|
}, 16);
|
||||||
|
|
||||||
|
|
||||||
const startDrag = (e: MouseEvent) => {
|
const startDrag = (e: MouseEvent) => {
|
||||||
isDragging.value = true
|
isDragging.value = true;
|
||||||
offset.value = {
|
offset.value = {
|
||||||
x: e.clientX - position.value.x,
|
x: e.clientX - position.value.x,
|
||||||
y: e.clientY - position.value.y
|
y: e.clientY - position.value.y,
|
||||||
}
|
};
|
||||||
document.addEventListener('mousemove', doDrag)
|
document.addEventListener("mousemove", doDrag);
|
||||||
document.addEventListener('mouseup', stopDrag)
|
document.addEventListener("mouseup", stopDrag);
|
||||||
}
|
};
|
||||||
|
|
||||||
const stopDrag = () => {
|
const stopDrag = () => {
|
||||||
isDragging.value = false
|
isDragging.value = false;
|
||||||
document.removeEventListener('mousemove', doDrag)
|
document.removeEventListener("mousemove", doDrag);
|
||||||
document.removeEventListener('mouseup', stopDrag)
|
document.removeEventListener("mouseup", stopDrag);
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -11,7 +11,6 @@ try {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error:", error);
|
console.error("Error:", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
|
@ -16,7 +16,7 @@ const submitUserPassword = async () => {
|
|||||||
username: userAccount.value,
|
username: userAccount.value,
|
||||||
password: password,
|
password: password,
|
||||||
}),
|
}),
|
||||||
})
|
});
|
||||||
const res = await sendData.json();
|
const res = await sendData.json();
|
||||||
|
|
||||||
if (res.status === "ok") {
|
if (res.status === "ok") {
|
||||||
@ -32,7 +32,7 @@ const submitUserPassword = async () => {
|
|||||||
// Clear the input fields
|
// Clear the input fields
|
||||||
userAccount.value = "";
|
userAccount.value = "";
|
||||||
userPassword.value = "";
|
userPassword.value = "";
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col items-center justify-center h-full">
|
<div class="flex flex-col items-center justify-center h-full">
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const { t, locale } = useI18n();
|
const { t, locale } = useI18n();
|
||||||
|
|
||||||
const { data: source, pending, error } = await useFetch("/api/getData/fetchSources", {
|
const {
|
||||||
|
data: source,
|
||||||
|
pending,
|
||||||
|
error,
|
||||||
|
} = await useFetch("/api/getData/fetchSources", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
@ -135,7 +135,7 @@ onMounted(async () => {
|
|||||||
if (openApp.value) {
|
if (openApp.value) {
|
||||||
openWindow(openApp.value);
|
openWindow(openApp.value);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
const associAppWindow = [
|
const associAppWindow = [
|
||||||
{
|
{
|
||||||
@ -147,23 +147,30 @@ const associAppWindow = [
|
|||||||
height: "500px",
|
height: "500px",
|
||||||
},
|
},
|
||||||
{ name: "login", id: "2", title: t("app.login"), component: LoginWindow },
|
{ name: "login", id: "2", title: t("app.login"), component: LoginWindow },
|
||||||
{ name: "sources", id: "3", title: t("app.sources"), component: SourcesWindow }
|
{
|
||||||
|
name: "sources",
|
||||||
|
id: "3",
|
||||||
|
title: t("app.sources"),
|
||||||
|
component: SourcesWindow,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const currentOpenAppId = ref(0);
|
const currentOpenAppId = ref(0);
|
||||||
|
|
||||||
const findAndOpenWindow = (windowName: string) => {
|
const findAndOpenWindow = (windowName: string) => {
|
||||||
const app = associAppWindow.find((app) => app.name === windowName)
|
const app = associAppWindow.find((app) => app.name === windowName);
|
||||||
|
|
||||||
// Prevent dual logins
|
// Prevent dual logins
|
||||||
if (windowName === "login" &&
|
if (
|
||||||
activeWindows.value.some((window) => window.name === "login")) {
|
windowName === "login" &&
|
||||||
return
|
activeWindows.value.some((window) => window.name === "login")
|
||||||
|
) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app) {
|
if (app) {
|
||||||
// Use shallowRef for better performance with components
|
// Use shallowRef for better performance with components
|
||||||
const windowComponent = shallowRef(app.component)
|
const windowComponent = shallowRef(app.component);
|
||||||
|
|
||||||
activeWindows.value.push({
|
activeWindows.value.push({
|
||||||
id: currentOpenAppId.value,
|
id: currentOpenAppId.value,
|
||||||
@ -172,10 +179,10 @@ const findAndOpenWindow = (windowName: string) => {
|
|||||||
title: app.title,
|
title: app.title,
|
||||||
width: app.width || "400px",
|
width: app.width || "400px",
|
||||||
height: app.height || "300px",
|
height: app.height || "300px",
|
||||||
})
|
});
|
||||||
currentOpenAppId.value++;
|
currentOpenAppId.value++;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const closeWindow = (windowId: string) => {
|
const closeWindow = (windowId: string) => {
|
||||||
activeWindows.value = activeWindows.value.filter(
|
activeWindows.value = activeWindows.value.filter(
|
||||||
@ -196,7 +203,7 @@ const topWindow = (windowId: string) => {
|
|||||||
|
|
||||||
useSeoMeta({
|
useSeoMeta({
|
||||||
title: "hi" + " - Desktop",
|
title: "hi" + " - Desktop",
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
|
@ -78,18 +78,14 @@ onMounted(() => {
|
|||||||
>
|
>
|
||||||
<h1 class="text-8xl mt-0">🤔</h1>
|
<h1 class="text-8xl mt-0">🤔</h1>
|
||||||
<h2 class="text-xl font-bold">Why?</h2>
|
<h2 class="text-xl font-bold">Why?</h2>
|
||||||
<span class="text-sm"
|
<span class="text-sm">{{ t("home.whydes") }}</span>
|
||||||
>{{ t("home.whydes")}}</span
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="flex flex-col justify-center items-center align-middle bg-[#C9C9C9]/60 rounded-xl shadow-lg p-5 m-5 w-[300px] h-[200px]"
|
class="flex flex-col justify-center items-center align-middle bg-[#C9C9C9]/60 rounded-xl shadow-lg p-5 m-5 w-[300px] h-[200px]"
|
||||||
>
|
>
|
||||||
<h1 class="text-8xl mt-0">🧐</h1>
|
<h1 class="text-8xl mt-0">🧐</h1>
|
||||||
<h2 class="text-xl font-bold">How?</h2>
|
<h2 class="text-xl font-bold">How?</h2>
|
||||||
<span class="text-sm"
|
<span class="text-sm">{{ t("home.howdes") }}</span>
|
||||||
>{{ t("home.howdes")}}</span
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
|
@ -19,7 +19,7 @@ export default defineEventHandler(async (event) => {
|
|||||||
title: "Source 2",
|
title: "Source 2",
|
||||||
url: "https://source2.com",
|
url: "https://source2.com",
|
||||||
description: "Description for Source 2",
|
description: "Description for Source 2",
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
|
@ -5,7 +5,7 @@ export default defineEventHandler(async (event) => {
|
|||||||
if (!salt) {
|
if (!salt) {
|
||||||
throw createError({
|
throw createError({
|
||||||
statusCode: 500,
|
statusCode: 500,
|
||||||
message: 'Internal server error'
|
message: "Internal server error",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const body = await readBody(event);
|
const body = await readBody(event);
|
||||||
@ -13,14 +13,14 @@ export default defineEventHandler(async (event) => {
|
|||||||
if (!username || !password) {
|
if (!username || !password) {
|
||||||
throw createError({
|
throw createError({
|
||||||
statusCode: 400,
|
statusCode: 400,
|
||||||
message: 'Username and password are required'
|
message: "Username and password are required",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const USERNAME_PATTERN = /^[a-zA-Z0-9_]{3,20}$/;
|
const USERNAME_PATTERN = /^[a-zA-Z0-9_]{3,20}$/;
|
||||||
if (!USERNAME_PATTERN.test(username)) {
|
if (!USERNAME_PATTERN.test(username)) {
|
||||||
throw createError({
|
throw createError({
|
||||||
statusCode: 400,
|
statusCode: 400,
|
||||||
message: 'Invalid username.'
|
message: "Invalid username.",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Server side hashing
|
// Server side hashing
|
||||||
@ -30,7 +30,5 @@ export default defineEventHandler(async (event) => {
|
|||||||
try {
|
try {
|
||||||
console.log(username);
|
console.log(username);
|
||||||
console.log(hashedPassword);
|
console.log(hashedPassword);
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
|
});
|
||||||
}
|
|
||||||
})
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user