Skip to content

Commit

Permalink
fix: 修复无法滚动
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Jan 17, 2024
1 parent ea410b5 commit c8a5949
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store-front-end",
"version": "2.14.70",
"version": "2.14.71",
"private": true,
"scripts": {
"dev": "vite --host",
Expand Down
16 changes: 16 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ import { createApp } from 'vue';
import App from './App.vue';

export function initializeApp() {
// 创建一个回调函数来处理变化
const callback = function(mutationsList, observer) {
for(let mutation of mutationsList) {
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
if (document.body.classList.contains('nut-overflow-hidden')) {
document.body.classList.remove('nut-overflow-hidden');
}
}
}
};

// 创建一个观察器实例,将回调函数作为参数
const observer = new MutationObserver(callback);

// 开始观察`body`元素上的`class`属性的变化
observer.observe(document.body, { attributes: true });
const pinia = createPinia();
const app = createApp(App);

Expand Down
10 changes: 9 additions & 1 deletion src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,16 @@ const router = createRouter({
});

// 全局前置守卫
// router.afterEach(async to => {
// if (/\/edit\/(collections|subs)\/UNTITLED/.test(to.fullPath)) {
// (document.querySelector('#app') as HTMLElement).style.height = '100%';
// } else {
// (document.querySelector('#app') as HTMLElement).style.height = '';
// }
// return true;
// });
router.beforeResolve(async to => {
document.body.classList.remove('nut-overflow-hidden');
// document.body.classList.remove('nut-overflow-hidden');
// 路由跳转时查询环境,决定是否更新数据
if (globalStore !== null) {
useEnvApi()
Expand Down

0 comments on commit c8a5949

Please sign in to comment.