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"
|
"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",
|
||||||
|
@ -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";
|
||||||
|
@ -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: any;
|
||||||
|
edited: any;
|
||||||
|
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;
|
||||||
@ -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) {
|
||||||
|
@ -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
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,6 +144,7 @@
|
|||||||
alt=""
|
alt=""
|
||||||
src="{url}/avatar/{selected ? selected : 'nobody'}.jpg"
|
src="{url}/avatar/{selected ? selected : 'nobody'}.jpg"
|
||||||
/>
|
/>
|
||||||
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||||
<ul
|
<ul
|
||||||
bind:this={ul}
|
bind:this={ul}
|
||||||
on:click={select_by_click}
|
on:click={select_by_click}
|
||||||
|
@ -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/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user