forked from WinmezzZ/react-antd-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Winme
committed
Jan 6, 2020
1 parent
45f7681
commit d9d7b85
Showing
47 changed files
with
818 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,31 @@ | ||
const { | ||
override, | ||
addLessLoader, | ||
addWebpackAlias, | ||
useEslintRc, | ||
fixBabelImports | ||
} = require('customize-cra') | ||
var path = require('path') | ||
var AntdDayjsWebpackPlugin = require('antd-dayjs-webpack-plugin') | ||
const { override, addLessLoader, addWebpackAlias, useEslintRc, fixBabelImports } = require('customize-cra') | ||
const path = require('path') | ||
const darkTheme = require('@ant-design/dark-theme').default | ||
|
||
const rewiredSourceMap = () => config => { | ||
config.devtool = | ||
config.mode === 'development' ? 'cheap-module-source-map' : false | ||
return config | ||
} | ||
const resolve = dir => path.join(__dirname, '.', dir) | ||
|
||
const rewiredDayJs = () => config => { | ||
config.plugins = [...config.plugins, new AntdDayjsWebpackPlugin()] | ||
const rewiredSourceMap = () => config => { | ||
config.devtool = config.mode === 'development' ? 'cheap-module-source-map' : false | ||
return config | ||
} | ||
|
||
module.exports = override( | ||
useEslintRc(), | ||
addLessLoader({ | ||
javascriptEnabled: true, | ||
modifyVars: { '@primary-color': '#1DA57A' } | ||
modifyVars: { | ||
...darkTheme, | ||
'@primary-color': '#13c2c2', | ||
'@dark-color': '#141414' | ||
} | ||
}), | ||
addWebpackAlias({ | ||
'~': path.resolve(__dirname, '..', 'src') | ||
'~': resolve('src') | ||
}), | ||
fixBabelImports('import', { | ||
libraryName: 'antd', | ||
libraryDirectory: 'es', | ||
style: true | ||
}), | ||
rewiredSourceMap(), | ||
rewiredDayJs() | ||
rewiredSourceMap() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import App from './App'; | ||
import React from 'react' | ||
import { render } from '@testing-library/react' | ||
import App from './App' | ||
|
||
test('renders learn react link', () => { | ||
const { getByText } = render(<App />); | ||
const linkElement = getByText(/learn react/i); | ||
expect(linkElement).toBeInTheDocument(); | ||
}); | ||
const { getByText } = render(<App />) | ||
const linkElement = getByText(/learn react/i) | ||
expect(linkElement).toBeInTheDocument() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Action } from 'redux' | ||
|
||
/** 用户设备 */ | ||
enum DeviceList { | ||
/** 手机 */ | ||
MOBILE = 'MOBILE', | ||
/** 电脑 */ | ||
DESKTOP = 'DESKTOP' | ||
} | ||
|
||
export type Device = keyof typeof DeviceList | ||
|
||
export interface GlobalState { | ||
/** 用户设备 */ | ||
device: Device | ||
|
||
/** 菜单栏收起状态 */ | ||
collapsed: boolean | ||
} | ||
|
||
const SETGLOBALITEM = 'SETGLOBALITEM' | ||
|
||
type SETGLOBALITEM = typeof SETGLOBALITEM | ||
|
||
interface SetGloabalItem extends Action<SETGLOBALITEM> { | ||
payload: Partial<GlobalState> | ||
} | ||
|
||
export const setGloabalItem = (payload: Partial<GlobalState>): SetGloabalItem => ({ | ||
type: 'SETGLOBALITEM', | ||
payload | ||
}) | ||
|
||
export type GlobalActions = SetGloabalItem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { request } from './request' | ||
import { MenuList } from '../interface/layout/menu.interface' | ||
|
||
/** 获取菜单列表接口 */ | ||
export const getMenuList = () => request<MenuList>('get', '/user/menu') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import axios from 'axios' | ||
import { message as $message } from 'antd' | ||
|
||
axios.defaults.timeout = 6000 | ||
|
||
axios.interceptors.request.use( | ||
config => { | ||
return config | ||
}, | ||
error => { | ||
Promise.reject(error) | ||
} | ||
) | ||
|
||
axios.interceptors.response.use( | ||
config => { | ||
if (config?.data?.message) { | ||
// $message.success(config.data.message) | ||
} | ||
return config?.data | ||
}, | ||
error => { | ||
const errorMessage = '系统异常' | ||
|
||
$message.error(errorMessage) | ||
return { | ||
code: -1, | ||
message: errorMessage, | ||
result: null | ||
} | ||
} | ||
) | ||
|
||
export type Response<T = any> = { | ||
status: boolean | ||
message: string | ||
result: T | ||
} | ||
|
||
type Method = 'get' | 'post' | ||
|
||
export type MyResponse<T = any> = Promise<Response<T>> | ||
|
||
/** | ||
* | ||
* @param method - request methods | ||
* @param url - request url | ||
* @param data - request data or params | ||
*/ | ||
export const request = <T = any>(method: Method, url: string, data?: any): MyResponse<T> => { | ||
// const prefix = '/api' | ||
const prefix = '' | ||
url = prefix + url | ||
if (method === 'post') { | ||
return axios.post(url, data) | ||
} else { | ||
return axios.get(url, { | ||
params: data | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { request } from './request' | ||
import { LoginResult, LoginParams } from '../interface/user/login' | ||
|
||
/** 登录接口 */ | ||
export const apiLogin = (data: LoginParams) => request<LoginResult>('get', '/user/login') |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { useEffect } from 'react' | ||
|
||
type Callback = () => Promise<any> | ||
|
||
type Deps = readonly any[] | ||
|
||
/** | ||
* | ||
* @param callback callback | ||
* @param deps dependences | ||
*/ | ||
export default function useAsyncEffect(callback: Callback, deps: Deps = []) { | ||
useEffect(() => { | ||
callback().catch(e => console.log('useAsyncEffect error:', e)) | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, deps) | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.