mirror of
https://github.com/1024-lab/smart-admin.git
synced 2025-09-02 02:44:58 +00:00
优化代码
This commit is contained in:
@@ -46,14 +46,15 @@
|
||||
|
||||
//监听退出登录方法
|
||||
async function onLogout() {
|
||||
localClear();
|
||||
clearAllCoolies();
|
||||
useUserStore().logout();
|
||||
try {
|
||||
await loginApi.logout();
|
||||
} catch (e) {
|
||||
smartSentry.captureError(e);
|
||||
} finally {
|
||||
|
||||
localClear();
|
||||
clearAllCoolies();
|
||||
useUserStore().logout();
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@
|
||||
<template #icon>
|
||||
<component :is="$antIcons[item.icon]" />
|
||||
</template>
|
||||
{{ item.menuName }}
|
||||
{{ menuNameAdapter(item.menuName) }}
|
||||
</a-menu-item>
|
||||
</template>
|
||||
</template>
|
||||
@@ -64,6 +64,11 @@
|
||||
return parentMenuList.value.map((e) => e.name);
|
||||
});
|
||||
|
||||
// 展开菜单的顶级目录名字适配,只展示两个字为好
|
||||
function menuNameAdapter(name){
|
||||
return name.substr(0,2);
|
||||
}
|
||||
|
||||
//监听路由的变化,进行更新菜单展开项目
|
||||
watch(
|
||||
currentRoute,
|
||||
|
@@ -77,34 +77,34 @@
|
||||
// ------------------ 意见反馈 --------------------------
|
||||
let feedbackMessageList = ref([]);
|
||||
onMounted(() => {
|
||||
// 默认先查询一次
|
||||
// 首先查询多一些意见反馈
|
||||
queryFeedbackList();
|
||||
scroll();
|
||||
// 更换显示
|
||||
scheduleShowFeedback();
|
||||
});
|
||||
|
||||
let scrollInterval = null;
|
||||
let swiper = 1;
|
||||
let scheduleShowInterval = null;
|
||||
let scheduleShowIndex = 0;
|
||||
|
||||
function scroll() {
|
||||
if (scrollInterval != null) {
|
||||
function scheduleShowFeedback() {
|
||||
if (scheduleShowInterval != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
scrollInterval = setInterval(() => {
|
||||
if (currentPage >= pages) {
|
||||
currentPage = 1;
|
||||
}
|
||||
if (pages == 0 || feedbackList.length == 0) {
|
||||
scheduleShowInterval = setInterval(() => {
|
||||
if (feedbackList.length == 0) {
|
||||
return;
|
||||
}
|
||||
let initValue = (currentPage - 1) * 2;
|
||||
feedbackMessageList.value[0] = feedbackList[initValue];
|
||||
if (feedbackList[initValue + 1]) {
|
||||
feedbackMessageList.value[1] = feedbackList[initValue + 1];
|
||||
|
||||
// 显示两条意见反馈
|
||||
for (let i = 0; i < 2; i++) {
|
||||
if (scheduleShowIndex >= feedbackList.length) {
|
||||
scheduleShowIndex = 0;
|
||||
}
|
||||
feedbackMessageList.value[i] = feedbackList[scheduleShowIndex];
|
||||
scheduleShowIndex++;
|
||||
}
|
||||
swiper = currentPage - 1;
|
||||
currentPage++;
|
||||
}, 2000);
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
// 总页数
|
||||
@@ -121,7 +121,7 @@
|
||||
};
|
||||
let result = await feedbackApi.queryFeedback(param);
|
||||
feedbackList = result.data.list;
|
||||
pages = Math.ceil(result.data.total / 2);
|
||||
pages = Math.ceil(feedbackList.length / 2);
|
||||
} catch (e) {
|
||||
smartSentry.captureError(e);
|
||||
}
|
||||
@@ -143,9 +143,9 @@
|
||||
//SmartAdmin中 router的name 就是 后端存储menu的id
|
||||
let menuId = -1;
|
||||
try {
|
||||
if(currentRoute.name === HOME_PAGE_NAME){
|
||||
if (currentRoute.name === HOME_PAGE_NAME) {
|
||||
menuId = 0;
|
||||
}else{
|
||||
} else {
|
||||
menuId = _.toNumber(currentRoute.name);
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -163,7 +163,7 @@
|
||||
|
||||
<style scoped lang="less">
|
||||
.help-doc-wrapper {
|
||||
border-left:1px solid #ededed;
|
||||
border-left: 1px solid #ededed;
|
||||
height: 100vh;
|
||||
padding: 0 10px;
|
||||
|
||||
|
@@ -103,6 +103,17 @@
|
||||
const helpDocFlag = computed(() => useAppConfigStore().$state.helpDocFlag);
|
||||
// 是否显示页脚
|
||||
const footerFlag = computed(() => useAppConfigStore().$state.footerFlag);
|
||||
// 多余高度
|
||||
const dueHeight = computed(() => {
|
||||
let due = 40;
|
||||
if (useAppConfigStore().$state.pageTagFlag) {
|
||||
due = due + 40;
|
||||
}
|
||||
if (useAppConfigStore().$state.footerFlag) {
|
||||
due = due + 40;
|
||||
}
|
||||
return due;
|
||||
});
|
||||
//是否隐藏菜单
|
||||
const collapsed = ref(false);
|
||||
|
||||
@@ -222,10 +233,11 @@
|
||||
}
|
||||
|
||||
.admin-layout-content {
|
||||
background-color: inherit;
|
||||
min-height: auto;
|
||||
position: relative;
|
||||
padding: 10px 10px 0px 10px;
|
||||
height: v-bind('pageTagFlag ? "calc(100% - 80px)": "calc(100% - 40px)"');
|
||||
height: calc(100% - v-bind(dueHeight)px);
|
||||
overflow-x: hidden;
|
||||
}
|
||||
}
|
||||
|
@@ -97,6 +97,17 @@
|
||||
const helpDocFlag = computed(() => useAppConfigStore().$state.helpDocFlag);
|
||||
// 是否显示页脚
|
||||
const footerFlag = computed(() => useAppConfigStore().$state.footerFlag);
|
||||
// 多余高度
|
||||
const dueHeight = computed(() => {
|
||||
let due = 40;
|
||||
if (useAppConfigStore().$state.pageTagFlag) {
|
||||
due = due + 40;
|
||||
}
|
||||
if (useAppConfigStore().$state.footerFlag) {
|
||||
due = due + 40;
|
||||
}
|
||||
return due;
|
||||
});
|
||||
//是否隐藏菜单
|
||||
const collapsed = ref(false);
|
||||
|
||||
@@ -223,11 +234,12 @@
|
||||
}
|
||||
|
||||
.admin-layout-content {
|
||||
background-color: inherit;
|
||||
min-height: auto;
|
||||
position: relative;
|
||||
overflow-x: hidden;
|
||||
padding: 10px 10px 0px 10px;
|
||||
height: v-bind('pageTagFlag ? "calc(100% - 80px)": "calc(100% - 40px)"');
|
||||
height: calc(100% - v-bind(dueHeight)px);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 计算表格自适应高度
|
||||
*
|
||||
* @param {*} heightRef
|
||||
* @param {*} removeRefArray
|
||||
* @param {*} extraRemoveHeight
|
||||
* @returns
|
||||
*/
|
||||
|
||||
import { useAppConfigStore } from '../store/modules/system/app-config';
|
||||
|
||||
export function calcTableHeight(heightRef, removeRefArray, extraRemoveHeight) {
|
||||
let removeHeight = 0;
|
||||
if (removeRefArray && removeRefArray.length > 0) {
|
||||
for (const item of removeRefArray) {
|
||||
removeHeight = removeHeight + item.value.$el.offsetHeight;
|
||||
}
|
||||
}
|
||||
|
||||
let due = 40;
|
||||
if (useAppConfigStore().$state.pageTagFlag) {
|
||||
due = due + 40;
|
||||
}
|
||||
if (useAppConfigStore().$state.footerFlag) {
|
||||
due = due + 40;
|
||||
}
|
||||
|
||||
removeHeight = removeHeight + extraRemoveHeight + due;
|
||||
heightRef.value = document.querySelector('#smartAdminLayoutContent').offsetHeight - removeHeight;
|
||||
}
|
@@ -27,12 +27,6 @@ import { useUserStore } from '/@/store/modules/system/user';
|
||||
import '/@/theme/index.less';
|
||||
import { getTokenFromCookie } from '/@/utils/cookie-util';
|
||||
|
||||
let url = location.href;
|
||||
if(url.indexOf('1024lab.net') > -1){
|
||||
location.href = "https://preview.smartadmin.vip";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* -------------------- ※ 着重 解释说明下main.js的初始化逻辑 begin ※ --------------------
|
||||
*
|
||||
|
@@ -8,7 +8,7 @@
|
||||
* @Copyright 1024创新实验室 ( https://1024lab.net ),Since 2012
|
||||
-->
|
||||
<template>
|
||||
<a-form class="smart-query-form" v-privilege="'loginLog:query'">
|
||||
<a-form class="smart-query-form" v-privilege="'loginLog:query'" ref="queryFormRef">
|
||||
<a-row class="smart-query-form-row">
|
||||
<a-form-item label="用户名称" class="smart-query-form-item">
|
||||
<a-input style="width: 300px" v-model:value="queryForm.userName" placeholder="用户名称" />
|
||||
@@ -40,10 +40,19 @@
|
||||
</a-form>
|
||||
|
||||
<a-card size="small" :bordered="false" :hoverable="true">
|
||||
<a-row justify="end">
|
||||
<a-row justify="end" ref="tableOperatorRef">
|
||||
<TableOperator class="smart-margin-bottom5" v-model="columns" :tableId="TABLE_ID_CONST.SUPPORT.LOGIN_LOG" :refresh="ajaxQuery" />
|
||||
</a-row>
|
||||
<a-table size="small" :dataSource="tableData" :columns="columns" bordered rowKey="loginLogId" :pagination="false" :loading="tableLoading">
|
||||
<a-table
|
||||
size="small"
|
||||
:dataSource="tableData"
|
||||
:columns="columns"
|
||||
bordered
|
||||
rowKey="loginLogId"
|
||||
:pagination="false"
|
||||
:loading="tableLoading"
|
||||
:scroll="{ y: scrollY }"
|
||||
>
|
||||
<template #bodyCell="{ text, record, column }">
|
||||
<template v-if="column.dataIndex === 'loginResult'">
|
||||
<template v-if="text === LOGIN_RESULT_ENUM.LOGIN_SUCCESS.value">
|
||||
@@ -85,7 +94,7 @@
|
||||
</a-card>
|
||||
</template>
|
||||
<script setup>
|
||||
import { onMounted, reactive, ref } from 'vue';
|
||||
import { onMounted, onUnmounted, reactive, ref } from 'vue';
|
||||
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
|
||||
import { defaultTimeRanges } from '/@/lib/default-time-ranges';
|
||||
import uaparser from 'ua-parser-js';
|
||||
@@ -94,6 +103,7 @@
|
||||
import { smartSentry } from '/@/lib/smart-sentry';
|
||||
import TableOperator from '/@/components/support/table-operator/index.vue';
|
||||
import { TABLE_ID_CONST } from '/@/constants/support/table-id-const';
|
||||
import { calcTableHeight } from '/@/lib/table-auto-height';
|
||||
|
||||
const columns = ref([
|
||||
{
|
||||
@@ -190,5 +200,23 @@
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(ajaxQuery);
|
||||
// ----------------- 表格自适应高度 --------------------
|
||||
const scrollY = ref(100);
|
||||
const tableOperatorRef = ref();
|
||||
const queryFormRef = ref();
|
||||
|
||||
function autoCalcTableHeight() {
|
||||
calcTableHeight(scrollY, [tableOperatorRef, queryFormRef], 10);
|
||||
}
|
||||
|
||||
window.addEventListener('resize', autoCalcTableHeight);
|
||||
|
||||
onMounted(() => {
|
||||
ajaxQuery();
|
||||
autoCalcTableHeight();
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', autoCalcTableHeight);
|
||||
});
|
||||
</script>
|
||||
|
@@ -201,6 +201,9 @@
|
||||
try {
|
||||
params.departmentId = props.departmentId;
|
||||
let res = await employeeApi.queryEmployee(params);
|
||||
for (const item of res.data.list) {
|
||||
item.roleNameList = _.join(item.roleNameList,',');
|
||||
}
|
||||
tableData.value = res.data.list;
|
||||
total.value = res.data.total;
|
||||
// 清除选中
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<!--
|
||||
* 菜单 表单 树形下拉框
|
||||
*
|
||||
* @Author: 1024创新实验室-主任:卓大
|
||||
* @Date: 2022-06-12 20:11:39
|
||||
* @Wechat: zhuda1024
|
||||
* @Email: lab1024@163.com
|
||||
* @Copyright 1024创新实验室 ( https://1024lab.net ),Since 2012
|
||||
*
|
||||
* @Author: 1024创新实验室-主任:卓大
|
||||
* @Date: 2022-06-12 20:11:39
|
||||
* @Wechat: zhuda1024
|
||||
* @Email: lab1024@163.com
|
||||
* @Copyright 1024创新实验室 ( https://1024lab.net ),Since 2012
|
||||
-->
|
||||
<template>
|
||||
<a-tree-select
|
||||
@@ -18,6 +18,7 @@
|
||||
placeholder="请选择菜单"
|
||||
allow-clear
|
||||
tree-default-expand-all
|
||||
treeNodeFilterProp="menuName"
|
||||
@change="treeSelectChange"
|
||||
/>
|
||||
</template>
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<!--
|
||||
* 菜单 表单 树形下拉框
|
||||
*
|
||||
* @Author: 1024创新实验室-主任:卓大
|
||||
* @Date: 2022-06-12 20:11:39
|
||||
* @Wechat: zhuda1024
|
||||
* @Email: lab1024@163.com
|
||||
* @Copyright 1024创新实验室 ( https://1024lab.net ),Since 2012
|
||||
*
|
||||
* @Author: 1024创新实验室-主任:卓大
|
||||
* @Date: 2022-06-12 20:11:39
|
||||
* @Wechat: zhuda1024
|
||||
* @Email: lab1024@163.com
|
||||
* @Copyright 1024创新实验室 ( https://1024lab.net ),Since 2012
|
||||
-->
|
||||
<template>
|
||||
<a-tree-select
|
||||
@@ -18,6 +18,7 @@
|
||||
placeholder="请选择菜单"
|
||||
allow-clear
|
||||
tree-default-expand-all
|
||||
treeNodeFilterProp="menuName"
|
||||
@change="treeSelectChange"
|
||||
/>
|
||||
</template>
|
||||
|
Reference in New Issue
Block a user