diff --git a/package.json b/package.json index cc1297f..9263213 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "pinia": "^2.0.34", "print-js": "^1.6.0", "qrcodejs2-fixes": "^0.0.2", + "qs": "^6.11.1", "screenfull": "^6.0.2", "sortablejs": "^1.15.0", "spark-md5": "^3.0.2", @@ -36,13 +37,12 @@ "vue": "^3.2.47", "vue-clipboard3": "^2.0.0", "vue-codemirror": "^6.1.1", + "vue-demi": "^0.13.11", "vue-grid-layout": "^3.0.0-beta1", "vue-i18n": "^9.2.2", "vue-router": "^4.1.6", "vue-simple-uploader": "^1.0.0-beta.5", - "vue-ueditor-wrap": "^3.0.8", - "qs": "^6.11.1", - "vue-demi": "^0.13.11" + "vue-ueditor-wrap": "^3.0.8" }, "devDependencies": { "@types/node": "^18.15.11", diff --git a/src/api/login/index.ts b/src/api/login/index.ts index b22986f..c8695de 100644 --- a/src/api/login/index.ts +++ b/src/api/login/index.ts @@ -22,6 +22,27 @@ export function captcha(){ }) } +/** + * 获取验证码V2 + */ +export function captchaV2(){ + return request({ + url:"/api/v1/pub/captcha/v2", + method:"get" + }) +} + +/** + * 检查v2验证码 + */ +export function checkCaptchaV2(data: { dots: string, key: string }){ + return request({ + url:"/api/v1/pub/captcha/v2Check", + data:data, + method:"post" + }) +} + /** * 退出登录 */ diff --git a/src/components/goCaptcha/GoCaptcha.vue b/src/components/goCaptcha/GoCaptcha.vue new file mode 100644 index 0000000..f2c7986 --- /dev/null +++ b/src/components/goCaptcha/GoCaptcha.vue @@ -0,0 +1,378 @@ + + + + + diff --git a/src/components/goCaptcha/GoCaptchaBtn.vue b/src/components/goCaptcha/GoCaptchaBtn.vue new file mode 100644 index 0000000..9781f01 --- /dev/null +++ b/src/components/goCaptcha/GoCaptchaBtn.vue @@ -0,0 +1,334 @@ + + + + + diff --git a/src/components/goCaptcha/GoCaptchaBtnDialog.vue b/src/components/goCaptcha/GoCaptchaBtnDialog.vue new file mode 100644 index 0000000..09d4418 --- /dev/null +++ b/src/components/goCaptcha/GoCaptchaBtnDialog.vue @@ -0,0 +1,331 @@ + + + + + diff --git a/src/utils/gfast.ts b/src/utils/gfast.ts index b3b0636..bddef32 100644 --- a/src/utils/gfast.ts +++ b/src/utils/gfast.ts @@ -33,28 +33,50 @@ export function handleTree(data:any[], id:string, parentId:string, children:stri id = id || 'id' parentId = parentId || 'parentId' children = children || 'children' - rootId = rootId || 0 + let rootIds:any = [] + if(typeof rootId === 'boolean' && rootId){ + //自动获取rootId + let idSet:any = {} + data.map((item:any)=>{ + idSet[item[id]] = true + }) + data.map((item:any)=>{ + if(!idSet[item[parentId]]){ + rootIds.push(item[parentId]) + } + }) + }else{ + rootId = rootId || 0 + rootIds = [rootId] + } + rootIds = [...new Set(rootIds)] + let treeData:any = [] //对源数据深度克隆 const cloneData = JSON.parse(JSON.stringify(data)) - //循环所有项 - const treeData = cloneData.filter((father:any) => { - let branchArr = cloneData.filter((child:any) => { - //返回每一项的子级数组 - return father[id] === child[parentId] + rootIds.map((rItem:any)=>{ + //循环所有项 + const td = cloneData.filter((father:any) => { + let branchArr = cloneData.filter((child:any) => { + //返回每一项的子级数组 + return father[id] === child[parentId] + }); + branchArr.length > 0 ? father[children] = branchArr : ''; + //返回第一层 + switch (typeof father[parentId]){ + case 'string': + if(father[parentId]===''&&rItem===0){ + return true + } + return father[parentId]===rItem.toString(); + case 'number': + return father[parentId] === rItem; + } + return false; }); - branchArr.length > 0 ? father[children] = branchArr : ''; - //返回第一层 - switch (typeof father[parentId]){ - case 'string': - if(father[parentId]===''&&rootId===0){ - return true - } - return father[parentId]===rootId.toString(); - case 'number': - return father[parentId] === rootId; + if(td.length>0){ + treeData = [...treeData,...td] } - return false; - }); + }) return treeData != '' ? treeData : data; } diff --git a/src/utils/request.ts b/src/utils/request.ts index 93ab224..341b786 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -10,7 +10,7 @@ const service: AxiosInstance = axios.create({ headers: { 'Content-Type': 'application/json' }, paramsSerializer: { serialize(params) { - return qs.stringify(params, { allowDots: true }); + return qs.stringify(params, { allowDots: true,arrayFormat: 'brackets' }); }, }, }); diff --git a/src/views/login/component/account.vue b/src/views/login/component/account.vue index 447d358..1033f82 100644 --- a/src/views/login/component/account.vue +++ b/src/views/login/component/account.vue @@ -33,7 +33,16 @@ - + + + + - - + + @@ -91,9 +100,11 @@ import { initBackEndControlRoutes } from '/@/router/backEnd'; import { Session } from '/@/utils/storage'; import { formatAxis } from '/@/utils/formatTime'; import { NextLoading } from '/@/utils/loading'; -import {login,captcha} from "/@/api/login"; +import {login} from "/@/api/login"; +import GoCaptchaBtn from "/@/components/goCaptcha/GoCaptchaBtn.vue"; export default defineComponent({ name: 'loginAccount', + components: {GoCaptchaBtn}, setup() { const { t } = useI18n(); const {proxy} = getCurrentInstance(); @@ -102,6 +113,7 @@ export default defineComponent({ const route = useRoute(); const router = useRouter(); const loginForm = ref(null) + const checkCaptchaResult = ref('default') const state = reactive({ isShowPassword: false, ruleForm: { @@ -117,7 +129,7 @@ export default defineComponent({ password: [ { required: true, trigger: "blur", message: "密码不能为空" } ], - verifyCode: [{ required: true, trigger: "blur", message: "验证码不能为空" }] + verifyCode: [{ required: true, trigger: "blur", message: "请先进行人机验证" }] }, loading: { signIn: false, @@ -128,10 +140,11 @@ export default defineComponent({ getCaptcha(); }); const getCaptcha = () => { - captcha().then((res:any)=>{ - state.captchaSrc = res.data.img - state.ruleForm.verifyKey = res.data.key - }) + // 验证码V1版 + // captcha().then((res:any)=>{ + // state.captchaSrc = res.data.img + // state.ruleForm.verifyKey = res.data.key + // }) }; // 时间获取 const currentTime = computed(() => { @@ -173,7 +186,11 @@ export default defineComponent({ } }).catch(()=>{ state.loading.signIn = false; - getCaptcha(); + state.ruleForm.verifyKey = '' + state.ruleForm.verifyCode = '' + checkCaptchaResult.value = 'default' + // 验证码V1版 + //getCaptcha(); }) } }) @@ -200,9 +217,17 @@ export default defineComponent({ // 添加 loading,防止第一次进入界面时出现短暂空白 NextLoading.start(); }; + + const handleVerifyCodeConfirm = (data:{key:string,dots:string})=>{ + state.ruleForm.verifyCode = data.dots + state.ruleForm.verifyKey = data.key + } + return { onSignIn, getCaptcha, + checkCaptchaResult, + handleVerifyCodeConfirm, loginForm, ...toRefs(state), }; diff --git a/src/views/system/role/component/editRole.vue b/src/views/system/role/component/editRole.vue index a24816b..a2bf471 100644 --- a/src/views/system/role/component/editRole.vue +++ b/src/views/system/role/component/editRole.vue @@ -3,6 +3,23 @@ + + + + + + + @@ -72,6 +89,7 @@ interface MenuDataTree { } interface DialogRow { id:number; + pid:number; name: string; status: number; listOrder: number; @@ -96,6 +114,12 @@ interface RoleState { export default defineComponent({ name: 'systemEditRole', + props:{ + roleData:{ + type:Array, + default:()=>[] + } + }, setup(props,{emit}) { const {proxy} = getCurrentInstance() as any; const formRef = ref(null); @@ -105,6 +129,7 @@ export default defineComponent({ isShowDialog: false, formData: { id:0, + pid:0, name: '', status: 1, listOrder: 0, @@ -198,6 +223,7 @@ export default defineComponent({ state.menuNodeAll = false; state.formData = { id:0, + pid:0, name: '', status: 1, listOrder: 0, diff --git a/src/views/system/role/index.vue b/src/views/system/role/index.vue index 9dac0b3..b7edae1 100644 --- a/src/views/system/role/index.vue +++ b/src/views/system/role/index.vue @@ -28,8 +28,10 @@ - - + @@ -54,15 +56,8 @@ - - + @@ -83,6 +78,7 @@ import UserList from '/@/views/system/user/component/userList.vue'; // 定义接口来定义对象的类型 interface TableData { id:number; + pid:number; status: number; listOrder: number; name: string; @@ -151,6 +147,7 @@ export default defineComponent({ list.map((item:TableData)=>{ data.push({ id:item.id, + pid:item.pid, status: item.status, listOrder: item.listOrder, name: item.name, @@ -160,8 +157,7 @@ export default defineComponent({ createdAt: item.createdAt, }); }) - state.tableData.data = data; - state.tableData.total = res.data.total; + state.tableData.data = proxy.handleTree(data??[], "id","pid","children",true); }) }; // 打开角色用户列表 diff --git a/src/views/system/user/component/editUser.vue b/src/views/system/user/component/editUser.vue index 2fe57e7..35f917b 100644 --- a/src/views/system/user/component/editUser.vue +++ b/src/views/system/user/component/editUser.vue @@ -20,15 +20,19 @@ - - - - + + + @@ -116,7 +120,7 @@