Skip to content

Commit d97cc52

Browse files
super update! add UI for desktop
1 parent b7bd3a9 commit d97cc52

File tree

5 files changed

+43
-10
lines changed

5 files changed

+43
-10
lines changed

src/css/app.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ input{
77
}
88
pre{
99
background: #0d1117!important;
10-
}
10+
}
11+
.q-page-container{
12+
margin-top:0!important;
13+
}

src/layouts/ChatLayout.vue

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</q-card>
3333
</q-dialog>
3434

35-
<q-drawer show-if-above bordered v-model="leftDrawerOpen">
35+
<q-drawer bordered v-model="leftDrawerOpen">
3636
<div class="bg-primary column" v-if="store.info">
3737
<div class="q-pa-lg">
3838
<q-avatar @click="router.push('/avatar')" v-if="store.info" size="60px"><img
@@ -81,7 +81,11 @@
8181

8282
</q-drawer>
8383

84-
<q-page-container>
84+
<q-page-container style="display: flex">
85+
<q-page-container :class="{'is-mobile':store.isMobile,half:!store.isMobile}" class="no-padding" style="background: #fff">
86+
<router-view name="fakeSidebar"></router-view>
87+
</q-page-container>
88+
<q-page-container style="flex:1" :class="{half:!store.isMobile}" class="no-padding">
8589
<router-view v-slot="{ Component }">
8690
<transition
8791
enter-active-class="animated fadeInRight"
@@ -90,23 +94,30 @@
9094
</transition>
9195
</router-view>
9296
</q-page-container>
97+
</q-page-container>
9398
</q-layout>
9499
</template>
95100

96101
<script setup>
97102
import {useCheckStore} from 'stores/check';
98103
99104
const $q = useQuasar()
105+
watch(
106+
() => $q.screen.width,
107+
(newWidth) => {
108+
store.isMobile = newWidth < 400
109+
}
110+
)
100111
const setColor = () => {
101112
document.querySelector(':root').style.setProperty('--q-primary', hexa.value);
102113
pickerShow.value = false;
103114
store.info.color = hexa.value;
104115
$q.localStorage.set('info', store.info);
105116
}
106-
117+
console.log($q.screen)
107118
import {useRoute} from 'vue-router'
108119
import {useQuasar} from 'quasar'
109-
import {ref} from 'vue';
120+
import {ref, watch} from 'vue';
110121
import {useRouter} from 'vue-router';
111122
112123
const route = useRoute();
@@ -120,6 +131,12 @@ const settings = () => {
120131
}
121132
const leftDrawerOpen = ref(false);
122133
134+
watch(route, (newRoute) => {
135+
if (newRoute.path.includes('person')) {
136+
leftDrawerOpen.value = false
137+
}
138+
})
139+
123140
function toggleLeftDrawer() {
124141
leftDrawerOpen.value = !leftDrawerOpen.value
125142
}
@@ -150,4 +167,12 @@ try {
150167
</script>
151168

152169
<style scoped lang="scss">
170+
.is-mobile{
171+
display: none;
172+
}
173+
.half{
174+
max-width: 50vw;
175+
overflow: hidden;
176+
}
177+
153178
</style>

src/pages/ChatPage.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
<!-- class="q-pa-md q-mb-xl">-->
1010
<div class=" q-pa-md q-mb-xl">
1111
<q-chat-message v-for="(item, i) in store.history[route.params.id]" :key="i"
12-
:avatar="store.avatar(<number>item.sender == route.params.id ? yourAvatar : myAvatar)"
12+
:avatar="store.avatar(item.sender === route.params.id ? yourAvatar : myAvatar)"
1313
:bg-color="`${item.sender == route.params.id ? 'white' : 'info'}`" :text="[item.content]"
1414
:stamp="item.time"
1515
:sent="item.sender != route.params.id"/>
1616
</div>
17-
<div class="row fixed bg-white window-width" style="bottom:0">
17+
<div class="row fixed bg-white" :class="store.isMobile?'window-width':'half-width'" style="bottom:0">
1818
<q-input borderless v-model="message" placeholder="Message" style="flex:1" class="q-px-md"
1919
@keyup.enter="sendMessage()"></q-input>
2020
<q-btn @click="sendMessage()" flat :disable="!message.length">
@@ -151,4 +151,7 @@ const sendMessage = async () => {
151151
background: center repeat;
152152
background-size: 420px auto;
153153
}
154+
.half-width{
155+
width: 50vw;
156+
}
154157
</style>

src/router/routes.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { RouteRecordRaw } from 'vue-router';
2-
2+
import ListPage from 'pages/ListPage.vue';
3+
import ChatPage from 'pages/ChatPage.vue';
34
const routes: RouteRecordRaw[] = [
45
{
56
path: '/file',
@@ -11,7 +12,7 @@ const routes: RouteRecordRaw[] = [
1112
path: '/chat',
1213
component: () => import('layouts/ChatLayout.vue'),
1314
children: [{ path: '/chat', component: () => import('pages/ListPage.vue') },
14-
{ path: '/chat/person/:id', component: () => import('pages/ChatPage.vue') },
15+
{ path: '/chat/person/:id', components: {fakeSidebar:ListPage,default:ChatPage} },
1516
{ path: '/chat/newfriends', component: () => import('pages/NewFriends.vue') }]
1617
},
1718
{

src/stores/check.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const useCheckStore = defineStore('check', () => {
99
const info = ref({})
1010
const order = ref({})
1111
const avatarList = ['O1kmMD', 'O1ky0I', 'O1kvZ1', 'O1kZBG', 'O1k1Hv', 'O1kn1Y', 'O1kiMU', 'O1kF0p', 'O1kzKj', 'O1kMKK', 'O1bw5s', 'O1b3fB', 'O1bIpg', 'O1bukl', 'O1b88b', 'O1b6DP', 'O1b2n6', 'O1b9wF', 'O1blSD', 'O1bfAI', 'O1bY51', 'O1bsYG', 'O1bdpM', 'O1bckr', 'O1bS6c', 'O1bQDq', 'O1bGnv', 'O1bLCY', 'O1bHSU', 'O1bDAp', 'O1b4qj', 'O1bRYx']
12+
const isMobile=ref(true)
1213
const avatar=(n:number)=>{
1314
const str = avatarList[n];
1415
return `https://ooo.0x0.ooo/2023/10/03/${str}.webp`
@@ -36,7 +37,7 @@ export const useCheckStore = defineStore('check', () => {
3637
}
3738
setInterval(update, 500)
3839

39-
return { history,info,order,avatar }
40+
return { history,info,order,avatar,isMobile }
4041
// state: () => ({
4142
// history:{}
4243
// }),

0 commit comments

Comments
 (0)