mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
bug fixes
This commit is contained in:
10 files changed
+56
-65
No files matched your search
@@ -125,14 +125,19 @@ export interface Field {
|
||||
}
|
||||
|
||||
type Result<T extends string, R extends Record<T, Field>> = {
|
||||
[K in keyof R]: ('text' | 'password' | 'username' | 'domain') extends R[K]['type'] ? string
|
||||
[K in keyof R]: R[K]['type'] extends ('text' | 'password' | 'username' | 'domain') ? string
|
||||
: R[K]['type'] extends 'checkbox' ? boolean
|
||||
: R[K]['type'] extends 'userId' ? number
|
||||
: R[K]['type'] extends 'user' ? any
|
||||
: never;
|
||||
};
|
||||
|
||||
export async function prompt<T extends string, R extends Record<T, Field>>(title: string, fields: R): Promise<Result<T, R>> {
|
||||
interface PromptOptions {
|
||||
cancelByClickingBack: boolean;
|
||||
cancelByEsc: boolean;
|
||||
}
|
||||
|
||||
export async function prompt<T extends string, R extends Record<T, Field>>(title: string, fields: R, options?: PromptOptions): Promise<Result<T, R>> {
|
||||
let valueCache: Result<T, R> = {} as any;
|
||||
const defaultValues = Object.fromEntries(Object.entries(fields)
|
||||
.map(([name, field]: [T, Field]) => {
|
||||
@@ -225,6 +230,8 @@ export async function prompt<T extends string, R extends Record<T, Field>>(title
|
||||
const res = await new Dialog({
|
||||
$body: $(div),
|
||||
$action: [buttonCancel, buttonOk].join('\n'),
|
||||
cancelByClickingBack: options?.cancelByClickingBack ?? false,
|
||||
cancelByEsc: options?.cancelByEsc ?? false,
|
||||
onDispatch(action) {
|
||||
if (action === 'ok') {
|
||||
for (const [name, field] of Object.entries(fields) as [string, Field][]) {
|
||||
|
||||
@@ -2,12 +2,10 @@ import { browserSupportsWebAuthnAutofill, startAuthentication } from '@simpleweb
|
||||
import $ from 'jquery';
|
||||
import responsiveCutoff from 'vj/breakpoints.json';
|
||||
import DomDialog from 'vj/components/dialog/DomDialog';
|
||||
import { InfoDialog } from 'vj/components/dialog/index';
|
||||
import { alert } from 'vj/components/dialog/index';
|
||||
import Notification from 'vj/components/notification';
|
||||
import { AutoloadPage } from 'vj/misc/Page';
|
||||
import {
|
||||
i18n, mediaQuery, request, tpl,
|
||||
} from 'vj/utils';
|
||||
import { i18n, mediaQuery, request } from 'vj/utils';
|
||||
|
||||
const signinDialogPage = new AutoloadPage('signinDialogPage', null, () => {
|
||||
const signInDialog = DomDialog.getOrConstruct($('.dialog--signin'), {
|
||||
@@ -18,7 +16,7 @@ const signinDialogPage = new AutoloadPage('signinDialogPage', null, () => {
|
||||
let authnInitialized = false;
|
||||
|
||||
async function initPasskey() {
|
||||
if (authnInitialized) return;
|
||||
if (authnInitialized || !window.isSecureContext) return;
|
||||
authnInitialized = true;
|
||||
const support = await browserSupportsWebAuthnAutofill();
|
||||
if (!support) return;
|
||||
@@ -79,9 +77,7 @@ const signinDialogPage = new AutoloadPage('signinDialogPage', null, () => {
|
||||
|
||||
$('[data-lostpass]').on('click', (e) => {
|
||||
e.preventDefault();
|
||||
new InfoDialog({
|
||||
$body: tpl.typoMsg(i18n('Relax and try to remember your password.')),
|
||||
}).open();
|
||||
alert(i18n('Relax and try to remember your password.'));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user