Skip to content

Commit

Permalink
Captcha 新增 actionConfig 配置参数,用于设定请求 Header ( Axios )
Browse files Browse the repository at this point in the history
  • Loading branch information
lirongtong committed Aug 30, 2023
1 parent c632349 commit bc8ccd2
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 76 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "makeit-admin-pro",
"version": "2.1.363",
"version": "2.1.364",
"author": {
"url": "https://admin.makeit.vip",
"name": "lirongtong",
Expand Down
13 changes: 11 additions & 2 deletions src/components/captcha/captcha.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ export default defineComponent({
afterInit()
props.initAction()
} else {
$request[props.initMethod.toLowerCase()](props.initAction, props.initParams)
$request[props.initMethod.toLowerCase()](
props.initAction,
props.initParams,
props.actionConfig
)
.then((res: any) => {
afterInit()
if (res?.data?.key && !params.verifyParams.key)
Expand All @@ -99,7 +103,11 @@ export default defineComponent({
params.status.ready = false
params.status.scanning = true
if (props.checkAction) {
$request[props.checkMethod.toLowerCase()](props.checkAction, props.checkParams)
$request[props.checkMethod.toLowerCase()](
props.checkAction,
props.checkParams,
props.actionConfig
)
.then((res: any) => {
if (res.data.pass) params.pass = true
else initCaptchaModal()
Expand Down Expand Up @@ -224,6 +232,7 @@ export default defineComponent({
verifyMethod={props.verifyMethod}
verifyParams={params.verifyParams}
verifyAction={props.verifyAction}
actionConfig={props.actionConfig}
onModalClose={closeCaptchaModal}
image={props.image}
/>
Expand Down
23 changes: 3 additions & 20 deletions src/components/captcha/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,15 @@ import { defineComponent, ref, reactive, onMounted, onBeforeUnmount, Transition
import { Tooltip } from 'ant-design-vue'
import { CloseCircleOutlined, ReloadOutlined, QuestionCircleOutlined } from '@ant-design/icons-vue'
import { useI18n } from 'vue-i18n'
import PropTypes from '../_utils/props-types'
import { getPrefixCls } from '../_utils/props-tools'
import { $tools } from '../../utils/tools'
import { $g, MI_POWERED, MI_AVATAR } from '../../utils/global'
import { $request } from '../../utils/request'
import { background } from '../../utils/images'
import { captchaModalProps } from './props'

const TARGET = 'https://admin.makeit.vip/components/captcha'

export const captchaModalProps = () => ({
prefixCls: PropTypes.string,
show: PropTypes.bool.def(false),
image: PropTypes.string,
position: PropTypes.object,
mask: PropTypes.bool.def(true),
maskClosable: PropTypes.bool.def(true),
themeColor: PropTypes.string,
bgColor: PropTypes.string,
boxShadow: PropTypes.bool.def(true),
boxShadowColor: PropTypes.string,
boxShadowBlur: PropTypes.number.def(6),
maxTries: PropTypes.number.def(5),
verifyParams: PropTypes.object.def({}),
verifyMethod: PropTypes.string.def('post'),
verifyAction: PropTypes.string
})

export default defineComponent({
name: 'MiCaptchaModal',
inheritAttrs: false,
Expand Down Expand Up @@ -427,7 +409,8 @@ export default defineComponent({
if (props.verifyAction) {
await $request[props.verifyMethod.toLowerCase()](
props.verifyAction,
props.verifyParams
props.verifyParams,
props.actionConfig
)
.then((res: any) => {
if (res.ret.code === 200) {
Expand Down
108 changes: 55 additions & 53 deletions src/components/captcha/props.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,55 @@
import PropTypes from '../_utils/props-types'
import { tuple } from '../_utils/props-tools'
import { $g } from '../../utils/global'

export const captchaProps = () => ({
prefixCls: PropTypes.string,
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).def(320),
height: PropTypes.number,
radius: PropTypes.number.def(48),
themeColor: PropTypes.string,
bgColor: PropTypes.string,
borderColor: PropTypes.string,
textColor: PropTypes.string,
boxShadow: PropTypes.bool.def(true),
boxShadowColor: PropTypes.string,
boxShadowBlur: PropTypes.number.def(4),
modalBgColor: PropTypes.string,
modalBoxShadow: PropTypes.bool.def(true),
modalBoxShadowColor: PropTypes.string,
modalBoxShadowBlur: PropTypes.number,
image: PropTypes.string,
logo: PropTypes.string,
mask: PropTypes.bool.def(true),
maskClosable: PropTypes.bool.def(true),
maxTries: PropTypes.number.def(5),
initParams: PropTypes.object.def({}),
initAction: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
initMethod: PropTypes.oneOf(tuple(...$g.methods)).def('get'),
verifyParams: PropTypes.object.def({}),
verifyAction: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
verifyMethod: PropTypes.oneOf(tuple(...$g.methods)).def('post'),
checkParams: PropTypes.object.def({}),
checkAction: PropTypes.string,
checkMethod: PropTypes.oneOf(tuple(...$g.methods)).def('post')
})

export const captchaModalProps = () => ({
prefixCls: PropTypes.string,
show: PropTypes.bool.def(false),
image: PropTypes.string,
position: PropTypes.object,
mask: PropTypes.bool.def(true),
maskClosable: PropTypes.bool.def(true),
themeColor: PropTypes.string,
bgColor: PropTypes.string,
boxShadow: PropTypes.bool.def(true),
boxShadowColor: PropTypes.string,
boxShadowBlur: PropTypes.number.def(6),
maxTries: PropTypes.number.def(5),
verifyParams: PropTypes.object.def({}),
verifyMethod: PropTypes.string.def('post'),
verifyAction: PropTypes.string
})
import PropTypes from '../_utils/props-types'
import { tuple } from '../_utils/props-tools'
import { $g } from '../../utils/global'

export const captchaProps = () => ({
prefixCls: PropTypes.string,
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).def(320),
height: PropTypes.number,
radius: PropTypes.number.def(48),
themeColor: PropTypes.string,
bgColor: PropTypes.string,
borderColor: PropTypes.string,
textColor: PropTypes.string,
boxShadow: PropTypes.bool.def(true),
boxShadowColor: PropTypes.string,
boxShadowBlur: PropTypes.number.def(4),
modalBgColor: PropTypes.string,
modalBoxShadow: PropTypes.bool.def(true),
modalBoxShadowColor: PropTypes.string,
modalBoxShadowBlur: PropTypes.number,
image: PropTypes.string,
logo: PropTypes.string,
mask: PropTypes.bool.def(true),
maskClosable: PropTypes.bool.def(true),
maxTries: PropTypes.number.def(5),
initParams: PropTypes.object.def({}),
initAction: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
initMethod: PropTypes.oneOf(tuple(...$g.methods)).def('get'),
verifyParams: PropTypes.object.def({}),
verifyAction: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
verifyMethod: PropTypes.oneOf(tuple(...$g.methods)).def('post'),
checkParams: PropTypes.object.def({}),
checkAction: PropTypes.string,
checkMethod: PropTypes.oneOf(tuple(...$g.methods)).def('post'),
actionConfig: PropTypes.object.def({})
})

export const captchaModalProps = () => ({
prefixCls: PropTypes.string,
show: PropTypes.bool.def(false),
image: PropTypes.string,
position: PropTypes.object,
mask: PropTypes.bool.def(true),
maskClosable: PropTypes.bool.def(true),
themeColor: PropTypes.string,
bgColor: PropTypes.string,
boxShadow: PropTypes.bool.def(true),
boxShadowColor: PropTypes.string,
boxShadowBlur: PropTypes.number.def(6),
maxTries: PropTypes.number.def(5),
verifyParams: PropTypes.object.def({}),
verifyMethod: PropTypes.string.def('post'),
verifyAction: PropTypes.string,
actionConfig: PropTypes.object.def({})
})

0 comments on commit bc8ccd2

Please sign in to comment.