Skip to content

Commit b3bbe13

Browse files
red point
1 parent d97cc52 commit b3bbe13

File tree

5 files changed

+43
-31
lines changed

5 files changed

+43
-31
lines changed

src/components/EditorComponent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<mavon-editor :codeStyle=codeStyle :externalLink="externalLink" :ishljs="true" :autofocus="false" placeholder=" "
2+
<mavon-editor :subfield="false" defaultOpen="preview" :codeStyle=codeStyle :externalLink="externalLink" :ishljs="true" :autofocus="false" placeholder=" "
33
:toolbars="toolbars" />
44
</template>
55

src/layouts/ChatLayout.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ const $q = useQuasar()
105105
watch(
106106
() => $q.screen.width,
107107
(newWidth) => {
108-
store.isMobile = newWidth < 400
108+
if (route.path.includes('login')||route.path.includes('signup')||route.path.includes('avatar')||route.path.includes('file'))
109+
store.isMobile=true;
110+
else
111+
store.isMobile = newWidth < 450
109112
}
110113
)
111114
const setColor = () => {

src/pages/EditorPage.vue

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</div>
1111
<div class="row">
1212
<div class="q-pa-md q-gutter-sm">
13-
<q-tree v-if="final" ref="treeObj" :nodes="final" node-key="key" style="min-width: 27vw;max-width: 27vw;"
13+
<q-tree v-if="final" ref="treeObj" :nodes="final" node-key="key"
1414
selected-color="primary" v-model:selected="key" @update:selected="select(key)" default-expand-all/>
1515
</div>
1616
<div class="container">
@@ -63,9 +63,9 @@ const touch=()=>{
6363
showLoaderOnConfirm: true,
6464
preConfirm: (login) => {
6565
commandReq(5, selectFolder.value+login,'').then(res => {
66-
if (res.data === 'success') Swal.fire('Success', '', 'success').then(() => {
66+
if (res.data.code === 200) Swal.fire('Success', '', 'success').then(() => {
6767
commandReq(0, '', '').then(res => {
68-
tree(res.data);
68+
tree(JSON.parse(res.data.message));
6969
})
7070
})
7171
else Swal.fire('Fail', '', 'error')
@@ -89,10 +89,10 @@ const addFolder = () => {
8989
showLoaderOnConfirm: true,
9090
preConfirm: (login) => {
9191
commandReq(4, selectFolder.value+login,'').then(res => {
92-
if (res.data === 'success') Swal.fire('Success', '', 'success').then(() => {
92+
if (res.data.code === 200) Swal.fire('Success', '', 'success').then(() => {
9393
9494
commandReq(0, '', '').then(res => {
95-
tree(res.data);
95+
tree(JSON.parse(res.data.message));
9696
})
9797
})
9898
else Swal.fire('Fail', '', 'error')
@@ -119,7 +119,7 @@ const deleteFile = () => {
119119
Swal.fire('Success', '', 'success').then(()=>{
120120
121121
commandReq(0, '', '').then(res => {
122-
tree(res.data);
122+
tree(JSON.parse(res.data.message));
123123
})
124124
})
125125
})
@@ -165,13 +165,13 @@ const select = (key) => {
165165
selectFile.value = selectNode.value.label;
166166
selectFolder.value = selectFolder.value === selectFile.value ? selectNode.value.path+'/' :selectNode.value.path.slice(0, selectNode.value.path.length - selectFile.value.length - 1) ;
167167
commandReq(6, selectNode.value.path, '').then(res => {
168-
content.value = res.data.toString();
168+
content.value = res.data.message.toString();
169169
})
170170
}
171171
}
172172
onMounted(() => {
173173
commandReq(0, '', '').then(res => {
174-
tree(res.data);
174+
tree(JSON.parse(res.data.message));
175175
})
176176
})
177177
const tree = (res) => {
@@ -259,14 +259,14 @@ const paste = (n) => {
259259
copyed.value = false;
260260
261261
commandReq(0, '', '').then(res => {
262-
tree(res.data);
262+
tree(JSON.parse(res.data.message));
263263
})
264264
} else {
265265
commandReq(2, movefile.value, selectFolder.value);
266266
moved.value = false;
267267
268268
commandReq(0, '', '').then(res => {
269-
tree(res.data);
269+
tree(JSON.parse(res.data.message));
270270
})
271271
272272
}
@@ -299,17 +299,19 @@ const imgAdd = (pos, file) => {
299299
'content-type': 'multipart/form-data'
300300
}
301301
}).then((res) => {
302-
const url = `http://8.130.48.157:8081/api/file/get?filename=${res.data}`;
302+
const url = `http://8.130.48.157:8081/api/file/get?filename=${res.data.message}`;
303303
content.value = content.value.replace(/!\[[^\]]+\]\([^)]+\)/, `![](${url})`);
304304
})
305305
}
306306
307307
</script>
308308

309309
<style lang="scss" scoped>
310+
.container{
311+
flex:1;
312+
}
310313
.content {
311314
padding: 24px;
312-
313315
.box {
314316
padding: 24px;
315317
border: 1px solid #e3e6e8;

src/pages/ListPage.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<q-page class="column" v-if="list">
33
<div class="person items-center relative-position" v-for="(person, i) in list" :key="i" v-ripple.early>
4-
<div class="row items-center" @click="router.push(`/chat/person/${person.username}`)"
4+
<div class="row items-center" @click="store.unread[person.username]=0;router.push(`/chat/person/${person.username}`)"
55
v-touch-hold.mouse="handleHold"
66
:style="`width: 100vw;background-color:${selected===person.username?'gainsboro':'none'};`">
77
<q-avatar class="q-ma-md"><img :src="store.avatar(person.avatar)" alt=""></q-avatar>
@@ -10,8 +10,11 @@
1010
class="q-mb-sm">{{ person.username }}</span><span
1111
class="text-grey q-mr-md"
1212
v-if="store.history[person.username]">{{ time(store.history[person.username].at(-1).time) }}</span></div>
13+
<div class="row justify-between">
1314
<span v-if="store.history[person.username]"
1415
style="color:#808080">{{ store.history[person.username].at(-1).content }}</span>
16+
<div style="background: red;border-radius: 100px" class="q-px-sm text-white q-mr-md" v-if="store.unread[person.username]">{{store.unread[person.username]}}</div>
17+
</div>
1518
</div>
1619
</div>
1720
<q-separator/>

src/stores/check.ts

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,47 @@
1-
import { defineStore } from 'pinia';
2-
import { ref} from 'vue'
1+
import {defineStore} from 'pinia';
2+
import {ref} from 'vue'
33
import axios from 'axios'
4-
5-
import { LocalStorage } from 'quasar'
4+
import {LocalStorage, Screen} from 'quasar'
65

76
export const useCheckStore = defineStore('check', () => {
7+
const isMobile = ref((window.location.href.includes('login') || window.location.href.includes('signup') || window.location.href.includes('avatar') || window.location.href.includes('file')) ? true : Screen.width < 450)
88
const history = ref({})
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)
13-
const avatar=(n:number)=>{
12+
const unread = ref({});
13+
const avatar = (n: number) => {
1414
const str = avatarList[n];
1515
return `https://ooo.0x0.ooo/2023/10/03/${str}.webp`
1616
}
1717
const update = () => {
18-
if(window.location.pathname!=='/login'&&window.location.pathname!=='/signup')
19-
axios.post('http://8.130.48.157:8081/api/check?type=new','' ,{
18+
if (window.location.pathname !== '/login' && window.location.pathname !== '/signup')
19+
axios.post('http://8.130.48.157:8081/api/check?type=new', '', {
2020

21-
headers: {
22-
Authorization: `Bearer ${LocalStorage.getItem('token')}`
23-
}}
21+
headers: {
22+
Authorization: `Bearer ${LocalStorage.getItem('token')}`
23+
}
24+
}
2425
)
25-
.then(res => {
26-
if(res.data.message!==null){
26+
.then(res => {
27+
if (res.data.message !== null) {
2728
const key = Object.keys(res.data.message)[0];
2829
if (!history.value[key]) history.value[key] = [];
2930
history.value[key] = [...history.value[key], ...res.data.message[key]];
31+
if (!unread.value[key])
32+
unread.value[key] = 0;
33+
unread.value[key]+=res.data.message[key].length;
3034
LocalStorage.set('history', history.value)
31-
if(!order.value) order.value = {};
35+
if (!order.value) order.value = {};
3236
if (!(key in order.value)) order.value[key] = [];
3337
order.value[key] = res.data.message[key][0].time
3438
LocalStorage.set('order', order.value)
3539
}
36-
})
40+
})
3741
}
3842
setInterval(update, 500)
3943

40-
return { history,info,order,avatar,isMobile }
44+
return {history, info, order, avatar, isMobile, unread}
4145
// state: () => ({
4246
// history:{}
4347
// }),

0 commit comments

Comments
 (0)