130.4
parent
131db241a3
commit
dc1711f949
|
@ -1,24 +1,19 @@
|
|||
'use client';
|
||||
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { trim } from 'lodash';
|
||||
import Link from 'next/link';
|
||||
|
||||
import { useState } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
||||
import { z } from 'zod';
|
||||
|
||||
import { fetchApi } from '@/lib/api';
|
||||
import { generateLowerString } from '@/lib/utils';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { trim } from 'lodash';
|
||||
import Link from 'next/link';
|
||||
import { useState } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { MarkdownEditor } from '../markdown/editor';
|
||||
|
||||
import { useAlert } from '../test/alert';
|
||||
import { Button } from '../ui/button';
|
||||
import { Input } from '../ui/input';
|
||||
import { Label } from '../ui/label';
|
||||
|
||||
import { isSlugUniqueForFrontend } from './hook';
|
||||
|
||||
export const CreatePostForm = () => {
|
||||
|
@ -218,11 +213,11 @@ export const CreatePostForm = () => {
|
|||
disabled={form.formState.isSubmitting}
|
||||
className=" tw-mt-4 tw-mx-auto "
|
||||
type="submit"
|
||||
onClick={() => handleSubmit()}
|
||||
onClick={async () => handleSubmit()}
|
||||
>
|
||||
保存
|
||||
</Button>
|
||||
<Button onClick={() => isSlugUniqueForFrontend()('y')}>1111</Button>
|
||||
<Button onClick={async () => isSlugUniqueForFrontend()('y')}>1111</Button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
'use client';
|
||||
|
||||
import type { ToastActionElement, ToastProps } from '@/app/_components/ui/toast';
|
||||
|
||||
// Inspired by react-hot-toast library
|
||||
import * as React from 'react';
|
||||
|
||||
import type { ToastActionElement, ToastProps } from '@/app/_components/ui/toast';
|
||||
|
||||
const TOAST_LIMIT = 1;
|
||||
const TOAST_REMOVE_DELAY = 1000000;
|
||||
|
||||
|
@ -195,4 +195,4 @@ function useToast() {
|
|||
};
|
||||
}
|
||||
|
||||
export { useToast, toast };
|
||||
export { toast, useToast };
|
||||
|
|
|
@ -90,16 +90,16 @@ export function parse(str: string): number {
|
|||
);
|
||||
}
|
||||
const match =
|
||||
/^(?<value>-?(?:\d+)?\.?\d+) *(?<type>milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
||||
/^(?<value>-?(?:\d+(?:\.\d+)?|\.\d+)) *(?<type>milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
||||
str,
|
||||
);
|
||||
// Named capture groups need to be manually typed today.
|
||||
// https://github.com/microsoft/TypeScript/issues/32098
|
||||
const groups = match?.groups as { value: string; type?: string } | undefined;
|
||||
if (!groups) {
|
||||
return NaN;
|
||||
return Number.NaN;
|
||||
}
|
||||
const n = parseFloat(groups.value);
|
||||
const n = Number.parseFloat(groups.value);
|
||||
const type = (groups.type || 'ms').toLowerCase() as Lowercase<Unit>;
|
||||
switch (type) {
|
||||
case 'years':
|
||||
|
@ -157,7 +157,6 @@ export function parseStrict(value: StringValue): number {
|
|||
return parse(value);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default msFn;
|
||||
|
||||
/**
|
||||
|
@ -209,7 +208,7 @@ function fmtLong(ms: number): StringValue {
|
|||
*/
|
||||
export function format(ms: number, options?: Options): string {
|
||||
if (typeof ms !== 'number' || !Number.isFinite(ms)) {
|
||||
throw new Error('Value provided to ms.format() must be of type number.');
|
||||
throw new TypeError('Value provided to ms.format() must be of type number.');
|
||||
}
|
||||
return options?.long ? fmtLong(ms) : fmtShort(ms);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ const FIELD_VALIDATION = {
|
|||
SPECIAL_CHAR: (value: string) => /[-._!"`'#%&,:;<>=@{}~$()*+/?[\]^|]+/.test(value),
|
||||
LOWERCASE: (value: string) => /[a-z]/.test(value),
|
||||
UPPERCASE: (value: string) => /[A-Z]/.test(value),
|
||||
NUMBER: (value: string) => /.*[0-9].*/.test(value),
|
||||
NUMBER: (value: string) => /.*\d.*/.test(value),
|
||||
},
|
||||
MSG: {
|
||||
MIN_LEN: `密码长度必须 ${MIN_LENGTH} 字符以上`,
|
||||
|
|
Loading…
Reference in New Issue