update deps

This commit is contained in:
AsukaMinato 2023-02-08 13:32:03 +00:00
parent f7baace046
commit c8f909ed69
7 changed files with 191 additions and 1399 deletions

1478
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,15 +9,16 @@
"check": "svelte-check --tsconfig ./tsconfig.json" "check": "svelte-check --tsconfig ./tsconfig.json"
}, },
"devDependencies": { "devDependencies": {
"@jridgewell/sourcemap-codec": "^1.4.14",
"@rollup/plugin-commonjs": "^17.0.0", "@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.0", "@rollup/plugin-node-resolve": "^11.0.0",
"@rollup/plugin-terser": "^0.4.0",
"@rollup/plugin-typescript": "^8.0.0", "@rollup/plugin-typescript": "^8.0.0",
"@tsconfig/svelte": "^2.0.1", "@tsconfig/svelte": "^2.0.1",
"rollup": "^2.3.4", "rollup": "^2.3.4",
"rollup-plugin-css-only": "^3.1.0", "rollup-plugin-css-only": "^3.1.0",
"rollup-plugin-livereload": "^2.0.0", "rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-svelte": "^7.0.0", "rollup-plugin-svelte": "^7.0.0",
"rollup-plugin-terser": "^7.0.0",
"svelte": "^3.49.0", "svelte": "^3.49.0",
"svelte-check": "^2.0.0", "svelte-check": "^2.0.0",
"svelte-preprocess": "^4.0.0", "svelte-preprocess": "^4.0.0",

View File

@ -2,7 +2,7 @@ import svelte from "rollup-plugin-svelte";
import commonjs from "@rollup/plugin-commonjs"; import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve"; import resolve from "@rollup/plugin-node-resolve";
import livereload from "rollup-plugin-livereload"; import livereload from "rollup-plugin-livereload";
import { terser } from "rollup-plugin-terser"; import terser from "@rollup/plugin-terser";
import sveltePreprocess from "svelte-preprocess"; import sveltePreprocess from "svelte-preprocess";
import typescript from "@rollup/plugin-typescript"; import typescript from "@rollup/plugin-typescript";
import css from "rollup-plugin-css-only"; import css from "rollup-plugin-css-only";

View File

@ -6,11 +6,23 @@
const LUOXU_URL = "https://lab.lilydjwg.me/luoxu"; const LUOXU_URL = "https://lab.lilydjwg.me/luoxu";
const islocal = LUOXU_URL.startsWith("http://localhost"); const islocal = LUOXU_URL.startsWith("http://localhost");
let groups = []; let groups: { group_id: string; name: string }[] = [];
let group: string; let group: string;
let query: string; let query: string;
let error: string; let error: string;
let result: { messages: string | any[]; has_more: any; groupinfo: any }; let result: {
messages: {
from_name: string;
t;
edited;
group_id: string;
id: string;
from_id: string;
html: string;
}[];
has_more: boolean;
groupinfo: string[][];
};
let now = new Date(); let now = new Date();
let loading = false; let loading = false;
let need_update_title = false; let need_update_title = false;
@ -49,7 +61,7 @@
$: { $: {
// only update title on hash change (doing a search) // only update title on hash change (doing a search)
if (need_update_title && groups) { if (need_update_title && groups) {
let group_name: any; let group_name: string;
for (const g of groups) { for (const g of groups) {
if (g.group_id === group) { if (g.group_id === group) {
group_name = g.name; group_name = g.name;
@ -91,7 +103,7 @@
} }
} }
async function do_search(more?: any) { async function do_search(more?: HTMLMouseEventHandler<HTMLButtonElement>) {
abort.abort(); abort.abort();
abort = new AbortController(); abort = new AbortController();
if (!group && !islocal) { if (!group && !islocal) {
@ -133,7 +145,7 @@
now = new Date(); now = new Date();
loading = true; loading = true;
try { try {
const res = await fetch(url, {signal: abort.signal}); const res = await fetch(url, { signal: abort.signal });
const r = await res.json(); const r = await res.json();
loading = false; loading = false;
if (abort.signal.aborted) { if (abort.signal.aborted) {
@ -200,7 +212,7 @@
}} }}
/> />
<Name {group} bind:selected={sender} {selected_init} /> <Name {group} bind:selected={sender} {selected_init} />
<button on:click={() => do_search()}>搜索</button> <button on:click={do_search}>搜索</button>
</div> </div>
{#if result} {#if result}

View File

@ -1,9 +1,17 @@
<script lang="ts"> <script lang="ts">
import { onMount, getContext } from "svelte"; import { onMount, getContext } from "svelte";
export let msg: any; export let msg: {
export let groupinfo: any; from_name: string;
export let now: any; t;
edited;
group_id: string;
id: string;
from_id: string;
html: string;
};
export let groupinfo: string[][];
export let now: Date;
const formatter = new Intl.DateTimeFormat(undefined, { const formatter = new Intl.DateTimeFormat(undefined, {
timeStyle: "full", timeStyle: "full",
@ -33,13 +41,16 @@
}; };
const rtf = new Intl.RelativeTimeFormat(); const rtf = new Intl.RelativeTimeFormat();
//@ts-ignore // https://stackoverflow.com/a/60688789
const elapsed = d1 - d2; //https://stackoverflow.com/a/4944782/13040423 const elapsed = d1.valueOf() - d2.valueOf();
for (const [u, period] of Object.entries(units)) { for (const [u, period] of Object.entries(units)) {
if (Math.abs(elapsed) > period || u === "second") { if (Math.abs(elapsed) > period || u === "second") {
//@ts-ignore // https://stackoverflow.com/a/64972112
return rtf.format(Math.round(elapsed / period), u); return rtf.format(
Math.round(elapsed / period),
u as Intl.RelativeTimeFormatUnit
);
} }
} }
} }

View File

@ -1,14 +1,14 @@
<script lang="ts"> <script lang="ts">
import { onMount, getContext } from "svelte"; import { onMount, getContext } from "svelte";
export let group: any; export let group: string;
export let selected: any; export let selected: string;
export let selected_init: any; export let selected_init: string;
let selected_name = ""; let selected_name = "";
let selected_idx: number; let selected_idx: number;
let to: string | number | NodeJS.Timeout; let to: NodeJS.Timeout;
let names = []; let names = [];
let url = getContext("LUOXU_URL"); let url = getContext("LUOXU_URL");
let input: HTMLInputElement; let input: HTMLInputElement;
@ -61,15 +61,15 @@
} }
} }
function select_by_click(e: any) { function select_by_click(e: MouseEvent) {
let el = e.target; let el = e.target as HTMLElement;
if (el.tagName === "IMG") { if (el.tagName === "IMG") {
el = el.parentNode; el = el.parentNode as HTMLElement;
} }
if (el.tagName != "LI") { if (el.tagName != "LI") {
return; return;
} }
selected_idx = el.dataset.idx | 0; selected_idx = parseInt(el.dataset.idx);
select_confirmed(); select_confirmed();
input.focus(); input.focus();
should_hide = true; should_hide = true;
@ -144,17 +144,17 @@
alt="" alt=""
src="{url}/avatar/{selected ? selected : 'nobody'}.jpg" src="{url}/avatar/{selected ? selected : 'nobody'}.jpg"
/> />
<ul <ul bind:this={ul}>
bind:this={ul} <button
on:click={select_by_click} on:click={select_by_click}
on:mousedown|preventDefault={() => {}} on:mousedown|preventDefault={() => {}}
class:hidden={names.length === 0 || should_hide} class:hidden={names.length === 0 || should_hide}
> >{#each names as name, i (name)}
{#each names as name, i (name)} <li data-idx={i} class:selected={i === selected_idx} title={name[1]}>
<li data-idx={i} class:selected={i === selected_idx} title={name[1]}> <img src="{url}/avatar/{name[0]}.jpg" alt="avatar" />{name[1]}
<img src="{url}/avatar/{name[0]}.jpg" alt="avatar" />{name[1]} </li>
</li> {/each}
{/each} </button>
</ul> </ul>
</div> </div>

View File

@ -1,6 +1,16 @@
{ {
"extends": "@tsconfig/svelte/tsconfig.json", "compilerOptions": {
"lib": [
"include": ["src/**/*"], "ES2020",
"exclude": ["node_modules/*", "__sapper__/*", "public/*"] "DOM"
} ]
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules/*",
"__sapper__/*",
"public/*"
]
}