fix: 修复控制台的一些警告问题

Former-commit-id: 3fcbd5494858f5af98c64ad6ab8294a7772e69e0
This commit is contained in:
郝先瑞
2022-05-26 00:50:23 +08:00
parent 7669dc66ed
commit fd742634a4
6 changed files with 14 additions and 11 deletions

View File

@@ -15,6 +15,7 @@
"@wangeditor/editor-for-vue": "^5.1.10", "@wangeditor/editor-for-vue": "^5.1.10",
"axios": "^0.24.0", "axios": "^0.24.0",
"better-scroll": "^2.4.2", "better-scroll": "^2.4.2",
"default-passive-events": "^2.0.0",
"echarts": "^5.2.2", "echarts": "^5.2.2",
"element-plus": "^2.1.8", "element-plus": "^2.1.8",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
@@ -40,12 +41,12 @@
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^8.6.0", "eslint-plugin-vue": "^8.6.0",
"fast-glob": "^3.2.11",
"husky": "^7.0.4", "husky": "^7.0.4",
"prettier": "^2.6.2", "prettier": "^2.6.2",
"sass": "^1.43.4", "sass": "^1.43.4",
"typescript": "^4.5.4", "typescript": "^4.5.4",
"vite": "^2.9.7", "vite": "^2.9.7",
"fast-glob": "^3.2.11",
"vite-plugin-svg-icons": "^2.0.1", "vite-plugin-svg-icons": "^2.0.1",
"vue-tsc": "^0.34.7" "vue-tsc": "^0.34.7"
}, },

View File

@@ -58,7 +58,7 @@ watch(show, value => {
}); });
function addEventClick() { function addEventClick() {
window.addEventListener('click', closeSidebar); window.addEventListener('click', closeSidebar, {passive:true});
} }
function closeSidebar(evt: any) { function closeSidebar(evt: any) {

View File

@@ -35,7 +35,7 @@ const visitedViews = computed(() => tagsView.visitedViews);
const scrollWrapper = computed(() => proxy?.$refs.scrollContainer.$refs.wrap$); const scrollWrapper = computed(() => proxy?.$refs.scrollContainer.$refs.wrap$);
onMounted(() => { onMounted(() => {
scrollWrapper.value.addEventListener('scroll', emitScroll, true) scrollWrapper.value.addEventListener('scroll', emitScroll, {passive:true})
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {
scrollWrapper.value.removeEventListener('scroll', emitScroll) scrollWrapper.value.removeEventListener('scroll', emitScroll)
@@ -81,8 +81,7 @@ function moveToTarget(currentTag: TagView) {
) { ) {
prevTag = tagListDom[k]; prevTag = tagListDom[k];
} }
if ( if ((tagListDom[k] as any).dataset.path ===
(tagListDom[k] as any).dataset.path ===
visitedViews.value[currentIndex + 1].path visitedViews.value[currentIndex + 1].path
) { ) {
nextTag = tagListDom[k]; nextTag = tagListDom[k];

View File

@@ -8,6 +8,7 @@
<router-link <router-link
v-for="tag in visitedViews" v-for="tag in visitedViews"
:key="tag.path" :key="tag.path"
:data-path="tag.path"
:class="isActive(tag) ? 'active' : ''" :class="isActive(tag) ? 'active' : ''"
:to="{ path: tag.path, query: tag.query, fullPath: tag.fullPath }" :to="{ path: tag.path, query: tag.query, fullPath: tag.fullPath }"
class="tags-view__item" class="tags-view__item"
@@ -64,8 +65,7 @@ import {
nextTick, nextTick,
ref, ref,
watch, watch,
onMounted, onMounted
ComponentInternalInstance
} from 'vue'; } from 'vue';
import path from 'path-browserify'; import path from 'path-browserify';
@@ -80,7 +80,7 @@ import useStore from '@/store';
const { tagsView, permission } = useStore(); const { tagsView, permission } = useStore();
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as any;
const router = useRouter(); const router = useRouter();
const route = useRoute(); const route = useRoute();
@@ -108,7 +108,7 @@ watch(
watch(visible, value => { watch(visible, value => {
if (value) { if (value) {
document.body.addEventListener('click', closeMenu); document.body.addEventListener('click', closeMenu, {passive:true});
} else { } else {
document.body.removeEventListener('click', closeMenu); document.body.removeEventListener('click', closeMenu);
} }

View File

@@ -9,6 +9,8 @@ import 'element-plus/theme-chalk/index.css';
import Pagination from '@/components/Pagination/index.vue'; import Pagination from '@/components/Pagination/index.vue';
import '@/permission'; import '@/permission';
import 'default-passive-events'
// 引入svg注册脚本 // 引入svg注册脚本
import 'virtual:svg-icons-register'; import 'virtual:svg-icons-register';

View File

@@ -16,7 +16,7 @@ export default function () {
}; };
const initResizeEvent = () => { const initResizeEvent = () => {
window.addEventListener('resize', chartResizeHandler); window.addEventListener('resize', chartResizeHandler, {passive:true});
}; };
const destroyResizeEvent = () => { const destroyResizeEvent = () => {
@@ -28,7 +28,8 @@ export default function () {
if (sidebarElm.value) { if (sidebarElm.value) {
sidebarElm.value.addEventListener( sidebarElm.value.addEventListener(
'transitionend', 'transitionend',
sidebarResizeHandler as EventListener sidebarResizeHandler as EventListener,
{passive:true}
); );
} }
}; };