mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 00:02:51 +08:00
fix: 修改数据加密解密,新增登录校验,新增底部备案号
This commit is contained in:
parent
77a6b50307
commit
efba045ad0
@ -9,11 +9,12 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/color": "^3.0.3",
|
"@types/color": "^3.0.3",
|
||||||
|
"@types/crypto-js": "^4.1.1",
|
||||||
"@types/keymaster": "^1.6.30",
|
"@types/keymaster": "^1.6.30",
|
||||||
"animate.css": "^4.1.1",
|
"animate.css": "^4.1.1",
|
||||||
"axios": "0.23.0",
|
"axios": "0.23.0",
|
||||||
"color": "^4.2.3",
|
"color": "^4.2.3",
|
||||||
"crypto-ts": "^1.0.2",
|
"crypto-js": "^4.1.1",
|
||||||
"echarts-liquidfill": "^3.1.0",
|
"echarts-liquidfill": "^3.1.0",
|
||||||
"highlight.js": "^11.5.0",
|
"highlight.js": "^11.5.0",
|
||||||
"html2canvas": "^1.4.1",
|
"html2canvas": "^1.4.1",
|
||||||
|
@ -2,6 +2,7 @@ lockfileVersion: 5.3
|
|||||||
|
|
||||||
specifiers:
|
specifiers:
|
||||||
'@types/color': ^3.0.3
|
'@types/color': ^3.0.3
|
||||||
|
'@types/crypto-js': ^4.1.1
|
||||||
'@types/keymaster': ^1.6.30
|
'@types/keymaster': ^1.6.30
|
||||||
'@types/node': ^16.11.26
|
'@types/node': ^16.11.26
|
||||||
'@typescript-eslint/eslint-plugin': ^5.18.0
|
'@typescript-eslint/eslint-plugin': ^5.18.0
|
||||||
@ -15,7 +16,7 @@ specifiers:
|
|||||||
animate.css: ^4.1.1
|
animate.css: ^4.1.1
|
||||||
axios: 0.23.0
|
axios: 0.23.0
|
||||||
color: ^4.2.3
|
color: ^4.2.3
|
||||||
crypto-ts: ^1.0.2
|
crypto-js: ^4.1.1
|
||||||
default-passive-events: ^2.0.0
|
default-passive-events: ^2.0.0
|
||||||
echarts: ^5.3.2
|
echarts: ^5.3.2
|
||||||
echarts-liquidfill: ^3.1.0
|
echarts-liquidfill: ^3.1.0
|
||||||
@ -53,11 +54,12 @@ specifiers:
|
|||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/color': 3.0.3
|
'@types/color': 3.0.3
|
||||||
|
'@types/crypto-js': 4.1.1
|
||||||
'@types/keymaster': 1.6.30
|
'@types/keymaster': 1.6.30
|
||||||
animate.css: 4.1.1
|
animate.css: 4.1.1
|
||||||
axios: 0.23.0
|
axios: 0.23.0
|
||||||
color: 4.2.3
|
color: 4.2.3
|
||||||
crypto-ts: 1.0.2
|
crypto-js: 4.1.1
|
||||||
echarts-liquidfill: 3.1.0_echarts@5.3.2
|
echarts-liquidfill: 3.1.0_echarts@5.3.2
|
||||||
highlight.js: 11.5.0
|
highlight.js: 11.5.0
|
||||||
html2canvas: 1.4.1
|
html2canvas: 1.4.1
|
||||||
@ -624,6 +626,10 @@ packages:
|
|||||||
'@types/color-convert': 2.0.0
|
'@types/color-convert': 2.0.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/@types/crypto-js/4.1.1:
|
||||||
|
resolution: {integrity: sha512-BG7fQKZ689HIoc5h+6D2Dgq1fABRa0RbBWKBd9SP/MVRVXROflpm5fhwyATX5duFmbStzyzyycPB8qUYKDH3NA==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/@types/estree/0.0.39:
|
/@types/estree/0.0.39:
|
||||||
resolution: {integrity: sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==}
|
resolution: {integrity: sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==}
|
||||||
dev: true
|
dev: true
|
||||||
@ -1491,13 +1497,8 @@ packages:
|
|||||||
which: 2.0.2
|
which: 2.0.2
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/crypto-ts/1.0.2:
|
/crypto-js/4.1.1:
|
||||||
resolution: {integrity: sha512-TcBWwF8ghYhVd/qPSwvY4nsbDZRN/PVxQ1Uc8ryRLiX4M4C5XSPyIhVgR4M5mIhrQEnWIktLcrv+FIqhKk2t3g==}
|
resolution: {integrity: sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==}
|
||||||
peerDependencies:
|
|
||||||
'@angular/common': '>= 5.0.0'
|
|
||||||
'@angular/core': '>= 5.0.0'
|
|
||||||
dependencies:
|
|
||||||
tslib: 1.14.1
|
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/css-line-break/2.1.0:
|
/css-line-break/2.1.0:
|
||||||
@ -4016,6 +4017,7 @@ packages:
|
|||||||
|
|
||||||
/tslib/1.14.1:
|
/tslib/1.14.1:
|
||||||
resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}
|
resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/tslib/2.3.0:
|
/tslib/2.3.0:
|
||||||
resolution: {integrity: sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==}
|
resolution: {integrity: sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==}
|
||||||
|
@ -30,7 +30,7 @@ export enum PageEnum {
|
|||||||
|
|
||||||
// 我的项目
|
// 我的项目
|
||||||
BASE_HOME_ITEMS = '/project/items',
|
BASE_HOME_ITEMS = '/project/items',
|
||||||
BASE_HOME_ITEMS_NAME = 'Project-Ttems',
|
BASE_HOME_ITEMS_NAME = 'Project-Items',
|
||||||
|
|
||||||
// 我的模板
|
// 我的模板
|
||||||
BASE_HOME_TEMPLATE = '/project/my-template',
|
BASE_HOME_TEMPLATE = '/project/my-template',
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="go-footer">
|
<div class="go-footer">
|
||||||
<slot>
|
<slot>
|
||||||
<n-text depth="2">
|
<n-space :size="50">
|
||||||
<n-a>{{ $t('global.doc_addr') }}: </n-a>
|
<n-text depth="2">
|
||||||
<n-a italic :href="docPath">
|
<n-a>{{ $t('global.doc_addr') }}: </n-a>
|
||||||
{{docPath}}
|
<n-a italic :href="docPath" target="_blank">
|
||||||
</n-a>
|
{{ docPath }}
|
||||||
</n-text>
|
</n-a>
|
||||||
|
</n-text>
|
||||||
|
<n-text depth="3">
|
||||||
|
<n-a italic href="https://beian.miit.gov.cn/" target="_blank">
|
||||||
|
京ICP备2021034585号-1
|
||||||
|
</n-a>
|
||||||
|
</n-text>
|
||||||
|
</n-space>
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Router } from 'vue-router';
|
import { Router } from 'vue-router';
|
||||||
import { PageEnum } from '@/enums/pageEnum'
|
import { PageEnum } from '@/enums/pageEnum'
|
||||||
|
import { loginCheck } from '@/utils'
|
||||||
|
|
||||||
export function createRouterGuards(router: Router) {
|
export function createRouterGuards(router: Router) {
|
||||||
// 前置
|
// 前置
|
||||||
@ -11,6 +11,13 @@ export function createRouterGuards(router: Router) {
|
|||||||
if (isErrorPage === -1) {
|
if (isErrorPage === -1) {
|
||||||
next({ name: PageEnum.ERROR_PAGE_NAME_404 })
|
next({ name: PageEnum.ERROR_PAGE_NAME_404 })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!loginCheck()) {
|
||||||
|
if (to.name === PageEnum.BASE_LOGIN_NAME) {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
next({ name: PageEnum.BASE_LOGIN_NAME })
|
||||||
|
}
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,29 +1,34 @@
|
|||||||
import * as CryptoJS from 'crypto-ts'
|
import CryptoJS from 'crypto-js'
|
||||||
// 加密
|
import { isString } from './type'
|
||||||
const AES_KEY = 'mt'
|
|
||||||
|
|
||||||
|
const KEY = 'mt'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 加密
|
||||||
|
* @param data { string }
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
export const cryptoEncode = (data: string): string => {
|
export const cryptoEncode = (data: string): string => {
|
||||||
if (typeof data !== 'string') return ''
|
if (!isString(data)) return ''
|
||||||
// 加密
|
// 加密
|
||||||
const key = CryptoJS.enc.Utf8.parse(AES_KEY)
|
const encryptedData = CryptoJS.AES.encrypt(data, KEY, {
|
||||||
const str = JSON.stringify(data)
|
|
||||||
const encryptedData = CryptoJS.AES.encrypt(str, key, {
|
|
||||||
mode: CryptoJS.mode.ECB,
|
mode: CryptoJS.mode.ECB,
|
||||||
padding: CryptoJS.pad.PKCS7,
|
padding: CryptoJS.pad.Pkcs7
|
||||||
iv: CryptoJS.enc.Utf8.parse(AES_KEY)
|
}).toString()
|
||||||
})
|
return encryptedData
|
||||||
return encryptedData.toString()
|
|
||||||
}
|
}
|
||||||
// 解密
|
|
||||||
|
/**
|
||||||
|
* * 解密
|
||||||
|
* @param data { string }
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
export const cryptoDecode = (data: string): string => {
|
export const cryptoDecode = (data: string): string => {
|
||||||
if (typeof data !== 'string') return ''
|
if (!isString(data)) return ''
|
||||||
const encryptedHexStr = CryptoJS.enc.Utf8.parse(data)
|
// 解密
|
||||||
const encryptedBase64Str = CryptoJS.enc.Utf8.stringify(encryptedHexStr)
|
const decryptedData = CryptoJS.AES.decrypt(data, KEY, {
|
||||||
const key = CryptoJS.enc.Utf8.parse(AES_KEY)
|
|
||||||
const decryptedData = CryptoJS.AES.decrypt(encryptedBase64Str, key, {
|
|
||||||
mode: CryptoJS.mode.ECB,
|
mode: CryptoJS.mode.ECB,
|
||||||
padding: CryptoJS.pad.PKCS7,
|
padding: CryptoJS.pad.Pkcs7
|
||||||
iv: CryptoJS.enc.Utf8.parse(AES_KEY)
|
|
||||||
})
|
})
|
||||||
return decryptedData.toString(CryptoJS.enc.Utf8)
|
return decryptedData.toString(CryptoJS.enc.Utf8)
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { ResultEnum } from '@/enums/httpEnum'
|
import { ResultEnum } from '@/enums/httpEnum'
|
||||||
import { ErrorPageNameMap, PageEnum } from '@/enums/pageEnum'
|
import { ErrorPageNameMap, PageEnum } from '@/enums/pageEnum'
|
||||||
import router from '@/router'
|
|
||||||
import { docPath, giteeSourceCodePath } from '@/settings/pathConst'
|
import { docPath, giteeSourceCodePath } from '@/settings/pathConst'
|
||||||
|
import { cryptoDecode } from './crypto'
|
||||||
|
import { StorageEnum } from '@/enums/storageEnum'
|
||||||
|
import { clearLocalStorage, getLocalStorage } from './storage'
|
||||||
|
import router from '@/router'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 根据名字跳转路由
|
* * 根据名字跳转路由
|
||||||
@ -101,6 +104,7 @@ export const reloadRoutePage = () => {
|
|||||||
* * 退出
|
* * 退出
|
||||||
*/
|
*/
|
||||||
export const logout = () => {
|
export const logout = () => {
|
||||||
|
clearLocalStorage(StorageEnum.GO_LOGIN_INFO_STORE)
|
||||||
routerTurnByName(PageEnum.BASE_LOGIN_NAME)
|
routerTurnByName(PageEnum.BASE_LOGIN_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,6 +132,10 @@ export const openGiteeSourceCode = () => {
|
|||||||
openNewWindow(giteeSourceCodePath)
|
openNewWindow(giteeSourceCodePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 判断是否是预览页
|
||||||
|
* @returns boolean
|
||||||
|
*/
|
||||||
export const isPreview = () => {
|
export const isPreview = () => {
|
||||||
return document.location.hash.includes('preview')
|
return document.location.hash.includes('preview')
|
||||||
}
|
}
|
||||||
@ -152,3 +160,21 @@ export const fetchRouteParams = () => {
|
|||||||
export const goHome = () => {
|
export const goHome = () => {
|
||||||
routerTurnByName(PageEnum.BASE_HOME_NAME)
|
routerTurnByName(PageEnum.BASE_HOME_NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 判断是否登录(现阶段是有 login 数据即可)
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
export const loginCheck = () => {
|
||||||
|
try {
|
||||||
|
const info = getLocalStorage(StorageEnum.GO_LOGIN_INFO_STORE)
|
||||||
|
if (!info) return false
|
||||||
|
const decodeInfo = cryptoDecode(info)
|
||||||
|
if (decodeInfo) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
} catch (error) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
@ -18,7 +18,7 @@
|
|||||||
* @param k 键名
|
* @param k 键名
|
||||||
* @returns any
|
* @returns any
|
||||||
*/
|
*/
|
||||||
export const getLocalStorage = (k: string) => {
|
export const getLocalStorage = (k: string) => {
|
||||||
const item = window.localStorage.getItem(k)
|
const item = window.localStorage.getItem(k)
|
||||||
try {
|
try {
|
||||||
return item ? JSON.parse(item) : item
|
return item ? JSON.parse(item) : item
|
||||||
@ -27,6 +27,14 @@ export const getLocalStorage = (k: string) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 清除本地会话数据
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
export const clearLocalStorage = (name: string) => {
|
||||||
|
window.localStorage.removeItem(name)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 存储临时会话数据
|
* * 存储临时会话数据
|
||||||
* @param k 键名
|
* @param k 键名
|
||||||
@ -52,4 +60,12 @@ export const getSessionStorage: (k: string) => any = (k: string) => {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 清除本地会话数据
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
export const clearSessioStorage = (name: string) => {
|
||||||
|
window.sessionStorage.removeItem(name)
|
||||||
}
|
}
|
@ -116,11 +116,6 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { reactive, ref, onMounted } from 'vue'
|
import { reactive, ref, onMounted } from 'vue'
|
||||||
import {
|
|
||||||
routerTurnByName,
|
|
||||||
cryptoEncode,
|
|
||||||
setLocalStorage
|
|
||||||
} from '@/utils'
|
|
||||||
import shuffle from 'lodash/shuffle'
|
import shuffle from 'lodash/shuffle'
|
||||||
import { carouselInterval } from '@/settings/designSetting'
|
import { carouselInterval } from '@/settings/designSetting'
|
||||||
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
import { useDesignStore } from '@/store/modules/designStore/designStore'
|
||||||
@ -131,7 +126,7 @@ import { LayoutFooter } from '@/layout/components/LayoutFooter'
|
|||||||
import { PageEnum } from '@/enums/pageEnum'
|
import { PageEnum } from '@/enums/pageEnum'
|
||||||
import { icon } from '@/plugins'
|
import { icon } from '@/plugins'
|
||||||
import { StorageEnum } from '@/enums/storageEnum'
|
import { StorageEnum } from '@/enums/storageEnum'
|
||||||
|
import { routerTurnByName, cryptoEncode, setLocalStorage } from '@/utils'
|
||||||
const { GO_LOGIN_INFO_STORE } = StorageEnum
|
const { GO_LOGIN_INFO_STORE } = StorageEnum
|
||||||
|
|
||||||
const { PersonOutlineIcon, LockClosedOutlineIcon } = icon.ionicons5
|
const { PersonOutlineIcon, LockClosedOutlineIcon } = icon.ionicons5
|
||||||
@ -161,20 +156,20 @@ onMounted(() => {
|
|||||||
|
|
||||||
const formInline = reactive({
|
const formInline = reactive({
|
||||||
username: 'admin',
|
username: 'admin',
|
||||||
password: '123456'
|
password: '123456',
|
||||||
})
|
})
|
||||||
|
|
||||||
const rules = {
|
const rules = {
|
||||||
username: {
|
username: {
|
||||||
required: true,
|
required: true,
|
||||||
message: t('global.form_account'),
|
message: t('global.form_account'),
|
||||||
trigger: 'blur'
|
trigger: 'blur',
|
||||||
},
|
},
|
||||||
password: {
|
password: {
|
||||||
required: true,
|
required: true,
|
||||||
message: t('global.form_password'),
|
message: t('global.form_password'),
|
||||||
trigger: 'blur'
|
trigger: 'blur',
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// 定时器
|
// 定时器
|
||||||
@ -193,7 +188,7 @@ const bgList = ref([
|
|||||||
'heatmap',
|
'heatmap',
|
||||||
'map',
|
'map',
|
||||||
'pie',
|
'pie',
|
||||||
'radar'
|
'radar',
|
||||||
])
|
])
|
||||||
|
|
||||||
// 处理url获取
|
// 处理url获取
|
||||||
@ -220,7 +215,7 @@ const handleSubmit = (e: Event) => {
|
|||||||
cryptoEncode(
|
cryptoEncode(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
username,
|
username,
|
||||||
password
|
password,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user