diff --git a/.husky/commit-msg b/.husky/commit-msg index 910bffbf..c40e30d3 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -6,5 +6,5 @@ export GIT_PARAMS=$* # Run lint before the commit npx --no-install lint-staged - +yarn lint npx --no-install fabric verify-commit diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 2b4571cb..00000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,46 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment include: - -- Using welcoming and inclusive language -- Being respectful of differing viewpoints and experiences -- Gracefully accepting constructive criticism -- Focusing on what is best for the community -- Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -- The use of sexualized language or imagery and unwelcome sexual attention or advances -- Trolling, insulting/derogatory comments, and personal or political attacks -- Public or private harassment -- Publishing others' private information, such as a physical or electronic address, without explicit permission -- Other conduct which could reasonably be considered inappropriate in a professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at afc163@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] - -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ diff --git a/LICENSE b/LICENSE deleted file mode 100644 index b65958eb..00000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019-present Alipay.inc - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/config/config.ts b/config/config.ts index 5fee85a3..071b6d7e 100644 --- a/config/config.ts +++ b/config/config.ts @@ -8,6 +8,12 @@ import routes from './routes'; const { REACT_APP_ENV = 'dev' } = process.env; export default defineConfig({ + // 解决刷新 404 找不到该页面的情况。 + exportStatic: { + // 忽略预渲染失败的错误 + ignorePreRenderError: true, + }, + clickToComponent: {}, /** * @name 开启 hash 模式 * @description 让 build 之后的产物包含 hash 后缀。通常用于增量发布和避免浏览器加载缓存。 @@ -105,7 +111,19 @@ export default defineConfig({ * @description 内置了 babel import 插件 * @doc https://umijs.org/docs/max/antd#antd */ - antd: {}, + antd: { + theme: { + // 主题相关配置 + token: { + borderRadiusLG: 4, + borderRadius: 4, + borderRadiusXS: 4, + colorPrimary: '#13c2c2', + colorBgContainerDisabled: 'rgba(0, 0, 0, 0.02)', + colorTextDisabled: 'rgba(0, 0, 0, 0.45)', + }, + }, + }, /** * @name 网络请求配置 * @description 它基于 axios 和 ahooks 的 useRequest 提供了一套统一的网络请求和错误处理方案。 @@ -141,15 +159,18 @@ export default defineConfig({ schemaPath: join(__dirname, 'oneapi.json'), mock: true, }, - { - requestLibPath: "import { request } from '@umijs/max'", - schemaPath: 'https://gw.alipayobjects.com/os/antfincdn/CA1dOm%2631B/openapi.json', - projectName: 'swagger', - }, ], mfsu: { strategy: 'normal', }, esbuildMinifyIIFE: true, requestRecord: {}, + chainWebpack: (config, { webpack }) => { + config.plugin('define').use(webpack.DefinePlugin, [ + { + 'process.env.FRONTEND_BRANCH_NAME': JSON.stringify(process.env.FRONTEND_BRANCH_NAME), + 'process.env.COMMIT_HASH': JSON.stringify(process.env.VERSION), + }, + ]); + }, }); diff --git a/config/defaultSettings.ts b/config/defaultSettings.ts index 0c721492..13bad97f 100644 --- a/config/defaultSettings.ts +++ b/config/defaultSettings.ts @@ -19,7 +19,16 @@ const defaultSettings: ProLayoutProps & { pwa: true, logo: '/images/logo.png', iconfontUrl: '', - token: {}, + token: { + sider: { + colorTextMenuSelected: '#13c2c2', + colorTextMenuActive: '#13c2c2', + colorTextMenuItemHover: '#13c2c2', + }, + header: { + colorTextRightActionsItem: 'rgba(0, 0, 0, 0.88)', + }, + }, }; export default defaultSettings; diff --git a/src/app.tsx b/src/app.tsx index fd2588d4..2ca8ec8b 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -10,6 +10,18 @@ import { errorConfig } from './requestErrorConfig'; const isDev = process.env.NODE_ENV === 'development'; const loginPath = '/user/login'; +// 主题css 变量注入 + +import { ConfigProvider } from 'antd'; +ConfigProvider.config({ + theme: { + primaryColor: '#13c2c2', + successColor: '#52c41a', + errorColor: '#ff4d4f', + warningColor: '#faad14', + }, +}); + /** * @see https://umijs.org/zh-CN/plugins/plugin-initial-state * */ @@ -65,6 +77,7 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => { history.push(loginPath); } }, + links: isDev ? [ diff --git a/src/global.less b/src/global.less index 5e3e63dd..70e5a098 100644 --- a/src/global.less +++ b/src/global.less @@ -64,3 +64,9 @@ select:-webkit-autofill { -webkit-box-shadow: 0 0 0px 1000px transparent inset !important; transition: background-color 50000s ease-in-out 0s; } + +// 主题重置 + +a { + color: var(--ant-primary-color) !important; +} diff --git a/src/manifest.json b/src/manifest.json deleted file mode 100644 index 8a27d855..00000000 --- a/src/manifest.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "Evil Pro Cli", - "short_name": "Evil Pro Cli", - "display": "standalone", - "start_url": "./?utm_source=homescreen", - "theme_color": "#002140", - "background_color": "#001529", - "icons": [ - { - "src": "icons/icon-192x192.png", - "sizes": "192x192" - }, - { - "src": "icons/icon-128x128.png", - "sizes": "128x128" - }, - { - "src": "icons/icon-512x512.png", - "sizes": "512x512" - } - ] -} diff --git a/src/services/swagger/index.ts b/src/services/swagger/index.ts deleted file mode 100644 index 83cf97ca..00000000 --- a/src/services/swagger/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -// @ts-ignore -/* eslint-disable */ -// API 更新时间: -// API 唯一标识: -import * as pet from './pet'; -import * as store from './store'; -import * as user from './user'; -export default { - pet, - store, - user, -}; diff --git a/src/services/swagger/pet.ts b/src/services/swagger/pet.ts deleted file mode 100644 index 7bba3bd9..00000000 --- a/src/services/swagger/pet.ts +++ /dev/null @@ -1,159 +0,0 @@ -// @ts-ignore -/* eslint-disable */ -import { request } from '@umijs/max'; - -/** Update an existing pet PUT /pet */ -export async function updatePet(body: API.Pet, options?: { [key: string]: any }) { - return request('/pet', { - method: 'PUT', - headers: { - 'Content-Type': 'application/json', - }, - data: body, - ...(options || {}), - }); -} - -/** Add a new pet to the store POST /pet */ -export async function addPet(body: API.Pet, options?: { [key: string]: any }) { - return request('/pet', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - data: body, - ...(options || {}), - }); -} - -/** Find pet by ID Returns a single pet GET /pet/${param0} */ -export async function getPetById( - // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) - params: API.getPetByIdParams, - options?: { [key: string]: any }, -) { - const { petId: param0, ...queryParams } = params; - return request(`/pet/${param0}`, { - method: 'GET', - params: { ...queryParams }, - ...(options || {}), - }); -} - -/** Updates a pet in the store with form data POST /pet/${param0} */ -export async function updatePetWithForm( - // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) - params: API.updatePetWithFormParams, - body: { name?: string; status?: string }, - options?: { [key: string]: any }, -) { - const { petId: param0, ...queryParams } = params; - const formData = new FormData(); - - Object.keys(body).forEach((ele) => { - const item = (body as any)[ele]; - - if (item !== undefined && item !== null) { - if (typeof item === 'object' && !(item instanceof File)) { - if (item instanceof Array) { - item.forEach((f) => formData.append(ele, f || '')); - } else { - formData.append(ele, JSON.stringify(item)); - } - } else { - formData.append(ele, item); - } - } - }); - - return request(`/pet/${param0}`, { - method: 'POST', - params: { ...queryParams }, - data: formData, - ...(options || {}), - }); -} - -/** Deletes a pet DELETE /pet/${param0} */ -export async function deletePet( - // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) - params: API.deletePetParams, - options?: { [key: string]: any }, -) { - const { petId: param0, ...queryParams } = params; - return request(`/pet/${param0}`, { - method: 'DELETE', - params: { ...queryParams }, - ...(options || {}), - }); -} - -/** uploads an image POST /pet/${param0}/uploadImage */ -export async function uploadFile( - // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) - params: API.uploadFileParams, - body: { additionalMetadata?: string; file?: string }, - file?: File, - options?: { [key: string]: any }, -) { - const { petId: param0, ...queryParams } = params; - const formData = new FormData(); - - if (file) { - formData.append('file', file); - } - - Object.keys(body).forEach((ele) => { - const item = (body as any)[ele]; - - if (item !== undefined && item !== null) { - if (typeof item === 'object' && !(item instanceof File)) { - if (item instanceof Array) { - item.forEach((f) => formData.append(ele, f || '')); - } else { - formData.append(ele, JSON.stringify(item)); - } - } else { - formData.append(ele, item); - } - } - }); - - return request(`/pet/${param0}/uploadImage`, { - method: 'POST', - params: { ...queryParams }, - data: formData, - requestType: 'form', - ...(options || {}), - }); -} - -/** Finds Pets by status Multiple status values can be provided with comma separated strings GET /pet/findByStatus */ -export async function findPetsByStatus( - // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) - params: API.findPetsByStatusParams, - options?: { [key: string]: any }, -) { - return request('/pet/findByStatus', { - method: 'GET', - params: { - ...params, - }, - ...(options || {}), - }); -} - -/** Finds Pets by tags Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. GET /pet/findByTags */ -export async function findPetsByTags( - // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) - params: API.findPetsByTagsParams, - options?: { [key: string]: any }, -) { - return request('/pet/findByTags', { - method: 'GET', - params: { - ...params, - }, - ...(options || {}), - }); -} diff --git a/src/services/swagger/store.ts b/src/services/swagger/store.ts deleted file mode 100644 index b9c689a6..00000000 --- a/src/services/swagger/store.ts +++ /dev/null @@ -1,48 +0,0 @@ -// @ts-ignore -/* eslint-disable */ -import { request } from '@umijs/max'; - -/** Returns pet inventories by status Returns a map of status codes to quantities GET /store/inventory */ -export async function getInventory(options?: { [key: string]: any }) { - return request>('/store/inventory', { - method: 'GET', - ...(options || {}), - }); -} - -/** Place an order for a pet POST /store/order */ -export async function placeOrder(body: API.Order, options?: { [key: string]: any }) { - return request('/store/order', { - method: 'POST', - data: body, - ...(options || {}), - }); -} - -/** Find purchase order by ID For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions GET /store/order/${param0} */ -export async function getOrderById( - // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) - params: API.getOrderByIdParams, - options?: { [key: string]: any }, -) { - const { orderId: param0, ...queryParams } = params; - return request(`/store/order/${param0}`, { - method: 'GET', - params: { ...queryParams }, - ...(options || {}), - }); -} - -/** Delete purchase order by ID For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors DELETE /store/order/${param0} */ -export async function deleteOrder( - // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) - params: API.deleteOrderParams, - options?: { [key: string]: any }, -) { - const { orderId: param0, ...queryParams } = params; - return request(`/store/order/${param0}`, { - method: 'DELETE', - params: { ...queryParams }, - ...(options || {}), - }); -} diff --git a/src/services/swagger/typings.d.ts b/src/services/swagger/typings.d.ts deleted file mode 100644 index 2038f3ae..00000000 --- a/src/services/swagger/typings.d.ts +++ /dev/null @@ -1,111 +0,0 @@ -declare namespace API { - type ApiResponse = { - code?: number; - type?: string; - message?: string; - }; - - type Category = { - id?: string; - name?: string; - }; - - type deleteOrderParams = { - /** ID of the order that needs to be deleted */ - orderId: string; - }; - - type deletePetParams = { - /** Pet id to delete */ - petId: string; - }; - - type deleteUserParams = { - /** The name that needs to be deleted */ - username: string; - }; - - type findPetsByStatusParams = { - /** Status values that need to be considered for filter */ - status: ('available' | 'pending' | 'sold')[]; - }; - - type findPetsByTagsParams = { - /** Tags to filter by */ - tags: string[]; - }; - - type getOrderByIdParams = { - /** ID of pet that needs to be fetched */ - orderId: string; - }; - - type getPetByIdParams = { - /** ID of pet to return */ - petId: string; - }; - - type getUserByNameParams = { - /** The name that needs to be fetched. Use user1 for testing. */ - username: string; - }; - - type loginUserParams = { - /** The user name for login */ - username: string; - /** The password for login in clear text */ - password: string; - }; - - type Order = { - id?: string; - petId?: string; - quantity?: number; - shipDate?: string; - /** Order Status */ - status?: 'placed' | 'approved' | 'delivered'; - complete?: boolean; - }; - - type Pet = { - id?: string; - category?: Category; - name: string; - photoUrls: string[]; - tags?: Tag[]; - /** pet status in the store */ - status?: 'available' | 'pending' | 'sold'; - }; - - type Tag = { - id?: string; - name?: string; - }; - - type updatePetWithFormParams = { - /** ID of pet that needs to be updated */ - petId: string; - }; - - type updateUserParams = { - /** name that need to be updated */ - username: string; - }; - - type uploadFileParams = { - /** ID of pet to update */ - petId: string; - }; - - type User = { - id?: string; - username?: string; - firstName?: string; - lastName?: string; - email?: string; - password?: string; - phone?: string; - /** User Status */ - userStatus?: number; - }; -} diff --git a/src/services/swagger/user.ts b/src/services/swagger/user.ts deleted file mode 100644 index ec458e73..00000000 --- a/src/services/swagger/user.ts +++ /dev/null @@ -1,100 +0,0 @@ -// @ts-ignore -/* eslint-disable */ -import { request } from '@umijs/max'; - -/** Create user This can only be done by the logged in user. 返回值: successful operation POST /user */ -export async function createUser(body: API.User, options?: { [key: string]: any }) { - return request('/user', { - method: 'POST', - data: body, - ...(options || {}), - }); -} - -/** Get user by user name GET /user/${param0} */ -export async function getUserByName( - // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) - params: API.getUserByNameParams, - options?: { [key: string]: any }, -) { - const { username: param0, ...queryParams } = params; - return request(`/user/${param0}`, { - method: 'GET', - params: { ...queryParams }, - ...(options || {}), - }); -} - -/** Updated user This can only be done by the logged in user. PUT /user/${param0} */ -export async function updateUser( - // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) - params: API.updateUserParams, - body: API.User, - options?: { [key: string]: any }, -) { - const { username: param0, ...queryParams } = params; - return request(`/user/${param0}`, { - method: 'PUT', - params: { ...queryParams }, - data: body, - ...(options || {}), - }); -} - -/** Delete user This can only be done by the logged in user. DELETE /user/${param0} */ -export async function deleteUser( - // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) - params: API.deleteUserParams, - options?: { [key: string]: any }, -) { - const { username: param0, ...queryParams } = params; - return request(`/user/${param0}`, { - method: 'DELETE', - params: { ...queryParams }, - ...(options || {}), - }); -} - -/** Creates list of users with given input array 返回值: successful operation POST /user/createWithArray */ -export async function createUsersWithArrayInput( - body: API.User[], - options?: { [key: string]: any }, -) { - return request('/user/createWithArray', { - method: 'POST', - data: body, - ...(options || {}), - }); -} - -/** Creates list of users with given input array 返回值: successful operation POST /user/createWithList */ -export async function createUsersWithListInput(body: API.User[], options?: { [key: string]: any }) { - return request('/user/createWithList', { - method: 'POST', - data: body, - ...(options || {}), - }); -} - -/** Logs user into the system GET /user/login */ -export async function loginUser( - // 叠加生成的Param类型 (非body参数swagger默认没有生成对象) - params: API.loginUserParams, - options?: { [key: string]: any }, -) { - return request('/user/login', { - method: 'GET', - params: { - ...params, - }, - ...(options || {}), - }); -} - -/** Logs out current logged in user session 返回值: successful operation GET /user/logout */ -export async function logoutUser(options?: { [key: string]: any }) { - return request('/user/logout', { - method: 'GET', - ...(options || {}), - }); -} diff --git a/src/utils/index.ts b/src/utils/index.ts index 346969fe..bed6bdff 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -172,32 +172,9 @@ export const queryOptions = async ( return []; }; -/** - * 计算税率 - * @param amount 金额 - * @param rate 税率 - * @returns taxInclusiveAmount 税额 taxExclusiveAmount 不含税金额 - */ -export const calcTaxRate = (amount: number, rate: number) => { - if (!amount || !rate) - return { - taxInclusiveAmount: 0, - taxExclusiveAmount: 0, - }; - - // 不含税金额 = 含税金额 / (1+税率) - const taxExclusiveAmount = Number((amount / (1 + rate / 100)).toFixed(2)); - - return { - // 税额 = 不含税金额 * 税率 - taxInclusiveAmount: (taxExclusiveAmount * (rate / 100)).toFixed(2), - taxExclusiveAmount, - }; -}; - // 查询审批分页 export const queryApprovalTable = async ( - params: AntTableParams1 & { [k: string]: any }, + params: { [k: string]: any }, api?: (data: U) => Promise>, ) => { if (!api)