diff --git a/.env.development b/.env.development index 058274ca..2ecc4c7d 100644 --- a/.env.development +++ b/.env.development @@ -2,4 +2,4 @@ ENV = 'development' # 本地环境接口地址 -VITE_API_URL = 'http://localhost:8888/' \ No newline at end of file +VITE_API_URL = '/api' diff --git a/package.json b/package.json index e91c412e..923bf94b 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,8 @@ "vue-clipboard3": "^2.0.0", "vue-grid-layout": "^3.0.0-beta1", "vue-i18n": "^9.2.2", - "vue-router": "^4.1.6" + "vue-router": "^4.1.6", + "crypto-js": "^3.1.9-1" }, "devDependencies": { "@types/node": "^18.11.13", diff --git a/src/api/login/index.ts b/src/api/login/index.ts index 71ed9461..f6718726 100644 --- a/src/api/login/index.ts +++ b/src/api/login/index.ts @@ -7,21 +7,39 @@ import request from '/@/utils/request'; * @method signIn 用户登录 * @method signOut 用户退出登录 */ -export function useLoginApi() { - return { - signIn: (data: object) => { - return request({ - url: '/user/signIn', - method: 'post', - data, - }); - }, - signOut: (data: object) => { - return request({ - url: '/user/signOut', - method: 'post', - data, - }); - }, - }; +// export function useLoginApi() { +// return { +// signIn: (data: object) => { +// return request({ +// url: '/user/signIn', +// method: 'post', +// data, +// }); +// }, +// signOut: (data: object) => { +// return request({ +// url: '/user/signOut', +// method: 'post', +// data, +// }); +// }, +// }; +// } + +/** + * 登录 + * @param data + */ +export const login = (data: any) => { + let basicAuth = 'Basic ' + window.btoa('pig:pig') + return request({ + url: '/admin/oauth2/token', + method: 'post', + params: data, + headers: { + isToken: false, + 'TENANT-ID': '1', + 'Authorization': basicAuth + } + }) } diff --git a/src/components/verifition/Verify.vue b/src/components/verifition/Verify.vue new file mode 100644 index 00000000..42a4d731 --- /dev/null +++ b/src/components/verifition/Verify.vue @@ -0,0 +1,443 @@ + + + diff --git a/src/components/verifition/Verify/VerifyPoints.vue b/src/components/verifition/Verify/VerifyPoints.vue new file mode 100644 index 00000000..e145da82 --- /dev/null +++ b/src/components/verifition/Verify/VerifyPoints.vue @@ -0,0 +1,262 @@ + + diff --git a/src/components/verifition/Verify/VerifySlide.vue b/src/components/verifition/Verify/VerifySlide.vue new file mode 100644 index 00000000..39194e86 --- /dev/null +++ b/src/components/verifition/Verify/VerifySlide.vue @@ -0,0 +1,380 @@ + + + diff --git a/src/components/verifition/api/index.ts b/src/components/verifition/api/index.ts new file mode 100644 index 00000000..196ce30a --- /dev/null +++ b/src/components/verifition/api/index.ts @@ -0,0 +1,26 @@ +/** + * 此处可直接引用自己项目封装好的 axios 配合后端联调 + */ + + +import request from '/@/utils/request'; + +//获取验证图片 以及token +export function reqGet(data: Object) { + return request({ + url: '/admin/code/create', + method: 'get', + data + }) +} + +//滑动或者点选验证 +export function reqCheck(data: Object) { + return request({ + url: '/admin/code/check', + method: 'post', + params: data + }) +} + + diff --git a/src/components/verifition/utils/ase.js b/src/components/verifition/utils/ase.js new file mode 100644 index 00000000..4c1c5594 --- /dev/null +++ b/src/components/verifition/utils/ase.js @@ -0,0 +1,11 @@ +import CryptoJS from 'crypto-js' +/** + * @word 要加密的内容 + * @keyWord String 服务器随机返回的关键字 + * */ +export function aesEncrypt(word,keyWord="XwKsGlMcdPMEhR1B"){ + var key = CryptoJS.enc.Utf8.parse(keyWord); + var srcs = CryptoJS.enc.Utf8.parse(word); + var encrypted = CryptoJS.AES.encrypt(srcs, key, {mode:CryptoJS.mode.ECB,padding: CryptoJS.pad.Pkcs7}); + return encrypted.toString(); +} diff --git a/src/components/verifition/utils/axios.js b/src/components/verifition/utils/axios.js new file mode 100644 index 00000000..9d58857d --- /dev/null +++ b/src/components/verifition/utils/axios.js @@ -0,0 +1,30 @@ +import axios from 'axios'; + +axios.defaults.baseURL = 'https://captcha.anji-plus.com/captcha-api'; + +const service = axios.create({ + timeout: 40000, + headers: { + 'X-Requested-With': 'XMLHttpRequest', + 'Content-Type': 'application/json; charset=UTF-8' + }, +}) +service.interceptors.request.use( + config => { + return config + }, + error => { + Promise.reject(error) + } +) + +// response interceptor +service.interceptors.response.use( + response => { + const res = response.data; + return res + }, + error => { + } +) +export default service diff --git a/src/components/verifition/utils/util.js b/src/components/verifition/utils/util.js new file mode 100644 index 00000000..4cd1ad9b --- /dev/null +++ b/src/components/verifition/utils/util.js @@ -0,0 +1,35 @@ +export function resetSize(vm) { + var img_width, img_height, bar_width, bar_height; //图片的宽度、高度,移动条的宽度、高度 + + var parentWidth = vm.$el.parentNode.offsetWidth || window.offsetWidth + var parentHeight = vm.$el.parentNode.offsetHeight || window.offsetHeight + if (vm.imgSize.width.indexOf('%') != -1) { + img_width = parseInt(vm.imgSize.width) / 100 * parentWidth + 'px' + } else { + img_width = vm.imgSize.width; + } + + if (vm.imgSize.height.indexOf('%') != -1) { + img_height = parseInt(vm.imgSize.height) / 100 * parentHeight + 'px' + } else { + img_height = vm.imgSize.height + } + + if (vm.barSize.width.indexOf('%') != -1) { + bar_width = parseInt(vm.barSize.width) / 100 * parentWidth + 'px' + } else { + bar_width = vm.barSize.width + } + + if (vm.barSize.height.indexOf('%') != -1) { + bar_height = parseInt(vm.barSize.height) / 100 * parentHeight + 'px' + } else { + bar_height = vm.barSize.height + } + + return {imgWidth: img_width, imgHeight: img_height, barWidth: bar_width, barHeight: bar_height} +} + +export const _code_chars = [1, 2, 3, 4, 5, 6, 7, 8, 9, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] +export const _code_color1 = ['#fffff0', '#f0ffff', '#f0fff0', '#fff0f0'] +export const _code_color2 = ['#FF0033', '#006699', '#993366', '#FF9900', '#66CC66', '#FF33CC'] \ No newline at end of file diff --git a/src/i18n/lang/en.ts b/src/i18n/lang/en.ts index 83d1129d..2e841447 100644 --- a/src/i18n/lang/en.ts +++ b/src/i18n/lang/en.ts @@ -93,10 +93,7 @@ export default { dropdownSmall: 'small', dropdown1: 'home page', dropdown2: 'Personal Center', - dropdown3: '404', - dropdown4: '401', dropdown5: 'Log out', - dropdown6: 'Code warehouse', searchPlaceholder: 'Menu search: support Chinese, routing path', newTitle: 'notice', newBtn: 'All read', diff --git a/src/i18n/lang/zh-cn.ts b/src/i18n/lang/zh-cn.ts index e0713b94..9315017d 100644 --- a/src/i18n/lang/zh-cn.ts +++ b/src/i18n/lang/zh-cn.ts @@ -93,10 +93,7 @@ export default { dropdownSmall: '小型', dropdown1: '首页', dropdown2: '个人中心', - dropdown3: '404', - dropdown4: '401', dropdown5: '退出登录', - dropdown6: '代码仓库', searchPlaceholder: '菜单搜索:支持中文、路由路径', newTitle: '通知', newBtn: '全部已读', diff --git a/src/i18n/lang/zh-tw.ts b/src/i18n/lang/zh-tw.ts index 35e406fe..7dff493f 100644 --- a/src/i18n/lang/zh-tw.ts +++ b/src/i18n/lang/zh-tw.ts @@ -93,10 +93,7 @@ export default { dropdownSmall: '小型', dropdown1: '首頁', dropdown2: '個人中心', - dropdown3: '404', - dropdown4: '401', dropdown5: '登出', - dropdown6: '程式碼倉庫', searchPlaceholder: '選單蒐索:支援中文、路由路徑', newTitle: '通知', newBtn: '全部已讀', diff --git a/src/layout/navBars/breadcrumb/user.vue b/src/layout/navBars/breadcrumb/user.vue index 4a622e0f..59e14fd7 100644 --- a/src/layout/navBars/breadcrumb/user.vue +++ b/src/layout/navBars/breadcrumb/user.vue @@ -68,10 +68,7 @@ diff --git a/src/router/route.ts b/src/router/route.ts index 0dc7096a..c40b4cd0 100644 --- a/src/router/route.ts +++ b/src/router/route.ts @@ -228,25 +228,5 @@ export const staticRoutes: Array = [ meta: { title: '登录', }, - }, - /** - * 提示:写在这里的为全屏界面,不建议写在这里 - * 请写在 `dynamicRoutes` 路由数组中 - */ - { - path: '/visualizingDemo1', - name: 'visualizingDemo1', - component: () => import('/@/views/visualizing/demo1.vue'), - meta: { - title: 'router.visualizingLinkDemo1', - }, - }, - { - path: '/visualizingDemo2', - name: 'visualizingDemo2', - component: () => import('/@/views/visualizing/demo2.vue'), - meta: { - title: 'router.visualizingLinkDemo2', - }, - }, + } ]; diff --git a/src/stores/themeConfig.ts b/src/stores/themeConfig.ts index 839827ca..689576c8 100644 --- a/src/stores/themeConfig.ts +++ b/src/stores/themeConfig.ts @@ -78,7 +78,7 @@ export const useThemeConfig = defineStore('themeConfig', { * 界面显示 */ // 是否开启侧边栏 Logo - isShowLogo: false, + isShowLogo: true, // 初始化变量,用于 el-scrollbar 的高度更新,请勿删除 isShowLogoChange: false, // 是否开启 Breadcrumb,强制经典、横向布局不显示 @@ -104,7 +104,7 @@ export const useThemeConfig = defineStore('themeConfig', { // 是否开启水印 isWartermark: true, // 水印文案 - wartermarkText: 'vue-next-admin', + wartermarkText: 'PigX', /** * 其它设置 @@ -137,9 +137,9 @@ export const useThemeConfig = defineStore('themeConfig', { * 全局网站标题 / 副标题 */ // 网站主标题(菜单导航、浏览器当前网页标题) - globalTitle: 'vue-next-admin', + globalTitle: 'PigX 快速开发框架', // 网站副标题(登录页顶部文字) - globalViceTitle: 'vueNextAdmin', + globalViceTitle: 'PigX 快速开发框架', // 网站副标题(登录页顶部文字) globalViceTitleMsg: '专注、免费、开源、维护、解疑', // 默认初始语言,可选值"",默认 zh-cn @@ -147,6 +147,7 @@ export const useThemeConfig = defineStore('themeConfig', { // 默认全局组件大小,可选值"",默认 'large' globalComponentSize: 'large', }, + }), actions: { setThemeConfig(data: ThemeConfigState) { diff --git a/src/stores/userInfo.ts b/src/stores/userInfo.ts index 0fb46bf9..81546038 100644 --- a/src/stores/userInfo.ts +++ b/src/stores/userInfo.ts @@ -1,6 +1,8 @@ import { defineStore } from 'pinia'; import Cookies from 'js-cookie'; import { Session } from '/@/utils/storage'; +import { login } from '/@//api/login/index' +import other from '/@/utils/other' /** * 用户信息 @@ -17,6 +19,33 @@ export const useUserInfo = defineStore('userInfo', { }, }), actions: { + async login(data: any){ + data.grant_type = 'password' + data.scope = 'server' + // 密码加密 + const user = other.encryption({ + data: data, + key: 'pigxpigxpigxpigx', + param: ['password'] + }) + console.log(user,'user') + + + return new Promise((resolve, reject) => { + login(user).then(res =>{ + // 存储token 信息 + console.log(res.data,'login data') + Session.set('token', res.data.access_token); + // 模拟数据,对接接口时,记得删除多余代码及对应依赖的引入。用于 `/src/stores/userInfo.ts` 中不同用户登录判断(模拟数据) + Cookies.set('userName', res.data.username); + resolve(res) + }).then((err) => { + console.log(err) + reject(err) + }) + }) + + }, async setUserInfos() { // 存储用户信息到浏览器缓存 if (Session.get('userInfo')) { diff --git a/src/utils/other.ts b/src/utils/other.ts index 08dd4771..8d5c7fbf 100644 --- a/src/utils/other.ts +++ b/src/utils/other.ts @@ -8,6 +8,8 @@ import { useThemeConfig } from '/@/stores/themeConfig'; import { i18n } from '/@/i18n/index'; import { Local } from '/@/utils/storage'; import { verifyUrl } from '/@/utils/toolsValidate'; +// @ts-ignore +import * as CryptoJS from "crypto-js"; // 引入组件 const SvgIcon = defineAsyncComponent(() => import('/@/components/svgIcon/index.vue')); @@ -172,6 +174,34 @@ export function handleOpenLink(val: RouteItem) { else window.open(`${origin}${pathname}#${val.meta?.isLink}`); } + +/** + *加密处理 + */ +export function encryption(params: any) { + let { data, type, param, key } = params; + const result = JSON.parse(JSON.stringify(data)); + if (type === "Base64") { + param.forEach((ele: any) => { + result[ele] = btoa(result[ele]); + }); + } else { + param.forEach((ele: any) => { + var data = result[ele]; + key = CryptoJS.enc.Latin1.parse(key); + var iv = key; + // 加密 + var encrypted = CryptoJS.AES.encrypt(data, key, { + iv: iv, + mode: CryptoJS.mode.CFB, + padding: CryptoJS.pad.NoPadding + }); + result[ele] = encrypted.toString(); + }); + } + return result; +}; + /** * 统一批量导出 * @method elSvg 导出全局注册 element plus svg 图标 @@ -212,6 +242,9 @@ const other = { handleOpenLink: (val: RouteItem) => { handleOpenLink(val); }, + encryption: (data: any) => { + return encryption(data) + } }; // 统一批量导出 diff --git a/src/views/login/component/account.vue b/src/views/login/component/account.vue index fb214b9f..fbd94b3f 100644 --- a/src/views/login/component/account.vue +++ b/src/views/login/component/account.vue @@ -1,7 +1,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + @@ -56,7 +65,7 @@