修改登录
This commit is contained in:
parent
33b13543e3
commit
90ca2cef2a
BIN
frontend/public/images/navleft.png
Normal file
BIN
frontend/public/images/navleft.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
BIN
frontend/public/images/navright.png
Normal file
BIN
frontend/public/images/navright.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
BIN
frontend/src/assets/system/navleft.png
Normal file
BIN
frontend/src/assets/system/navleft.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
@ -195,7 +195,7 @@ function routerclick(path) {
|
|||||||
}else if(path == '/UserLogin'){
|
}else if(path == '/UserLogin'){
|
||||||
const route = router.resolve({
|
const route = router.resolve({
|
||||||
path: path,
|
path: path,
|
||||||
query: { id: '1927554158852841473' ,name:'测试项目'}
|
// query: { id: '1927554158852841473' ,name:'测试项目'}
|
||||||
});
|
});
|
||||||
window.open(route.href, '_blank');
|
window.open(route.href, '_blank');
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,8 @@ type InternalAxiosRequestConfigWidthLoading<T> = T & {
|
|||||||
loading?: boolean
|
loading?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus-secondary'
|
// import { ElMessage, ElMessageBox } from 'element-plus-secondary'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
|
|
||||||
const { result_code } = config
|
const { result_code } = config
|
||||||
@ -132,11 +133,11 @@ service.interceptors.response.use(
|
|||||||
(
|
(
|
||||||
response: AxiosResponse<any> & { config: InternalAxiosRequestConfig & { loading?: boolean } }
|
response: AxiosResponse<any> & { config: InternalAxiosRequestConfig & { loading?: boolean } }
|
||||||
) => {
|
) => {
|
||||||
|
|
||||||
if (response.config.responseType === 'blob') {
|
if (response.config.responseType === 'blob') {
|
||||||
// 如果是文件流,直接过
|
// 如果是文件流,直接过
|
||||||
return response
|
return response
|
||||||
} else if (response.data.code == result_code || response.data.code == 50002) {
|
} else if (response.data.code == result_code || response.data.code == 50002) {
|
||||||
|
|
||||||
return response.data
|
return response.data
|
||||||
} else if (response.config.url.match(/^\/map|geo\/\d{3}\/\d+\.json$/)) {
|
} else if (response.config.url.match(/^\/map|geo\/\d{3}\/\d+\.json$/)) {
|
||||||
// TODO 处理静态文件
|
// TODO 处理静态文件
|
||||||
@ -158,6 +159,7 @@ service.interceptors.response.use(
|
|||||||
message: response.data.msg,
|
message: response.data.msg,
|
||||||
showClose: true
|
showClose: true
|
||||||
})
|
})
|
||||||
|
|
||||||
if (response.data.code === 80001) {
|
if (response.data.code === 80001) {
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
let queryRedirectPath = '/application/index'
|
let queryRedirectPath = '/application/index'
|
||||||
|
@ -114,7 +114,7 @@ const routes:any = [
|
|||||||
component: () => import('@/views/system/userlogin/login_container.vue'),
|
component: () => import('@/views/system/userlogin/login_container.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: '登录',
|
title: '登录',
|
||||||
requiresAuth: true
|
requiresAuth: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -140,17 +140,24 @@ router.beforeEach((to, from, next) => {
|
|||||||
// 设置页面标题
|
// 设置页面标题
|
||||||
document.title = to.meta.title ? `${to.meta.title} - StdProject` : 'StdProject'
|
document.title = to.meta.title ? `${to.meta.title} - StdProject` : 'StdProject'
|
||||||
|
|
||||||
|
debugger
|
||||||
|
console.log(userStore.isAuthenticated)
|
||||||
// 检查是否需要认证
|
// 检查是否需要认证
|
||||||
if (to.meta.requiresAuth) {
|
if (to.meta.requiresAuth) {
|
||||||
next()
|
// next()
|
||||||
// if (userStore.isAuthenticated) {
|
// if (userStore.isAuthenticated) {
|
||||||
// next()
|
// next()
|
||||||
// } else {
|
// } else {
|
||||||
// next('/login')
|
// next('/login')
|
||||||
// }
|
// }
|
||||||
|
if (userStore.isAuthenticated) {
|
||||||
|
next()
|
||||||
|
} else {
|
||||||
|
next('/UserLogin') // 未认证重定向到登录页
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 如果已登录且访问登录页,重定向到仪表板
|
// 如果已登录且访问登录页,重定向到仪表板
|
||||||
if (to.path === '/login' && userStore.isAuthenticated) {
|
if (to.path === '/UserLogin' && userStore.isAuthenticated) {
|
||||||
next('/dashboard')
|
next('/dashboard')
|
||||||
} else {
|
} else {
|
||||||
next()
|
next()
|
||||||
|
@ -5,6 +5,7 @@ import { ElMessage } from 'element-plus'
|
|||||||
|
|
||||||
export const useUserStore = defineStore('user', () => {
|
export const useUserStore = defineStore('user', () => {
|
||||||
// 状态
|
// 状态
|
||||||
|
debugger
|
||||||
const token = ref(localStorage.getItem('token') || '')
|
const token = ref(localStorage.getItem('token') || '')
|
||||||
const userInfo = ref(JSON.parse(localStorage.getItem('userInfo') || 'null'))
|
const userInfo = ref(JSON.parse(localStorage.getItem('userInfo') || 'null'))
|
||||||
const permissions = ref(JSON.parse(localStorage.getItem('permissions') || '[]'))
|
const permissions = ref(JSON.parse(localStorage.getItem('permissions') || '[]'))
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import { updateUser } from '@/api/data-visualization/manage/user'
|
import { updateUser,queryUsers } from '@/api/data-visualization/manage/user'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { useCache } from '@/data-visualization/hooks/web/useCache'
|
import { useCache } from '@/data-visualization/hooks/web/useCache'
|
||||||
const { wsCache } = useCache()
|
const { wsCache } = useCache()
|
||||||
@ -16,8 +16,12 @@ const userlist: any = ref({
|
|||||||
id:''
|
id:''
|
||||||
})
|
})
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
init()
|
||||||
userlist.value = props.userList
|
userlist.value = props.userList
|
||||||
})
|
})
|
||||||
|
function init() {
|
||||||
|
|
||||||
|
}
|
||||||
function saveinfo() {
|
function saveinfo() {
|
||||||
//保存
|
//保存
|
||||||
updateUser(userlist.value).then((res:any) => {
|
updateUser(userlist.value).then((res:any) => {
|
||||||
|
@ -64,15 +64,15 @@ const runCode = async () => {
|
|||||||
// '@/viewsnew/application/SfcEditor/NavbarEditor/assocPage.vue': Vue.defineAsyncComponent(() =>
|
// '@/viewsnew/application/SfcEditor/NavbarEditor/assocPage.vue': Vue.defineAsyncComponent(() =>
|
||||||
// import('@/viewsnew/application/SfcEditor/NavbarEditor/assocPage.vue')
|
// import('@/viewsnew/application/SfcEditor/NavbarEditor/assocPage.vue')
|
||||||
// ),
|
// ),
|
||||||
// '@/viewsnew/application/permissionset/index.vue': Vue.defineAsyncComponent(() =>
|
'@/views/system/manage/index.vue': Vue.defineAsyncComponent(() =>
|
||||||
// import('@/viewsnew/application/permissionset/index.vue')
|
import('@/views/system/manage/index.vue')
|
||||||
// ),
|
),
|
||||||
// '@/viewsnew/application/permissionset/user/userinfo.vue': Vue.defineAsyncComponent(() =>
|
'@/views/system/manage/user/userinfo.vue': Vue.defineAsyncComponent(() =>
|
||||||
// import('@/viewsnew/application/permissionset/user/userinfo.vue')
|
import('@/views/system/manage/user/userinfo.vue')
|
||||||
// ),
|
),
|
||||||
'@/data-visualization/hooks/web/useCache': { useCache }
|
'@/data-visualization/hooks/web/useCache': { useCache }
|
||||||
},
|
},
|
||||||
getFile: async (fileName) => {
|
getFile: async (fileName:any) => {
|
||||||
if (fileName === 'dynamic.vue') {
|
if (fileName === 'dynamic.vue') {
|
||||||
let code = sfcCode.value
|
let code = sfcCode.value
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
import { ref, watch, onMounted, onBeforeUnmount, shallowRef } from 'vue'
|
import { ref, watch, onMounted, onBeforeUnmount, shallowRef } from 'vue'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
// import Assocmodule from '@/viewsnew/application/SfcEditor/NavbarEditor/assocPage.vue'
|
// import Assocmodule from '@/viewsnew/application/SfcEditor/NavbarEditor/assocPage.vue'
|
||||||
// import PermissionSet from '@/viewsnew/application/permissionset/index.vue'
|
import PermissionSet from '@/views/system/manage/index.vue'
|
||||||
// import UserInfoSet from '@/viewsnew/application/permissionset/user/userinfo.vue'
|
import UserInfoSet from '@/views/system/manage/user/userinfo.vue'
|
||||||
import {useRoute, useRouter } from 'vue-router'
|
import {useRoute, useRouter } from 'vue-router'
|
||||||
import { useCache } from '@/data-visualization/hooks/web/useCache'
|
import { useCache } from '@/data-visualization/hooks/web/useCache'
|
||||||
const { wsCache } = useCache()
|
const { wsCache } = useCache()
|
||||||
@ -138,7 +138,7 @@ function logout(){
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
wsCache.delete('Permission-userinfo')
|
wsCache.delete('Permission-userinfo')
|
||||||
router.push({
|
router.push({
|
||||||
path: '/SystemLogin',
|
path: '/UserLogin',
|
||||||
query: { id: props.applicationId, name: props.projectName }
|
query: { id: props.applicationId, name: props.projectName }
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -178,20 +178,20 @@ function userdetails(){
|
|||||||
</div>
|
</div>
|
||||||
<div class="Navbar-box-right">
|
<div class="Navbar-box-right">
|
||||||
<div style="margin-right: 10px;cursor: pointer;" @click="permissionClick"><img
|
<div style="margin-right: 10px;cursor: pointer;" @click="permissionClick"><img
|
||||||
src="@/assets/img/navpermission.png" alt=""></div>
|
src="@/assets/system/navpermission.png" alt=""></div>
|
||||||
<div style="margin-right: 10px;cursor: pointer;"><img src="@/assets/img/nav1.png" alt=""></div>
|
<div style="margin-right: 10px;cursor: pointer;" @click="userdetails"><img src="@/assets/system/nav1.png" alt=""></div>
|
||||||
<div style="margin-right: 15px;min-width: 45px;cursor: pointer;" @click="userdetails">{{ props.isExecuteEvent == false?userList.nickname:'admin' }}</div>
|
<div style="margin-right: 15px;min-width: 45px;cursor: pointer;" @click="userdetails">{{ props.isExecuteEvent == false?userList.nickname:'admin' }}</div>
|
||||||
<div style="margin-right: 15px;cursor: pointer;" @click="userdetails"><img src="@/assets/img/nav3.png" alt=""></div>
|
<div style="margin-right: 15px;cursor: pointer;"><img src="@/assets/system/nav3.png" alt=""></div>
|
||||||
<div @click="logout" style="cursor: pointer;"><img src="@/assets/img/nav4.png" alt=""></div>
|
<div @click="logout" style="cursor: pointer;"><img src="@/assets/system/nav4.png" alt=""></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="!props.isExecuteEvent" class="system-box-content"
|
<div v-if="!props.isExecuteEvent" class="system-box-content"
|
||||||
:style="{ height: props.isFixed ? 'calc(100vh - 65px)' : 'calc(100vh - 125px)' }">
|
:style="{ height: props.isFixed ? 'calc(100vh - 65px)' : 'calc(100vh - 125px)' }">
|
||||||
<!-- <Assocmodule v-if="showmodule" :applicationId="props.applicationId"
|
<!-- <Assocmodule v-if="showmodule" :applicationId="props.applicationId"
|
||||||
:moduleinfo="currentrow" />
|
:moduleinfo="currentrow" /> -->
|
||||||
<PermissionSet v-if="showermission" />
|
<PermissionSet v-if="showermission" />
|
||||||
<UserInfoSet v-if="showUserInfo" :userList="userList" :applicationId="props.applicationId" /> -->
|
<UserInfoSet v-if="showUserInfo" :userList="userList" :applicationId="props.applicationId" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -6,9 +6,11 @@ import { useRoute, useRouter } from 'vue-router'
|
|||||||
import { userLogin } from '@/api/data-visualization/manage/user'
|
import { userLogin } from '@/api/data-visualization/manage/user'
|
||||||
import { useCache } from '@/data-visualization/hooks/web/useCache'
|
import { useCache } from '@/data-visualization/hooks/web/useCache'
|
||||||
import { encrypt,decrypt } from '@/utils/rsaEncrypt';
|
import { encrypt,decrypt } from '@/utils/rsaEncrypt';
|
||||||
|
import { useUserStore } from '@/store/user'
|
||||||
|
import { set } from 'lodash'
|
||||||
const { wsCache } = useCache()
|
const { wsCache } = useCache()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const userStore = useUserStore()
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
id: String,
|
id: String,
|
||||||
name: String,
|
name: String,
|
||||||
@ -46,20 +48,27 @@ const submitForm = async (formEl: FormInstance | undefined) => {
|
|||||||
let userInfo = {
|
let userInfo = {
|
||||||
nickname: res.data.nickname,
|
nickname: res.data.nickname,
|
||||||
username: res.data.username,
|
username: res.data.username,
|
||||||
id: res.data.id,
|
id: res.data.userid
|
||||||
phone: res.data.phone,
|
|
||||||
email: res.data.email,
|
|
||||||
}
|
}
|
||||||
wsCache.set('Permission-userinfo', userInfo)
|
wsCache.set('Permission-userinfo', userInfo)
|
||||||
|
|
||||||
ElMessage.success('登录成功')
|
ElMessage.success('登录成功')
|
||||||
|
userStore.isAuthenticated = true
|
||||||
|
localStorage.setItem('token', res.data.token)
|
||||||
|
setTimeout(() => {
|
||||||
router.push({
|
router.push({
|
||||||
path: '/UserNavbar',
|
path: '/UserNavbar',
|
||||||
query: { id: props.id, name: props.name }
|
query: { id: props.id, name: props.name }
|
||||||
})
|
})
|
||||||
|
}, 500)
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
console.log(res,'信息')
|
||||||
ElMessage.error(res.msg)
|
ElMessage.error(res.msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}).catch((err:any) => {
|
||||||
|
ElMessage.error(err.msg)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -12,6 +12,9 @@ import defaultTemplate from '@/views/system/userlogin/login.vue?raw'
|
|||||||
import { userLogin } from '@/api/data-visualization/manage/user'
|
import { userLogin } from '@/api/data-visualization/manage/user'
|
||||||
import { useCache } from '@/data-visualization/hooks/web/useCache'
|
import { useCache } from '@/data-visualization/hooks/web/useCache'
|
||||||
import { encrypt,decrypt } from '@/utils/rsaEncrypt';
|
import { encrypt,decrypt } from '@/utils/rsaEncrypt';
|
||||||
|
import { useUserStore } from '@/store/user'
|
||||||
|
import _ from 'lodash'
|
||||||
|
import * as lodashEs from 'lodash-es'
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const sfcCode = ref(defaultTemplate)
|
const sfcCode = ref(defaultTemplate)
|
||||||
@ -49,9 +52,25 @@ const runCode = async () => {
|
|||||||
'vue-router': VueRouter,
|
'vue-router': VueRouter,
|
||||||
'@/api/data-visualization/manage/user': { userLogin },
|
'@/api/data-visualization/manage/user': { userLogin },
|
||||||
'@/data-visualization/hooks/web/useCache': { useCache },
|
'@/data-visualization/hooks/web/useCache': { useCache },
|
||||||
'@/utils/rsaEncrypt':{ encrypt,decrypt }
|
'@/utils/rsaEncrypt':{ encrypt,decrypt },
|
||||||
|
'lodash': _,
|
||||||
|
'lodash-es': lodashEs,
|
||||||
|
'@/store/user':{ useUserStore }
|
||||||
},
|
},
|
||||||
getFile: async (fileName:any) => {
|
getFile: async (fileName:any) => {
|
||||||
|
if (!fileName.startsWith('@/') && !fileName.endsWith('.less') && fileName !== 'dynamic.vue') {
|
||||||
|
try {
|
||||||
|
// 添加 ?v= 参数避免缓存问题
|
||||||
|
const module = await import(/* @vite-ignore */ `${fileName}?v=${Date.now()}`)
|
||||||
|
return {
|
||||||
|
content: `export default ${module.default || module}`,
|
||||||
|
mediaType: 'application/javascript'
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error(`模块加载失败: ${fileName}`, e)
|
||||||
|
return { content: `/* 模块加载失败 */` }
|
||||||
|
}
|
||||||
|
}
|
||||||
if (fileName.startsWith('@/')) {
|
if (fileName.startsWith('@/')) {
|
||||||
const resolvedPath = fileName.replace('@/', '/src/')
|
const resolvedPath = fileName.replace('@/', '/src/')
|
||||||
try {
|
try {
|
||||||
@ -121,8 +140,8 @@ const runCode = async () => {
|
|||||||
const componentModule:any = await loadModule('dynamic.vue', options)
|
const componentModule:any = await loadModule('dynamic.vue', options)
|
||||||
const component = componentModule.default || componentModule
|
const component = componentModule.default || componentModule
|
||||||
const dynamicProps = ref({
|
const dynamicProps = ref({
|
||||||
id: route.query.id,
|
id: '1927554158852841473',
|
||||||
name: route.query.name,
|
name: '测试',
|
||||||
isExecuteEvent: false
|
isExecuteEvent: false
|
||||||
})
|
})
|
||||||
// prevApp = Vue.createApp({
|
// prevApp = Vue.createApp({
|
||||||
@ -178,6 +197,7 @@ function init() {
|
|||||||
// runCode()
|
// runCode()
|
||||||
// }
|
// }
|
||||||
// })
|
// })
|
||||||
|
|
||||||
}
|
}
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user