移动端适配

This commit is contained in:
李志鹏
2026-05-28 11:05:51 +08:00
parent d404f5ceac
commit 6415523eef
12 changed files with 125 additions and 21 deletions

View File

@@ -50,8 +50,11 @@
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
const { locale } = useI18n() const { locale } = useI18n()
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { useGlobalStore } from '@/stores/global'
import { useUserInfoStore } from '@/stores/userInfo' import { useUserInfoStore } from '@/stores/userInfo'
const userInfoStore = useUserInfoStore() const userInfoStore = useUserInfoStore()
const globalStore = useGlobalStore()
const windowWidth = computed(() => globalStore.state.windowWidth)
const token = computed(() => userInfoStore.state.token) const token = computed(() => userInfoStore.state.token)
const route = useRoute() const route = useRoute()
const lang = computed(() => route.params.lang) const lang = computed(() => route.params.lang)
@@ -125,17 +128,6 @@
path: '/contact-us' path: '/contact-us'
} }
]) ])
const windowWidth = ref(1920)
const resize = () => {
windowWidth.value = window.innerWidth
}
onMounted(() => {
resize()
window.addEventListener('resize', resize)
})
onBeforeUnmount(() => {
window.removeEventListener('resize', resize)
})
const mainMenuDialogRef = ref() const mainMenuDialogRef = ref()
const openMainMenu = () => { const openMainMenu = () => {

View File

@@ -27,12 +27,13 @@
<style scoped lang="less"> <style scoped lang="less">
.contact-us { .contact-us {
--bg-height: 514px;
> * { > * {
position: relative; position: relative;
z-index: 1; z-index: 1;
} }
> .bg { > .bg {
height: 514px; height: var(--bg-height);
width: 100%; width: 100%;
object-fit: cover; object-fit: cover;
position: fixed; position: fixed;
@@ -40,7 +41,7 @@
z-index: 0; z-index: 0;
} }
> .header { > .header {
height: 514px; height: var(--bg-height);
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
@@ -84,5 +85,22 @@
max-width: 860px; max-width: 860px;
} }
} }
@media (max-width: 800px) {
--bg-height: 239px;
> .header {
> h1 {
font-size: 40px;
margin-bottom: 20px;
}
}
> .contact {
> .iconfont {
font-size: 36px;
}
}
> .contact-input {
padding: 60px 20px;
}
}
} }
</style> </style>

View File

@@ -113,12 +113,13 @@
<style scoped lang="less"> <style scoped lang="less">
.media { .media {
--bg-height: 464px;
> * { > * {
position: relative; position: relative;
z-index: 1; z-index: 1;
} }
> .bg { > .bg {
height: 464px; height: var(--bg-height);
width: 100%; width: 100%;
object-fit: cover; object-fit: cover;
position: fixed; position: fixed;
@@ -126,7 +127,7 @@
z-index: 0; z-index: 0;
} }
> .header { > .header {
height: 464px; height: var(--bg-height);
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
@@ -140,10 +141,11 @@
> .content { > .content {
width: 100%; width: 100%;
padding: 100px 0; padding: 100px 0;
background-color: #fff; background-color: #f9f9f9;
font-size: 14px; font-size: 14px;
> .box { > .box {
max-width: 1140px; max-width: 1140px;
padding: 0 20px;
margin: 0 auto; margin: 0 auto;
> .nav { > .nav {
display: flex; display: flex;
@@ -174,5 +176,31 @@
} }
} }
} }
@media (max-width: 800px) {
--bg-height: 239px;
> .content {
padding: 30px 0;
> .box {
> .nav {
margin-bottom: 20px;
}
> .list {
padding: 0;
> div {
> .date {
min-width: 0;
width: 25%;
margin-right: 10px;
color: #999;
flex-shrink: 0;
}
> .text {
color: #222;
}
}
}
}
}
}
} }
</style> </style>

View File

@@ -111,5 +111,16 @@
> .content { > .content {
flex: 1; flex: 1;
} }
@media (max-width: 800px) {
flex-direction: column;
> .left {
width: 100%;
border: none;
margin-bottom: 20px;
>.info{
text-align: center;
}
}
}
} }
</style> </style>

View File

