-
Notifications
You must be signed in to change notification settings - Fork 358
Screen adaptation #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5abbe3d
ad01968
20766c3
0a87879
8ba0d07
51f2318
1d49eb0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,36 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover"/> | ||
| <link rel="apple-touch-icon" href="/pwa-192x192.png" /> | ||
| <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#f6d2d2"> | ||
| <meta name="msapplication-TileColor" content="#f6d2d2"> | ||
| <script> | ||
| ;(function () { | ||
| const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches | ||
| const setting = localStorage.getItem('vueuse-color-scheme') || 'auto' | ||
| if (setting === 'dark' || (prefersDark && setting !== 'light')) | ||
| document.documentElement.classList.toggle('dark', true) | ||
| })() | ||
| </script> | ||
| </head> | ||
| <body> | ||
| <div id="app"></div> | ||
| <script type="module" src="/src/main.ts"></script> | ||
| <noscript> | ||
| This website requires JavaScript to function properly. | ||
| Please enable JavaScript to continue. | ||
| </noscript> | ||
| </body> | ||
| </html> | ||
|
|
||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" /> | ||
| <link rel="apple-touch-icon" href="/pwa-192x192.png" /> | ||
| <link rel="mask-icon" href="/safari-pinned-tab.svg" color="#f6d2d2"> | ||
| <meta name="msapplication-TileColor" content="#f6d2d2"> | ||
| <script> | ||
| ; (function () { | ||
| const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches | ||
| const setting = localStorage.getItem('vueuse-color-scheme') || 'auto' | ||
| if (setting === 'dark' || (prefersDark && setting !== 'light')) | ||
| document.documentElement.classList.toggle('dark', true) | ||
| })() | ||
| </script> | ||
| </head> | ||
|
|
||
| <body> | ||
| <div id="app"></div> | ||
| <script type="module" src="/src/main.ts"></script> | ||
| <noscript> | ||
| This website requires JavaScript to function properly. | ||
| Please enable JavaScript to continue. | ||
| </noscript> | ||
| </body> | ||
|
|
||
| <script> | ||
| let app = document.querySelector('#app') | ||
| window.addEventListener('load', function () { | ||
| app.style.minHeight = window.innerHeight + 'px' | ||
| }) | ||
| </script> | ||
|
|
||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,14 +36,22 @@ const { initializeThemeSwitcher } = useAutoThemeSwitcher(appStore) | |
| onMounted(() => { | ||
| initializeThemeSwitcher() | ||
| }) | ||
|
|
||
| const appSrapperTop = ref('0px') | ||
| const appSrapperHeight = ref('calc( 100% - 0px )') | ||
| const router = useRouter() | ||
| router.beforeEach((to) => { | ||
| to.meta.title !== undefined ? appSrapperTop.value = '46px' : appSrapperTop.value = '0px' | ||
| to.meta.title !== undefined ? appSrapperHeight.value = 'calc( 100% - 46px )' : appSrapperHeight.value = 'calc( 100% - 0px )' | ||
| }) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这段代码块可能不利于后期维护 |
||
| </script> | ||
|
|
||
| <template> | ||
| <VanConfigProvider :theme="mode"> | ||
| <NavBar /> | ||
| <router-view v-slot="{ Component, route }"> | ||
| <transition :name="routeTransitionName"> | ||
| <div :key="route.name" class="app-wrapper"> | ||
| <div :key="route.name" class="app-wrapper" :style="{ top: appSrapperTop, height: appSrapperHeight }"> | ||
| <component :is="Component" /> | ||
| </div> | ||
| </transition> | ||
|
|
@@ -54,9 +62,7 @@ onMounted(() => { | |
| <style scoped> | ||
| .app-wrapper { | ||
| width: 100%; | ||
| height: 100%; | ||
| position: absolute; | ||
| top: 46px; | ||
| left: 0; | ||
| overflow-y: auto; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ const router = useRouter() | |
| </script> | ||
|
|
||
| <template> | ||
| <main p="x4 y16" text-18 text="center gray-300 dark:gray-200"> | ||
| <main p="x4 y62" text-18 text="center gray-300 dark:gray-200"> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里为什么要修改呢
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 在我的PR中,我把没有导航栏的页面 .app-wrapper的top值设为0,所以增加了 404.vue的padding值
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 了解 |
||
| <van-icon name="warn-o" size="3em" /> | ||
|
|
||
| <RouterView /> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,17 +34,19 @@ const menuItems = [ | |
| </script> | ||
|
|
||
| <template> | ||
| <VanCellGroup inset> | ||
| <VanCell center title="🌗 暗黑模式"> | ||
| <template #right-icon> | ||
| <VanSwitch v-model="checked" size="20px" aria-label="on/off Dark Mode" @click="toggle()" /> | ||
| <div class="m-t-46"> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个外层容器也可去掉 |
||
| <VanCellGroup inset> | ||
| <VanCell center title="🌗 暗黑模式"> | ||
| <template #right-icon> | ||
| <VanSwitch v-model="checked" size="20px" aria-label="on/off Dark Mode" @click="toggle()" /> | ||
| </template> | ||
| </VanCell> | ||
|
|
||
| <template v-for="item in menuItems" :key="item.route"> | ||
| <VanCell :title="item.title" :to="item.route" is-link /> | ||
| </template> | ||
| </VanCell> | ||
|
|
||
| <template v-for="item in menuItems" :key="item.route"> | ||
| <VanCell :title="item.title" :to="item.route" is-link /> | ||
| </template> | ||
| </VanCellGroup> | ||
| </VanCellGroup> | ||
| </div> | ||
| </template> | ||
|
|
||
| <route lang="yaml"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| #app { | ||
| min-height: 100vh; | ||
| position: relative; | ||
| overflow-x: hidden; | ||
| overflow-y: scroll; | ||
| } | ||
|
|
||
| html { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不建议在应用入口处设置监听事件