fix: password rule

main
jialin 1 year ago
parent 8bb1961a02
commit 84bed59f21

@ -48,7 +48,7 @@ export const WatchEventType = {
};
export const PasswordReg =
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[\W_])(?=\S+$).{6,12}$/;
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*_+])[a-zA-Z\d!@#$%^&*_+]{6,12}$/;
export const uppercaseReg = /(?=.*[A-Z])/;

@ -13,7 +13,7 @@ export default {
'users.form.currentpassword': 'Current Password',
'users.form.updatepassword': 'Modify Password',
'users.form.rule.password':
'Contains uppercase and lowercase letters, numbers, and special characters, 6 to 12 characters in length, no spaces allowed.',
'Contains uppercase and lowercase letters, numbers, and !@#$%^&*_+, 6 to 12 characters in length, no spaces allowed.',
'users.password.uppcase': 'At least one uppercase letter',
'users.password.lowercase': 'At least one lowercase letter',
'users.password.number': 'At least one number',

@ -13,7 +13,7 @@ export default {
'users.form.currentpassword': '当前密码',
'users.form.updatepassword': '修改密码',
'users.form.rule.password':
'包含大小写字母、数字和特殊字符6至12个字符不允许有空格',
'包含大小写字母、数字和!@#$%^&*_+6至12个字符不允许有空格',
'users.password.uppcase': '至少包含一个大写字母',
'users.password.lowercase': '至少包含一个小写字母',
'users.password.number': '至少包含一个数字',

@ -117,7 +117,6 @@ const AddModal: React.FC<AddModalProps> = (props) => {
repo={huggingfaceRepoId}
onSelectFile={handleSelectModelFile}
collapsed={collapsed}
loadingModel={loadingModel}
></HFModelFile>
</ColumnWrapper>
)}

@ -4,11 +4,11 @@ import { useIntl } from '@umijs/max';
import { Col, Empty, Row, Select, Spin, Tag, Tooltip } from 'antd';
import classNames from 'classnames';
import _ from 'lodash';
import { useCallback, useEffect, useRef, useState } from 'react';
import { memo, useCallback, useEffect, useRef, useState } from 'react';
import SimpleBar from 'simplebar-react';
import 'simplebar-react/dist/simplebar.min.css';
import { queryHuggingfaceModelFiles } from '../apis';
import FileType from '../config/file-type';
import { getFileType } from '../config/file-type';
import '../style/hf-model-file.less';
import FileParts from './file-parts';
import TitleWrapper from './title-wrapper';
@ -122,8 +122,8 @@ const HFModelFile: React.FC<HFModelFileProps> = (props) => {
const sortList = _.sortBy(list, (item: any) => {
return sortType === 'size' ? item.size : item.path;
});
setDataSource({ fileList: sortList, loading: false });
handleSelectModelFile(sortList[0]);
setDataSource({ fileList: sortList, loading: false });
} catch (error) {
setDataSource({ fileList: [], loading: false });
handleSelectModelFile({});
@ -139,18 +139,8 @@ const HFModelFile: React.FC<HFModelFileProps> = (props) => {
};
const getModelQuantizationType = useCallback((item: any) => {
let itemPath = item.path;
let path = _.split(itemPath, '/').pop();
if (!_.endsWith(path, '.gguf') && !_.includes(path, '.gguf')) {
path = `${path}.gguf`;
}
const name = _.split(path, '.').slice(0, -1).join('.');
let quanType = _.toUpper(name.split('-').slice(-1)[0]);
if (quanType.indexOf('.') > -1) {
quanType = _.split(quanType, '.').pop();
}
if (FileType[quanType] !== undefined) {
const quanType = getFileType(item.path);
if (quanType) {
return (
<Tag
className="tag-item"
@ -159,7 +149,7 @@ const HFModelFile: React.FC<HFModelFileProps> = (props) => {
marginRight: 0
}}
>
{quanType}
{_.toUpper(quanType)}
</Tag>
);
}
@ -182,6 +172,7 @@ const HFModelFile: React.FC<HFModelFileProps> = (props) => {
axiosTokenRef.current?.abort?.();
};
}, []);
return (
<div>
<TitleWrapper>
@ -205,13 +196,12 @@ const HFModelFile: React.FC<HFModelFileProps> = (props) => {
></Select>
</TitleWrapper>
<SimpleBar
style={{ maxHeight: collapsed ? 'max-content' : 'calc(100vh - 300px)' }}
style={{
height: collapsed ? 'max-content' : 'calc(100vh - 300px)'
}}
>
<div style={{ padding: '16px 24px' }}>
<Spin
spinning={dataSource.loading || loadingModel}
style={{ minHeight: 100 }}
>
<Spin spinning={dataSource.loading} style={{ minHeight: 100 }}>
{dataSource.fileList.length ? (
<Row gutter={[16, 24]}>
{_.map(dataSource.fileList, (item: any) => {
@ -273,7 +263,7 @@ const HFModelFile: React.FC<HFModelFileProps> = (props) => {
</Row>
) : (
!dataSource.loading &&
!loadingModel && (
!dataSource.fileList.length && (
<Empty
imageStyle={{ height: 'auto', marginTop: '20px' }}
image={Empty.PRESENTED_IMAGE_SIMPLE}
@ -290,4 +280,4 @@ const HFModelFile: React.FC<HFModelFileProps> = (props) => {
);
};
export default HFModelFile;
export default memo(HFModelFile);

@ -160,7 +160,10 @@ const ModelCard: React.FC<{
)}
</div>
) : (
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE}></Empty>
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
style={{ marginBlock: 20 }}
></Empty>
)}
</div>
</>

@ -32,4 +32,45 @@ enum FileType {
BF16 = 32
}
export const fileTypeList = [
'F32',
'F16',
'Q4_0',
'Q4_1',
'Q4_1_SOME_F16',
'Q8_0',
'Q5_0',
'Q5_1',
'Q2_K',
'Q3_K_S',
'Q3_K_M',
'Q3_K_L',
'Q4_K_S',
'Q4_K_M',
'Q5_K_S',
'Q5_K_M',
'Q6_K',
'IQ2_XXS',
'IQ2_XS',
'Q2_K_S',
'IQ3_XS',
'IQ3_XXS',
'IQ1_S',
'IQ4_NL',
'IQ3_S',
'IQ3_M',
'IQ2_S',
'IQ2_M',
'IQ4_XS',
'IQ1_M',
'BF16'
];
export const getFileType = (fileName: string): string | null => {
const pattern = new RegExp(`[._-](${fileTypeList.join('|')})\\.gguf$`, 'i');
const match = fileName.match(pattern);
return match ? match[1].toUpperCase() : null;
};
export default FileType;

@ -17,7 +17,7 @@
right: 0;
padding-inline: @padding;
background: var(--color-white-1);
border-bottom: 1px solid var(--ant-color-split);
// border-bottom: 1px solid var(--ant-color-split);
padding-bottom: 16px;
.filter {

Loading…
Cancel
Save