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