This commit is contained in:
2026-05-23 19:54:03 +09:00
parent c3383b778b
commit 1fd95616a5
46 changed files with 3920 additions and 107 deletions
+27 -28
View File
@@ -1,18 +1,33 @@
import client, { initClient } from "@/lib/client";
import type ApiMap from "lynqchat-js/1.0.0-alpha.0/map";
import { ref } from "vue";
/*
[TODO]
キャッシュの類を全部account.tsに詰め込むのをやめる
*/
await initClient();
export let serverInfo = ref<ApiMap["server-info"]["response"]>(await client.value.request("server-info"));
export let account = ref<ApiMap["me"]["response"]>(await client.value.request("me"));
export let channels = ref<Extract<ApiMap["channel/list"]["response"], { channels: any }>["channels"]>([]);
export let lastLoadedChannel = ref<string>();
let communitys = ref<Extract<ApiMap["community/list"]["response"], { communitys: any }>["communitys"]>([]);
let lastLoadedCommunity = ref<string>();
export const reloadCommunitys = async () => {
lastLoadedCommunity.value = undefined;
const response = await client.value.request("community/list");
if (!response.success)
return;
communitys.value = response.communitys;
if (response.communitys.length > 0) {
lastLoadedCommunity.value = response.communitys[response.communitys.length - 1]?.id;
}
return;
}
await reloadCommunitys();
export {
communitys,
lastLoadedCommunity,
}
export const reloadServerInfo = async () => {
serverInfo.value = await client.value.request("server-info");
@@ -24,34 +39,18 @@ export const reloadAccount = async () => {
account.value = await client.value.request("me");
}
export const initChannels = async () => {
lastLoadedChannel.value = undefined;
const response = await client.value.request("channel/list");
if (!response.success) {
return false;
}
channels.value = response.channels;
if (response.channels.length > 0) {
lastLoadedChannel.value = response.channels[response.channels.length - 1]?.id;
}
return true;
}
export const loadChannels = async () => {
const response = await client.value.request("channel/list", lastLoadedChannel.value ? {
since: lastLoadedChannel.value,
export const loadCommunitys = async () => {
const response = await client.value.request("community/list", lastLoadedCommunity.value ? {
since: lastLoadedCommunity.value,
} : undefined);
if (!response.success) {
return false;
}
channels.value = channels.value.concat(response.channels);
if (response.channels.length > 0) {
lastLoadedChannel.value = response.channels[response.channels.length - 1]?.id;
communitys.value = communitys.value.concat(response.communitys);
if (response.communitys.length > 0) {
lastLoadedCommunity.value = response.communitys[response.communitys.length - 1]?.id;
}
return true;
}
+1 -1
View File
@@ -1,6 +1,6 @@
import Dexie, { type EntityTable } from "dexie";
export interface Settings {
interface Settings {
id: number;
name: string;
value: string;
+4 -2
View File
@@ -1,4 +1,4 @@
import { reactive } from "vue";
import { reactive, ref } from "vue";
const routerStatus = reactive<{
isLoad: boolean;
@@ -6,4 +6,6 @@ const routerStatus = reactive<{
isLoad: false,
});
export default routerStatus;
export default routerStatus;
export const title = ref<string | undefined>(undefined);
+27
View File
@@ -0,0 +1,27 @@
const swSelf = globalThis as unknown as ServiceWorkerGlobalScope;
swSelf.addEventListener("install", (event) => {
event.waitUntil(swSelf.skipWaiting());
});
swSelf.addEventListener("activate", (event) => {
event.waitUntil(swSelf.clients.claim());
});
swSelf.addEventListener("fetch", (event) => {
const request = event.request;
if (request.url.indexOf("http") !== 0)
return;
event.respondWith((async () => {
try {
const res = await fetch(request);
return res;
} catch (err) {
return new Response("Network error", {
status: 504,
});
}
})());
});