'admin-21.12.17:修复tagsView拖拽问题,感谢@简单爱、'

This commit is contained in:
lyt 2021-12-17 20:19:11 +08:00
parent ec5911a987
commit 18ef20b230
3 changed files with 34 additions and 10 deletions

View File

@ -201,10 +201,10 @@
<el-switch v-model="getThemeConfig.isCacheTagsView" @change="setLocalThemeConfig"></el-switch>
</div>
</div>
<div class="layout-breadcrumb-seting-bar-flex mt15">
<div class="layout-breadcrumb-seting-bar-flex mt15" :style="{ opacity: isMobile ? 0.5 : 1 }">
<div class="layout-breadcrumb-seting-bar-flex-label">{{ $t('message.layout.fourIsSortableTagsView') }}</div>
<div class="layout-breadcrumb-seting-bar-flex-value">
<el-switch v-model="getThemeConfig.isSortableTagsView" @change="onSortableTagsViewChange"></el-switch>
<el-switch v-model="getThemeConfig.isSortableTagsView" :disabled="isMobile ? true : false" @change="onSortableTagsViewChange"></el-switch>
</div>
</div>
<div class="layout-breadcrumb-seting-bar-flex mt15">
@ -381,19 +381,23 @@
</template>
<script lang="ts">
import { nextTick, onUnmounted, onMounted, getCurrentInstance, defineComponent, computed } from 'vue';
import { nextTick, onUnmounted, onMounted, getCurrentInstance, defineComponent, computed, reactive, toRefs } from 'vue';
import { useStore } from '/@/store/index';
import { getLightColor } from '/@/utils/theme';
import { verifyAndSpace } from '/@/utils/toolsValidate';
import { Local } from '/@/utils/storage';
import Watermark from '/@/utils/wartermark';
import commonFunction from '/@/utils/commonFunction';
import other from '/@/utils/other';
export default defineComponent({
name: 'layoutBreadcrumbSeting',
setup() {
const { proxy } = getCurrentInstance() as any;
const store = useStore();
const { copyText } = commonFunction();
const state = reactive({
isMobile: false,
});
//
const getThemeConfig = computed(() => {
return store.state.themeConfig.themeConfig;
@ -613,6 +617,7 @@ export default defineComponent({
getThemeConfig.value.isDrawer = false;
initLayoutChangeFun();
onMenuBarHighlightChange();
state.isMobile = other.isMobile();
});
setTimeout(() => {
// 退()
@ -661,6 +666,7 @@ export default defineComponent({
onShareTagsViewChange,
onCopyConfigClick,
onResetConfigClick,
...toRefs(state),
};
},
});

View File

@ -49,6 +49,7 @@ import { ElMessage } from 'element-plus';
import { useStore } from '/@/store/index';
import { Session } from '/@/utils/storage';
import { isObjectValueEqual } from '/@/utils/arrayOperation';
import other from '/@/utils/other';
import Contextmenu from '/@/layout/navBars/tagsView/contextmenu.vue';
export default {
name: 'layoutTagsView',
@ -397,10 +398,10 @@ export default {
});
};
// tagsView
const initSortable = () => {
const initSortable = async () => {
const el = document.querySelector('.layout-navbars-tagsview-ul') as HTMLElement;
if (!el) return false;
state.sortable && state.sortable.destroy();
state.sortable.el && state.sortable.destroy();
state.sortable = Sortable.create(el, {
animation: 300,
dataIdAttr: 'data-url',
@ -417,11 +418,9 @@ export default {
});
};
// https://gitee.com/lyt-top/vue-next-admin/issues/I3ZRRI
const onSortableResize = () => {
const clientWidth = document.body.clientWidth;
if (clientWidth < 1000) getThemeConfig.value.isSortableTagsView = false;
else getThemeConfig.value.isSortableTagsView = true;
initSortable();
const onSortableResize = async () => {
await initSortable();
if (other.isMobile()) state.sortable.el && state.sortable.destroy();
};
//
onBeforeMount(() => {

View File

@ -89,6 +89,21 @@ export function deepClone(obj: any) {
return newObj;
}
/**
*
*/
export function isMobile() {
if (
navigator.userAgent.match(
/('phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone')/i
)
) {
return true;
} else {
return false;
}
}
/**
*
* @method elSvg element plus svg
@ -96,6 +111,7 @@ export function deepClone(obj: any) {
* @method lazyImg
* @method globalComponentSize element plus
* @method deepClone
* @method isMobile
*/
const other = {
elSvg: (app: App) => {
@ -113,6 +129,9 @@ const other = {
deepClone: (obj: any) => {
deepClone(obj);
},
isMobile: () => {
return isMobile();
},
};
// 统一批量导出