v3.17.0 【新增】新增菜单展开1个配置;【新增】移除表格固定高度;【新增】App登录token模式

This commit is contained in:
zhuoda
2025-04-08 20:21:07 +08:00
parent 87354b38d4
commit b0addda9e9
20 changed files with 95 additions and 57 deletions

View File

@@ -52,7 +52,7 @@
import { themeColors } from '/@/theme/color.js';
import { Popover } from 'ant-design-vue';
import SmartCopyIcon from '/@/components/framework/smart-copy-icon/index.vue';
import _ from 'lodash';
const slots = useSlots();
const antdLocale = computed(() => messages[useAppConfigStore().language].antdLocale);
const dayjsLocale = computed(() => messages[useAppConfigStore().language].dayjsLocale);
@@ -90,6 +90,9 @@
return text;
}
}
window.addEventListener('resize',_.throttle(()=>{
window.location.reload()
},1000));
</script>
<style scoped lang="less">
:deep(.ant-table-column-sorters) {

View File

@@ -14,8 +14,6 @@ export const appDefaultConfig = {
layout: 'side',
// 侧边菜单宽度 默认为200px
sideMenuWidth: 200,
// 表格高度
tableYHeight: 300,
//标签页位置
pageTagLocation: 'center',
// 菜单主题
@@ -26,6 +24,8 @@ export const appDefaultConfig = {
pageWidth: '99%',
// 圆角
borderRadius: 6,
// 展开模式
flatPattern: true,
// 标签页
pageTagFlag: true,
// 标签页样式: default、 antd、chrome

View File

@@ -24,6 +24,7 @@ export default {
'setting.border.radius': 'Border Radius',
'setting.compact': 'Page Compact',
'setting.bread': 'Show Bread',
'setting.flatPattern': 'Flat Pattern',
'setting.pagetag': 'Show PageTag',
'setting.pagetag.style': 'PageTag Style',
'setting.footer': 'Show Footer',

View File

@@ -24,6 +24,7 @@ export default {
'setting.border.radius': '页面圆角',
'setting.page.width': '页面宽度',
'setting.bread': '面包屑',
'setting.flatPattern': '展开模式',
'setting.pagetag': '标签页',
'setting.pagetag.style': '标签页样式',
'setting.footer': '页脚',

View File

@@ -47,10 +47,6 @@
<a-input-number @change="changeSideMenuWidth" v-model:value="formState.sideMenuWidth" :min="1" />
像素px
</a-form-item>
<a-form-item :label="$t('setting.table.yHeight')">
<a-input-number @change="changeTableYHeight" v-model:value="formState.tableYHeight" :min="100" />
像素px
</a-form-item>
<a-form-item :label="$t('setting.page.width')" v-if="formState.layout === LAYOUT_ENUM.TOP.value">
<a-input @change="changePageWidth" v-model:value="formState.pageWidth" />
像素px或者 百分比
@@ -87,6 +83,9 @@
<a-radio-button value="chrome">Chrome</a-radio-button>
</a-radio-group>
</a-form-item>
<a-form-item :label="$t('setting.flatPattern')">
<a-switch @change="changeFlatPattern" v-model:checked="formState.flatPattern" checked-children="单个" un-checked-children="多个" />
</a-form-item>
<a-form-item :label="$t('setting.pagetag')">
<a-switch @change="changePageTagFlag" v-model:checked="formState.pageTagFlag" checked-children="显示" un-checked-children="隐藏" />
</a-form-item>
@@ -202,8 +201,6 @@
colorIndex: appConfigStore.colorIndex,
// 侧边菜单宽度
sideMenuWidth: appConfigStore.sideMenuWidth,
// 表格高度
tableYHeight: appConfigStore.tableYHeight,
// 菜单主题
sideMenuTheme: appConfigStore.sideMenuTheme,
// 页面紧凑
@@ -212,6 +209,8 @@
borderRadius: appConfigStore.borderRadius,
// 标签页
pageTagFlag: appConfigStore.pageTagFlag,
// 标签页
flatPattern: appConfigStore.flatPattern,
// 标签页 样式
pageTagStyle: appConfigStore.pageTagStyle,
// 面包屑
@@ -276,12 +275,6 @@
sideMenuWidth: value,
});
}
function changeTableYHeight(value) {
appConfigStore.$patch({
tableYHeight: value,
});
window.location.reload();
}
function changePageWidth(e) {
appConfigStore.$patch({
@@ -317,6 +310,11 @@
pageTagFlag: e,
});
}
function changeFlatPattern(e) {
appConfigStore.$patch({
flatPattern: e,
});
}
function changePageTagStyle(e) {
appConfigStore.$patch({

View File

@@ -8,7 +8,7 @@
* @Copyright 1024创新实验室 https://1024lab.net Since 2012
-->
<template>
<a-menu v-model:openKeys="openKeys" v-model:selectedKeys="selectedKeys" class="smart-menu" mode="inline" :theme="theme">
<a-menu :open-keys="openKeys" v-model:selectedKeys="selectedKeys" class="smart-menu" mode="inline" :theme="theme" @openChange="onOpenChange">
<template v-for="item in menuTree" :key="item.menuId">
<template v-if="item.visibleFlag && !item.disabledFlag">
<template v-if="$lodash.isEmpty(item.children)">
@@ -36,6 +36,7 @@
import { useUserStore } from '/@/store/modules/system/user';
const theme = computed(() => useAppConfigStore().$state.sideMenuTheme);
const flatPattern = computed(() => useAppConfigStore().$state.flatPattern);
const props = defineProps({
collapsed: {
@@ -45,6 +46,8 @@
});
const menuTree = computed(() => useUserStore().getMenuTree || []);
const rootSubmenuKeys = computed(()=>menuTree.value.map(item=>item.menuId));
//展开的菜单
let currentRoute = useRoute();
@@ -89,7 +92,17 @@
immediate: true,
}
);
function onOpenChange(openKeysParams){
if(flatPattern.value){
return;
}
const latestOpenKey = openKeysParams.find(key => openKeys.value.indexOf(key) === -1);
if (rootSubmenuKeys.value.indexOf(latestOpenKey) === -1) {
openKeys.value = openKeysParams;
} else {
openKeys.value = latestOpenKey ? [latestOpenKey] : [];
}
};
defineExpose({
updateOpenKeysAndSelectKeys,
});

View File

@@ -62,7 +62,7 @@
:url="item.meta.frameUrl"
/>
<!--非iframe使用router-view-->
<div v-show="!iframeNotKeepAlivePageFlag && keepAliveIframePages.every((e) => route.name != e.name)">
<div v-show="!iframeNotKeepAlivePageFlag && keepAliveIframePages.every((e) => route.name != e.name)" style="height: 100%;">
<router-view v-slot="{ Component }">
<keep-alive :include="keepAliveIncludes">
<component :is="Component" :key="route.name" />

View File

@@ -99,17 +99,10 @@ async function initVue() {
//挂载
app.mount('#app');
}
function setTableYHeight() {
Table.props.scroll.default = {
y: useAppConfigStore().tableYHeight,
};
}
//不需要获取用户信息、用户菜单、用户菜单动态路由直接初始化vue即可
let token = localRead(LocalStorageKeyConst.USER_TOKEN);
if (!token) {
await initVue();
setTableYHeight();
} else {
await getLoginInfo();
setTableYHeight();
}

View File

@@ -102,7 +102,7 @@
:dataSource="tableData"
:columns="columns"
rowKey="goodsId"
:scroll="{ x: 1000 }"
:scroll="{ x: 1000,y: yHeight }"
bordered
:pagination="false"
:showSorterTooltip="false"
@@ -205,6 +205,7 @@
import SmartHeaderCell from '/@/components/support/table-header-cell/index.vue';
import { DICT_CODE_ENUM } from '/@/constants/support/dict-const.js';
import DictLabel from '/@/components/support/dict-label/index.vue';
import { onBeforeMount } from 'vue';
// ---------------------------- 表格列 ----------------------------
@@ -497,4 +498,16 @@
function camelToUnderscore(str) {
return str.replace(/([A-Z])/g, '_$1').toLowerCase();
}
const dueHeight=ref(0)
const yHeight=ref(0)
onMounted(() => {
let doc = document.querySelector('.ant-form');
let btn = document.querySelector('.smart-table-btn-block');
let tableCell = document.querySelector('.ant-table-cell');
let page = document.querySelector('.smart-query-table-page');
let box = document.querySelector('.ant-layout-content>div');
dueHeight.value = doc.offsetHeight+10+24+btn.offsetHeight+15+tableCell.offsetHeight+page.offsetHeight+20
yHeight.value=box.offsetHeight-dueHeight.value
});
</script>

View File

@@ -52,6 +52,7 @@
import { themeColors } from '/@/theme/color.js';
import { Popover } from 'ant-design-vue';
import SmartCopyIcon from '/@/components/framework/smart-copy-icon/index.vue';
import _ from 'lodash';
const slots = useSlots();
const antdLocale = computed(() => messages[useAppConfigStore().language].antdLocale);
@@ -90,6 +91,9 @@
return text;
}
}
window.addEventListener('resize',_.throttle(()=>{
window.location.reload()
},1000));
</script>
<style scoped lang="less">
:deep(.ant-table-column-sorters) {

View File

@@ -20,8 +20,6 @@ export const appDefaultConfig: AppConfig = {
layout: 'side',
// 侧边菜单宽度 默认为200px
sideMenuWidth: 200,
// 表格高度
tableYHeight: 300,
//标签页位置
pageTagLocation: 'center',
// 菜单主题
@@ -32,6 +30,8 @@ export const appDefaultConfig: AppConfig = {
pageWidth: '99%',
// 圆角
borderRadius: 6,
// 展开模式
flatPattern: true,
// 标签页
pageTagFlag: true,
// 标签页样式: default、 antd、chrome

View File

@@ -24,6 +24,7 @@ export default {
'setting.border.radius': 'Border Radius',
'setting.compact': 'Page Compact',
'setting.bread': 'Show Bread',
'setting.flatPattern': 'Flat Pattern',
'setting.pagetag': 'Show PageTag',
'setting.pagetag.style': 'PageTag Style',
'setting.footer': 'Show Footer',

View File

@@ -24,6 +24,7 @@ export default {
'setting.border.radius': '页面圆角',
'setting.page.width': '页面宽度',
'setting.bread': '面包屑',
'setting.flatPattern': '展开模式',
'setting.pagetag': '标签页',
'setting.pagetag.style': '标签页样式',
'setting.footer': '页脚',

View File

@@ -47,10 +47,6 @@
<a-input-number @change="changeSideMenuWidth" v-model:value="formState.sideMenuWidth" :min="1" />
像素px
</a-form-item>
<a-form-item :label="$t('setting.table.yHeight')">
<a-input-number @change="changeTableYHeight" v-model:value="formState.tableYHeight" :min="100" />
像素px
</a-form-item>
<a-form-item :label="$t('setting.page.width')" v-if="formState.layout === LAYOUT_ENUM.TOP.value">
<a-input @change="changePageWidth" v-model:value="formState.pageWidth" />
像素px或者 百分比
@@ -87,6 +83,9 @@
<a-radio-button value="chrome">Chrome</a-radio-button>
</a-radio-group>
</a-form-item>
<a-form-item :label="$t('setting.flatPattern')">
<a-switch @change="changeFlatPattern" v-model:checked="formState.flatPattern" checked-children="单个" un-checked-children="多个" />
</a-form-item>
<a-form-item :label="$t('setting.pagetag')">
<a-switch @change="changePageTagFlag" v-model:checked="formState.pageTagFlag" checked-children="显示" un-checked-children="隐藏" />
</a-form-item>
@@ -202,8 +201,6 @@
colorIndex: appConfigStore.colorIndex,
// 侧边菜单宽度
sideMenuWidth: appConfigStore.sideMenuWidth,
// 表格高度
tableYHeight: appConfigStore.tableYHeight,
// 菜单主题
sideMenuTheme: appConfigStore.sideMenuTheme,
// 页面紧凑
@@ -211,6 +208,8 @@
// 页面圆角
borderRadius: appConfigStore.borderRadius,
// 标签页
flatPattern: appConfigStore.flatPattern,
// 标签页
pageTagFlag: appConfigStore.pageTagFlag,
// 标签页 样式
pageTagStyle: appConfigStore.pageTagStyle,
@@ -276,12 +275,6 @@
sideMenuWidth: value,
});
}
function changeTableYHeight(value: any) {
appConfigStore.$patch({
tableYHeight: value,
});
window.location.reload();
}
function changePageWidth(e) {
appConfigStore.$patch({
@@ -317,6 +310,11 @@
pageTagFlag: e,
});
}
function changeFlatPattern(e) {
appConfigStore.$patch({
flatPattern: e,
});
}
function changePageTagStyle(e) {
appConfigStore.$patch({

View File

@@ -8,7 +8,7 @@
* @Copyright 1024创新实验室 https://1024lab.net Since 2012
-->
<template>
<a-menu v-model:openKeys="openKeys" v-model:selectedKeys="selectedKeys" class="smart-menu" mode="inline" :theme="theme">
<a-menu :open-keys="openKeys" v-model:selectedKeys="selectedKeys" class="smart-menu" mode="inline" :theme="theme" @openChange="onOpenChange">
<template v-for="item in menuTree" :key="item.menuId">
<template v-if="item.visibleFlag && !item.disabledFlag">
<template v-if="$lodash.isEmpty(item.children)">
@@ -36,6 +36,7 @@
import { useUserStore } from '/@/store/modules/system/user';
const theme = computed(() => useAppConfigStore().$state.sideMenuTheme);
const flatPattern = computed(() => useAppConfigStore().$state.flatPattern);
const props = defineProps({
collapsed: {
@@ -45,6 +46,7 @@
});
const menuTree = computed(() => useUserStore().getMenuTree || []);
const rootSubmenuKeys = computed(()=>menuTree.value.map(item=>item.menuId));
//展开的菜单
let currentRoute = useRoute();
@@ -89,7 +91,17 @@
immediate: true,
}
);
function onOpenChange(openKeysParams){
if(flatPattern.value){
return;
}
const latestOpenKey = openKeysParams.find(key => openKeys.value.indexOf(key) === -1);
if (rootSubmenuKeys.value.indexOf(latestOpenKey) === -1) {
openKeys.value = openKeysParams;
} else {
openKeys.value = latestOpenKey ? [latestOpenKey] : [];
}
};
defineExpose({
updateOpenKeysAndSelectKeys,
});

View File

@@ -62,7 +62,7 @@
:url="item.meta.frameUrl"
/>
<!--非iframe使用router-view-->
<div v-show="!iframeNotKeepAlivePageFlag && keepAliveIframePages.every((e) => route.name != e.name)">
<div v-show="!iframeNotKeepAlivePageFlag && keepAliveIframePages.every((e) => route.name != e.name)" style="height: 100%;">
<router-view v-slot="{ Component }">
<keep-alive :include="keepAliveIncludes">
<component :is="Component" :key="route.name" />

View File

@@ -99,17 +99,10 @@ async function initVue() {
//挂载
app.mount('#app');
}
function setTableYHeight() {
Table.props.scroll.default = {
y: useAppConfigStore().tableYHeight,
};
}
//不需要获取用户信息、用户菜单、用户菜单动态路由直接初始化vue即可
let token = localRead(LocalStorageKeyConst.USER_TOKEN);
if (!token) {
await initVue();
setTableYHeight();
} else {
await getLoginInfo();
setTableYHeight();
}

View File

@@ -32,8 +32,6 @@ export interface AppConfig {
layout: string;
// 主题
sideMenuTheme: ThemeType;
// 表格高度
tableYHeight: number;
//标签页位置
pageTagLocation: string;
// 侧边菜单宽度 默认为256px

View File

@@ -102,7 +102,7 @@
:dataSource="tableData"
:columns="columns"
rowKey="goodsId"
:scroll="{ x: 1000 }"
:scroll="{ x: 1000,y: yHeight }"
bordered
:pagination="false"
:showSorterTooltip="false"
@@ -110,8 +110,6 @@
@change="onChange"
@resizeColumn="handleResizeColumn"
>
<!-- main.js中有全局表格高度配置也可单独配置 -->
<!-- :scroll="{ y: 300 }" -->
<template #headerCell="{ column }">
<SmartHeaderCell v-model:value="queryForm[column.filterOptions?.key || column.dataIndex]" :column="column" @change="queryData" />
</template>
@@ -497,4 +495,15 @@
function camelToUnderscore(str) {
return str.replace(/([A-Z])/g, '_$1').toLowerCase();
}
const dueHeight=ref(0)
const yHeight=ref(0)
onMounted(() => {
let doc = document.querySelector('.ant-form');
let btn = document.querySelector('.smart-table-btn-block');
let tableCell = document.querySelector('.ant-table-cell');
let page = document.querySelector('.smart-query-table-page');
let box = document.querySelector('.ant-layout-content>div');
dueHeight.value = doc.offsetHeight+10+24+btn.offsetHeight+15+tableCell.offsetHeight+page.offsetHeight+20
yHeight.value=box.offsetHeight-dueHeight.value
});
</script>

View File

@@ -67,7 +67,7 @@ export const request = function (url, method, data) {
data: data,
method: method,
header: {
'x-access-token': getUserToken(),
'Authorization':'Bearer ' + getUserToken(),
},
success: (response) => {
handleResponse(response, resolve, reject);
@@ -110,7 +110,7 @@ export const uploadRequest = function (filePath, folder) {
url: baseUrl + '/support/file/upload',
filePath,
header: {
'x-access-token': getUserToken(),
'Authorization':'Bearer ' + getUserToken(),
},
name: 'file',
formData: {