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

View File

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

View File

@ -89,6 +89,21 @@ export function deepClone(obj: any) {
return newObj; 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 * @method elSvg element plus svg
@ -96,6 +111,7 @@ export function deepClone(obj: any) {
* @method lazyImg * @method lazyImg
* @method globalComponentSize element plus * @method globalComponentSize element plus
* @method deepClone * @method deepClone
* @method isMobile
*/ */
const other = { const other = {
elSvg: (app: App) => { elSvg: (app: App) => {
@ -113,6 +129,9 @@ const other = {
deepClone: (obj: any) => { deepClone: (obj: any) => {
deepClone(obj); deepClone(obj);
}, },
isMobile: () => {
return isMobile();
},
}; };
// 统一批量导出 // 统一批量导出