优化
This commit is contained in:
parent
94e2cc8a0d
commit
568bcdf140
@ -120,17 +120,19 @@ function menuclick(name:any){
|
|||||||
color: #383838;
|
color: #383838;
|
||||||
}
|
}
|
||||||
:deep(.ed-button){
|
:deep(.ed-button){
|
||||||
border-color: #dcdfe6;
|
border-color: #dcdfe6 !important;
|
||||||
|
background-color:#ffffff !important;
|
||||||
|
color: #1f2329 !important;
|
||||||
}
|
}
|
||||||
:deep(.ed-button--primary){
|
:deep(.ed-button--primary){
|
||||||
background-color:#409eff;
|
background-color:#409eff !important;
|
||||||
color: #ffffff;
|
color: #ffffff !important;
|
||||||
border-color: #409eff;
|
border-color: #409eff !important;
|
||||||
}
|
}
|
||||||
:deep(.ed-button.is-disabled){
|
:deep(.ed-button.is-disabled){
|
||||||
background: #ffffff;
|
background: #ffffff !important;
|
||||||
color:#C9C9C9;
|
color:#C9C9C9 !important;
|
||||||
border-color: #f2f2f2;
|
border-color: #f2f2f2 !important;
|
||||||
}
|
}
|
||||||
:deep(.ed-button.is-disabled, .ed-button.is-disabled:focus, .ed-button.is-disabled:hover){
|
:deep(.ed-button.is-disabled, .ed-button.is-disabled:focus, .ed-button.is-disabled:hover){
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
|
@ -21,9 +21,6 @@ const router = useRouter()
|
|||||||
const sfcCode = ref(defaultTemplate)
|
const sfcCode = ref(defaultTemplate)
|
||||||
const previewContainer:any = ref(null)
|
const previewContainer:any = ref(null)
|
||||||
let prevApp:any = null
|
let prevApp:any = null
|
||||||
const projectName:any = ref('')
|
|
||||||
const applicationId:any = ref('')
|
|
||||||
const menuList:any= ref([])
|
|
||||||
// 增强的Base64转换函数
|
// 增强的Base64转换函数
|
||||||
const convertToBase64 = async (imagePath:any) => {
|
const convertToBase64 = async (imagePath:any) => {
|
||||||
try {
|
try {
|
||||||
@ -119,8 +116,6 @@ 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 = Vue.reactive({
|
const dynamicProps = Vue.reactive({
|
||||||
menuList: menuList.value,
|
|
||||||
applicationId: applicationId.value,
|
|
||||||
})
|
})
|
||||||
// 修改createApp方式
|
// 修改createApp方式
|
||||||
prevApp = Vue.createApp({
|
prevApp = Vue.createApp({
|
||||||
@ -147,40 +142,9 @@ const runCode = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
const appInfo:any = JSON.parse(localStorage.getItem('userInfo'))
|
|
||||||
if (appInfo.id) {
|
|
||||||
applicationId.value = appInfo.id
|
|
||||||
getmenuinfo()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
function gettreeData(orglist:any) {
|
|
||||||
const res:any = {};
|
|
||||||
for (const row of orglist) {
|
|
||||||
// 处理 parentid 并解构需要字段
|
|
||||||
const parentid = row.parentid || "0";
|
|
||||||
const { id, name,code, isdisplay, appId, type,module_id,module_type } = row;
|
|
||||||
// 统一节点数据对象
|
|
||||||
const nodeData = { parentid, id, name,code, isdisplay, appId, type,module_id,module_type }
|
|
||||||
// 更新或创建节点
|
|
||||||
if (res[id]) {
|
|
||||||
Object.assign(res[id], nodeData);
|
|
||||||
} else {
|
|
||||||
res[id] = { ...nodeData, children: [] };
|
|
||||||
}
|
|
||||||
// 处理父子关系
|
|
||||||
if (res[parentid]) {
|
|
||||||
res[parentid].children.push(res[id]);
|
|
||||||
} else {
|
|
||||||
res[parentid] = { children: [res[id]] };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res[0].children;
|
|
||||||
}
|
|
||||||
function getmenuinfo() {
|
|
||||||
const permissions:any = JSON.parse(localStorage.getItem('permissions'))
|
|
||||||
menuList.value = gettreeData(permissions)
|
|
||||||
runCode()
|
runCode()
|
||||||
}
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
/* 保留原有样式并补充 */
|
/* 保留原有样式并补充 */
|
||||||
|
@ -5,18 +5,9 @@ import { ElMessage, ElMessageBox } from 'element-plus'
|
|||||||
import PermissionSet from '@/views/system/manage/index.vue'
|
import PermissionSet from '@/views/system/manage/index.vue'
|
||||||
import UserInfoSet from '@/views/system/manage/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 dataVisualization from '@/data-visualization/index.vue'
|
import dataVisualization from '@/data-visualization/index.vue'
|
||||||
import FormCreate from '@/views/BuiltInPage/FormCreate.vue'
|
import FormCreate from '@/views/BuiltInPage/FormCreate.vue'
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const props = defineProps({
|
|
||||||
menuList: {
|
|
||||||
type: Array, // 根据实际数据结构调整
|
|
||||||
required: true, // 强制必须传递
|
|
||||||
default: () => [] // 设置安全默认值
|
|
||||||
},
|
|
||||||
applicationId: String,
|
|
||||||
})
|
|
||||||
const navtitle: any = ref('')
|
const navtitle: any = ref('')
|
||||||
const navmenulist: any = ref([
|
const navmenulist: any = ref([
|
||||||
])
|
])
|
||||||
@ -26,15 +17,7 @@ const currentMoudleType = ref('')
|
|||||||
const currentrow: any = ref({})
|
const currentrow: any = ref({})
|
||||||
const userList: any = ref({})
|
const userList: any = ref({})
|
||||||
const showcontent = ref('')
|
const showcontent = ref('')
|
||||||
watch(
|
const applicationId = ref('')
|
||||||
() => props.menuList,
|
|
||||||
(newVal) => {
|
|
||||||
if (newVal) {
|
|
||||||
navmenulist.value = newVal
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ immediate: true } // 立即执行一次
|
|
||||||
)
|
|
||||||
function menuclick(index: any) {
|
function menuclick(index: any) {
|
||||||
if (navmenulist.value[index].children.length == 0 || navmenulist.value[index].children == undefined) {
|
if (navmenulist.value[index].children.length == 0 || navmenulist.value[index].children == undefined) {
|
||||||
checkindex.value = index
|
checkindex.value = index
|
||||||
@ -92,7 +75,7 @@ const TimeDisplay = {
|
|||||||
setup() {
|
setup() {
|
||||||
const currentTime = shallowRef('')
|
const currentTime = shallowRef('')
|
||||||
const currentDate = shallowRef('')
|
const currentDate = shallowRef('')
|
||||||
let timer: number
|
let timer: any
|
||||||
|
|
||||||
function updateTime() {
|
function updateTime() {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
@ -121,10 +104,18 @@ const TimeDisplay = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
navmenulist.value = props.menuList
|
init()
|
||||||
userList.value = JSON.parse(localStorage.getItem('userInfo'))
|
})
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
|
||||||
|
});
|
||||||
|
function init(){
|
||||||
|
userList.value = JSON.parse(localStorage.getItem('userInfo') || '{}')
|
||||||
navtitle.value = userList.value.app_name
|
navtitle.value = userList.value.app_name
|
||||||
const currentInfo:any = JSON.parse(localStorage.getItem('currentInfo'))
|
applicationId.value = userList.id
|
||||||
|
const permissions:any = JSON.parse(localStorage.getItem('permissions')|| '{}')
|
||||||
|
navmenulist.value = gettreeData(permissions)
|
||||||
|
const currentInfo:any = JSON.parse(localStorage.getItem('currentInfo')|| '{}')
|
||||||
if (currentInfo?.showcontent) {
|
if (currentInfo?.showcontent) {
|
||||||
if(currentInfo.showcontent !=='FormCreate' && currentInfo.showcontent !=='dataVisualization'){
|
if(currentInfo.showcontent !=='FormCreate' && currentInfo.showcontent !=='dataVisualization'){
|
||||||
showcontent.value = currentInfo.showcontent
|
showcontent.value = currentInfo.showcontent
|
||||||
@ -141,10 +132,30 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
onBeforeUnmount(() => {
|
function gettreeData(orglist:any) {
|
||||||
|
const res:any = {};
|
||||||
});
|
for (const row of orglist) {
|
||||||
|
// 处理 parentid 并解构需要字段
|
||||||
|
const parentid = row.parentid || "0";
|
||||||
|
const { id, name,code, isdisplay, appId, type,module_id,module_type } = row;
|
||||||
|
// 统一节点数据对象
|
||||||
|
const nodeData = { parentid, id, name,code, isdisplay, appId, type,module_id,module_type }
|
||||||
|
// 更新或创建节点
|
||||||
|
if (res[id]) {
|
||||||
|
Object.assign(res[id], nodeData);
|
||||||
|
} else {
|
||||||
|
res[id] = { ...nodeData, children: [] };
|
||||||
|
}
|
||||||
|
// 处理父子关系
|
||||||
|
if (res[parentid]) {
|
||||||
|
res[parentid].children.push(res[id]);
|
||||||
|
} else {
|
||||||
|
res[parentid] = { children: [res[id]] };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res[0].children;
|
||||||
|
}
|
||||||
function permissionClick() {
|
function permissionClick() {
|
||||||
showcontent.value = 'PermissionSet'
|
showcontent.value = 'PermissionSet'
|
||||||
const currentInfo = {
|
const currentInfo = {
|
||||||
@ -168,8 +179,11 @@ function logout() {
|
|||||||
localStorage.removeItem('userInfo')
|
localStorage.removeItem('userInfo')
|
||||||
localStorage.removeItem('permissions')
|
localStorage.removeItem('permissions')
|
||||||
localStorage.removeItem('currentInfo')
|
localStorage.removeItem('currentInfo')
|
||||||
router.push({
|
const router = useRouter()
|
||||||
path: '/UserLogin',
|
router.push({ path: '/UserLogin' })
|
||||||
|
.catch((err:any) => {
|
||||||
|
console.error("路由跳转失败:", err)
|
||||||
|
// ElMessage.error("跳转失败,请检查路由配置")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(() => { })
|
.catch(() => { })
|
||||||
@ -227,7 +241,7 @@ function userdetails() {
|
|||||||
:busiFlag="currentMoudleType" />
|
:busiFlag="currentMoudleType" />
|
||||||
<FormCreate v-if="showcontent == 'FormCreate'" :appId="currentrow.module_id" />
|
<FormCreate v-if="showcontent == 'FormCreate'" :appId="currentrow.module_id" />
|
||||||
<PermissionSet v-if="showcontent == 'PermissionSet'" :isshowheader="true" />
|
<PermissionSet v-if="showcontent == 'PermissionSet'" :isshowheader="true" />
|
||||||
<UserInfoSet v-if="showcontent == 'UserInfoSet'" :userList="userList" :applicationId="props.applicationId" />
|
<UserInfoSet v-if="showcontent == 'UserInfoSet'" :userList="userList" :applicationId="applicationId" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -5,16 +5,11 @@ import { ElMessage } from 'element-plus'
|
|||||||
import { useRoute, useRouter } from 'vue-router'
|
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 { useUserStore } from '@/store/user'
|
||||||
import { set } from 'lodash'
|
import { set } from 'lodash'
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const props = defineProps({
|
|
||||||
id: String,
|
|
||||||
name: String,
|
|
||||||
isExecuteEvent: Boolean,
|
|
||||||
})
|
|
||||||
const form = ref({
|
const form = ref({
|
||||||
username: '',
|
username: '',
|
||||||
password: ''
|
password: ''
|
||||||
@ -30,41 +25,56 @@ const loginRules = ref({
|
|||||||
const ruleFormRef = ref<FormInstance>()
|
const ruleFormRef = ref<FormInstance>()
|
||||||
const loginTitle: any = ref('')
|
const loginTitle: any = ref('')
|
||||||
const errormsg = ref('')
|
const errormsg = ref('')
|
||||||
|
const doubleClick = ref(false)
|
||||||
const submitForm = async (formEl: FormInstance | undefined) => {
|
const submitForm = async (formEl: FormInstance | undefined) => {
|
||||||
if (props.isExecuteEvent) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!formEl) return
|
if (!formEl) return
|
||||||
await formEl.validate((valid, fields) => {
|
await formEl.validate((valid, fields) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
if (doubleClick.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
doubleClick.value = true
|
||||||
|
localStorage.getItem('userInfo')
|
||||||
|
if (localStorage.getItem('userInfo')) {
|
||||||
|
localStorage.removeItem('userInfo')
|
||||||
|
}
|
||||||
|
if (localStorage.getItem('token')) {
|
||||||
|
localStorage.removeItem('token')
|
||||||
|
}
|
||||||
|
if (localStorage.getItem('permissions')) {
|
||||||
|
localStorage.removeItem('permissions')
|
||||||
|
}
|
||||||
var password = encrypt(form.value.password)
|
var password = encrypt(form.value.password)
|
||||||
const params = {
|
const params = {
|
||||||
username: form.value.username,
|
username: form.value.username,
|
||||||
password: password
|
password: password
|
||||||
}
|
}
|
||||||
userLogin(params).then((res:any) => {
|
userLogin(params).then((res: any) => {
|
||||||
if(res.code == '0'){
|
if (res.code == '0') {
|
||||||
errormsg.value = ''
|
errormsg.value = ''
|
||||||
let userInfo:any = {
|
let userInfo: any = {
|
||||||
nickname: res.data.nickname,
|
nickname: res.data.nickname,
|
||||||
username: res.data.username,
|
username: res.data.username,
|
||||||
id: res.data.userid,
|
id: res.data.userid,
|
||||||
appid:res.data.appid,
|
appid: res.data.appid,
|
||||||
app_name: res.data.app_name
|
app_name: res.data.app_name
|
||||||
}
|
}
|
||||||
localStorage.setItem('userInfo',JSON.stringify(userInfo))
|
localStorage.setItem('userInfo', JSON.stringify(userInfo))
|
||||||
localStorage.setItem('token', res.data.token)
|
localStorage.setItem('token', res.data.token)
|
||||||
localStorage.setItem('permissions', JSON.stringify(res.data.permissions))
|
localStorage.setItem('permissions', JSON.stringify(res.data.permissions))
|
||||||
ElMessage.success('登录成功')
|
ElMessage.success('登录成功')
|
||||||
router.push({
|
router.push({
|
||||||
path: '/AppFrame',
|
path: '/AppFrame',
|
||||||
})
|
})
|
||||||
}else{
|
doubleClick.value = true
|
||||||
|
} else {
|
||||||
errormsg.value = res.msg
|
errormsg.value = res.msg
|
||||||
|
doubleClick.value = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}).catch((err:any) => {
|
}).catch((err: any) => {
|
||||||
errormsg.value = err
|
errormsg.value = err
|
||||||
|
doubleClick.value = true
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -72,7 +82,7 @@ const submitForm = async (formEl: FormInstance | undefined) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loginTitle.value = props.name
|
loginTitle.value = '测试'
|
||||||
})
|
})
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
|
|
||||||
@ -102,7 +112,7 @@ onBeforeUnmount(() => {
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="" prop="password">
|
<el-form-item label="" prop="password">
|
||||||
<div class="logininput">
|
<div class="logininput">
|
||||||
<el-input v-model="form.password" show-password placeholder="请输入密码" type="password">
|
<el-input v-model="form.password" show-password placeholder="请输入密码" type="password" @keyup.enter.native="submitForm(ruleFormRef)">
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
<img src="@/assets/system/password.png" alt="">
|
<img src="@/assets/system/password.png" alt="">
|
||||||
</template>
|
</template>
|
||||||
@ -111,7 +121,7 @@ onBeforeUnmount(() => {
|
|||||||
style="width:100%;height: 1px;" alt="">
|
style="width:100%;height: 1px;" alt="">
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<div style="color:red;margin-top:10px">{{errormsg}}</div>
|
<div style="color:red;margin-top:10px">{{ errormsg }}</div>
|
||||||
<div class="login-button" @click="submitForm(ruleFormRef)">登录</div>
|
<div class="login-button" @click="submitForm(ruleFormRef)">登录</div>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -139,13 +139,7 @@ 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: '1927554158852841473',
|
|
||||||
name: '测试',
|
|
||||||
isExecuteEvent: false
|
|
||||||
})
|
})
|
||||||
// prevApp = Vue.createApp({
|
|
||||||
// render: () => Vue.h(component, dynamicProps.value)
|
|
||||||
// })
|
|
||||||
prevApp = Vue.createApp({
|
prevApp = Vue.createApp({
|
||||||
render: () => Vue.h(component, {
|
render: () => Vue.h(component, {
|
||||||
...dynamicProps.value,
|
...dynamicProps.value,
|
||||||
|
Loading…
Reference in New Issue
Block a user