feat:
This commit is contained in:
6
src/utils/common.ts
Normal file
6
src/utils/common.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export const isValidPhone = (phone: string, callback: (msg?: string) => void) => {
|
||||
if (!/^1\d{10}$/.test(phone)) {
|
||||
callback('手机号格式不正确');
|
||||
}
|
||||
callback();
|
||||
};
|
||||
22
src/utils/login.ts
Normal file
22
src/utils/login.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { history } from '@umijs/max';
|
||||
|
||||
import { LOGIN_PATH } from '@/constants/global';
|
||||
|
||||
let _token = '';
|
||||
|
||||
export const setToken = (token: string) => {
|
||||
_token = token;
|
||||
};
|
||||
|
||||
export const getToken = () => {
|
||||
return _token;
|
||||
};
|
||||
|
||||
export const clearToken = () => {
|
||||
return (_token = '');
|
||||
};
|
||||
|
||||
export const gotoLogin = () => {
|
||||
console.trace('gotoLogin');
|
||||
history.push(LOGIN_PATH);
|
||||
};
|
||||
Reference in New Issue
Block a user