mirror of
https://github.com/PaiGramTeam/luoxu-api-pub.git
synced 2024-11-22 07:08:05 +00:00
Merge remote-tracking branch 'origin/pr/4'
This commit is contained in:
commit
19214cd829
1478
package-lock.json
generated
1478
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -9,15 +9,16 @@
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jridgewell/sourcemap-codec": "^1.4.14",
|
||||
"@rollup/plugin-commonjs": "^17.0.0",
|
||||
"@rollup/plugin-node-resolve": "^11.0.0",
|
||||
"@rollup/plugin-terser": "^0.4.0",
|
||||
"@rollup/plugin-typescript": "^8.0.0",
|
||||
"@tsconfig/svelte": "^2.0.1",
|
||||
"rollup": "^2.3.4",
|
||||
"rollup-plugin-css-only": "^3.1.0",
|
||||
"rollup-plugin-livereload": "^2.0.0",
|
||||
"rollup-plugin-svelte": "^7.0.0",
|
||||
"rollup-plugin-terser": "^7.0.0",
|
||||
"svelte": "^3.49.0",
|
||||
"svelte-check": "^2.0.0",
|
||||
"svelte-preprocess": "^4.0.0",
|
||||
|
@ -2,7 +2,7 @@ import svelte from "rollup-plugin-svelte";
|
||||
import commonjs from "@rollup/plugin-commonjs";
|
||||
import resolve from "@rollup/plugin-node-resolve";
|
||||
import livereload from "rollup-plugin-livereload";
|
||||
import { terser } from "rollup-plugin-terser";
|
||||
import terser from "@rollup/plugin-terser";
|
||||
import sveltePreprocess from "svelte-preprocess";
|
||||
import typescript from "@rollup/plugin-typescript";
|
||||
import css from "rollup-plugin-css-only";
|
||||
|
@ -6,11 +6,23 @@
|
||||
|
||||
const LUOXU_URL = "https://lab.lilydjwg.me/luoxu";
|
||||
const islocal = LUOXU_URL.startsWith("http://localhost");
|
||||
let groups = [];
|
||||
let groups: { group_id: string; name: string }[] = [];
|
||||
let group: string;
|
||||
let query: string;
|
||||
let error: string;
|
||||
let result: { messages: string | any[]; has_more: any; groupinfo: any };
|
||||
let result: {
|
||||
messages: {
|
||||
from_name: string;
|
||||
t: any;
|
||||
edited: any;
|
||||
group_id: string;
|
||||
id: string;
|
||||
from_id: string;
|
||||
html: string;
|
||||
}[];
|
||||
has_more: boolean;
|
||||
groupinfo: string[][];
|
||||
};
|
||||
let now = new Date();
|
||||
let loading = false;
|
||||
let need_update_title = false;
|
||||
@ -49,7 +61,7 @@
|
||||
$: {
|
||||
// only update title on hash change (doing a search)
|
||||
if (need_update_title && groups) {
|
||||
let group_name: any;
|
||||
let group_name: string;
|
||||
for (const g of groups) {
|
||||
if (g.group_id === group) {
|
||||
group_name = g.name;
|
||||
|
@ -1,9 +1,17 @@
|
||||
<script lang="ts">
|
||||
import { onMount, getContext } from "svelte";
|
||||
|
||||
export let msg: any;
|
||||
export let groupinfo: any;
|
||||
export let now: any;
|
||||
export let msg: {
|
||||
from_name: string;
|
||||
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, {
|
||||
timeStyle: "full",
|
||||
@ -33,13 +41,16 @@
|
||||
};
|
||||
|
||||
const rtf = new Intl.RelativeTimeFormat();
|
||||
//@ts-ignore
|
||||
const elapsed = d1 - d2; //https://stackoverflow.com/a/4944782/13040423
|
||||
// https://stackoverflow.com/a/60688789
|
||||
const elapsed = d1.valueOf() - d2.valueOf();
|
||||
|
||||
for (const [u, period] of Object.entries(units)) {
|
||||
if (Math.abs(elapsed) > period || u === "second") {
|
||||
//@ts-ignore
|
||||
return rtf.format(Math.round(elapsed / period), u);
|
||||
// https://stackoverflow.com/a/64972112
|
||||
return rtf.format(
|
||||
Math.round(elapsed / period),
|
||||
u as Intl.RelativeTimeFormatUnit
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
<script lang="ts">
|
||||
import { onMount, getContext } from "svelte";
|
||||
|
||||
export let group: any;
|
||||
export let group: string;
|
||||
|
||||
export let selected: any;
|
||||
export let selected_init: any;
|
||||
export let selected: string;
|
||||
export let selected_init: string;
|
||||
let selected_name = "";
|
||||
let selected_idx: number;
|
||||
|
||||
let to: string | number | NodeJS.Timeout;
|
||||
let to: NodeJS.Timeout;
|
||||
let names = [];
|
||||
let url = getContext("LUOXU_URL");
|
||||
let input: HTMLInputElement;
|
||||
@ -61,15 +61,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
function select_by_click(e: any) {
|
||||
let el = e.target;
|
||||
function select_by_click(e: MouseEvent) {
|
||||
let el = e.target as HTMLElement;
|
||||
if (el.tagName === "IMG") {
|
||||
el = el.parentNode;
|
||||
el = el.parentNode as HTMLElement;
|
||||
}
|
||||
if (el.tagName != "LI") {
|
||||
return;
|
||||
}
|
||||
selected_idx = el.dataset.idx | 0;
|
||||
selected_idx = parseInt(el.dataset.idx);
|
||||
select_confirmed();
|
||||
input.focus();
|
||||
should_hide = true;
|
||||
@ -144,6 +144,7 @@
|
||||
alt=""
|
||||
src="{url}/avatar/{selected ? selected : 'nobody'}.jpg"
|
||||
/>
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<ul
|
||||
bind:this={ul}
|
||||
on:click={select_by_click}
|
||||
|
@ -1,6 +1,16 @@
|
||||
{
|
||||
"extends": "@tsconfig/svelte/tsconfig.json",
|
||||
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules/*", "__sapper__/*", "public/*"]
|
||||
"compilerOptions": {
|
||||
"lib": [
|
||||
"ES2020",
|
||||
"DOM"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules/*",
|
||||
"__sapper__/*",
|
||||
"public/*"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user