@@ -16,11 +16,19 @@
.register > form > * { .register > form > * {
margin-bottom: 20px; margin-bottom: 20px;
} }
.login > form .link,
.register > form .link {
color: #222;
}
.login > form > .form-item, .login > form > .form-item,
.register > form > .form-item { .register > form > .form-item {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.login > form > .form-item.center,
.register > form > .form-item.center {
align-items: center;
}
.login > form > .form-item > label, .login > form > .form-item > label,
.register > form > .form-item > label { .register > form > .form-item > label {
margin-bottom: 5px; margin-bottom: 5px;
@@ -87,7 +95,6 @@
.login > form > .remember > .link, .login > form > .remember > .link,
.register > form > .remember > .link { .register > form > .remember > .link {
margin-left: auto; margin-left: auto;
color: #222;
} }
.login > form > .subscribe, .login > form > .subscribe,
.register > form > .subscribe { .register > form > .subscribe {

View File

@@ -48,7 +48,7 @@
> .content { > .content {
max-width: 1200px; max-width: 1200px;
margin: 0 auto; margin: 0 auto;
padding-bottom: 80px; padding: 0 15px 80px;
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
gap: 60px; gap: 60px;
@@ -57,5 +57,14 @@
} }
animation: opacity-in 0.3s linear both; animation: opacity-in 0.3s linear both;
} }
@media (max-width: 800px) {
> .content {
flex-direction: column;
gap: 30px;
> * {
width: 100%;
}
}
}
} }
</style> </style>

View File

@@ -17,10 +17,19 @@
margin-bottom: 20px; margin-bottom: 20px;
} }
.link {
color: #222;
}
>.form-item { >.form-item {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
&.center {
align-items: center;
}
>label { >label {
margin-bottom: 5px; margin-bottom: 5px;
font-size: 16px; font-size: 16px;
@@ -83,7 +92,6 @@
>.link { >.link {
margin-left: auto; margin-left: auto;
color: #222;
} }
} }

View File

@@ -26,20 +26,26 @@
<div class="remember"> <div class="remember">
<input type="checkbox" id="remember" name="remember" v-model="remember" /> <input type="checkbox" id="remember" name="remember" v-model="remember" />
<label for="remember">Remember me</label> <label for="remember">Remember me</label>
<router-link class="link" to="/my-account/lost-password" <router-link class="link" to="/my-account/lost-password" v-show="windowWidth > 800"
>Lost your password?</router-link >Lost your password?</router-link
> >
</div> </div>
<button type="submit" custom>LOG IN</button> <button type="submit" custom>LOG IN</button>
<div class="form-item center">
<router-link class="link" to="/my-account/lost-password" v-show="windowWidth <= 800"
>Lost your password?</router-link
>
</div>
</form> </form>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { ref, computed } from 'vue'
import { useGlobalStore } from '@/stores/global' import { useGlobalStore } from '@/stores/global'
const globalStore = useGlobalStore() const globalStore = useGlobalStore()
import { useUserInfoStore } from '@/stores/userInfo' import { useUserInfoStore } from '@/stores/userInfo'
const userInfoStore = useUserInfoStore() const userInfoStore = useUserInfoStore()
const windowWidth = computed(() => globalStore.state.windowWidth)
const passShow = ref(false) const passShow = ref(false)
const remember = ref(false) const remember = ref(false)
const fromData = ref({ const fromData = ref({

View File

@@ -58,5 +58,10 @@
margin-bottom: 20px; margin-bottom: 20px;
} }
} }
@media (max-width: 800px) {
> .content {
padding: 50px 15px;
}
}
} }
</style> </style>

View File

@@ -38,5 +38,8 @@
text-transform: none; text-transform: none;
color: #ffffff; color: #ffffff;
} }
@media (max-width: 800px) {
padding: 25px 0;
}
} }
</style> </style>

View File

@@ -93,5 +93,18 @@
} }
} }
} }
@media (max-width: 800px) {
> .content {
flex-direction: column;
padding: 70px 90px;
> div {
padding: 0;
margin-bottom: 30px;
> div {
margin-bottom: 30px;
}
}
}
}
} }
</style> </style>

View File

@@ -3,6 +3,7 @@ import { ref, computed } from 'vue'
export const useGlobalStore = defineStore('global', () => { export const useGlobalStore = defineStore('global', () => {
const state = ref({ const state = ref({
loading: false,// 全局loading loading: false,// 全局loading
windowWidth: window.innerWidth,// 页面宽度
}) })
const setLoading = (v: boolean) => { state.value.loading = v } const setLoading = (v: boolean) => { state.value.loading = v }
@@ -12,3 +13,6 @@ export const useGlobalStore = defineStore('global', () => {
setLoading, setLoading,
} }
}) })
window.addEventListener('resize', () => {
useGlobalStore().state.windowWidth = window.innerWidth
})