Skip to content

Commit c74bef9

Browse files
authored
Merge pull request #14 from misterpancn/feature-develop-buck
Feature develop buck
2 parents c797c64 + 9b6bb46 commit c74bef9

File tree

20 files changed

+289
-68
lines changed

20 files changed

+289
-68
lines changed

README.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,10 @@ npm run lint
3030
```
3131

3232
#### Config Setup
33-
```javascript
34-
const config = {
35-
serviceAddress: 'localhost.com', // websocket service
36-
websocketPort: 1234, // ws port
37-
connectLimit: 10,
38-
openssl: false,
39-
apiVersion: 'prs.dingo.v1',
40-
allMbPrefix: []
41-
}
42-
export default config
33+
```bash
34+
# setup config file
35+
cd src/renderer/store/config
36+
cp config.js.example config.js
4337
```
4438

4539
---

build/icons/256x256.png

-26.2 KB
Loading

build/icons/icon.icns

-447 KB
Binary file not shown.

build/icons/icon.ico

32 KB
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "VueChat",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"author": "[email protected]",
55
"description": "An electron-vue project",
66
"private": true,

src/main/index.js

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ function createWindow () {
2727
* Initial window options
2828
*/
2929
mainWindow = new BrowserWindow({
30-
height: 350,
31-
useContentSize: true,
32-
width: 540,
30+
height: config.windowSize.login.height,
31+
// useContentSize: true,
32+
width: config.windowSize.login.width,
3333
show: false
3434
})
3535

@@ -43,13 +43,20 @@ function createWindow () {
4343
mainWindow.once('ready-to-show', () => {
4444
mainWindow.show()
4545
})
46-
winModal = new BrowserWindow({ parent: mainWindow, modal: true, useContentSize: true, frame: false, show: false, alwaysOnTop: true })
46+
winModal = new BrowserWindow({
47+
parent: mainWindow,
48+
modal: true,
49+
useContentSize: true,
50+
frame: false,
51+
show: false,
52+
alwaysOnTop: true
53+
})
4754
winModal.loadURL(winModalURL)
4855
winModal.on('closed', () => {
4956
winModal = null
5057
})
5158
mainWindow.on('close', (e) => {
52-
if (!exit) {
59+
if (!exit && isShowExitNotify()) {
5360
e.preventDefault()
5461
dialog.showMessageBox(mainWindow, {
5562
type: 'warning',
@@ -67,6 +74,17 @@ function createWindow () {
6774
})
6875
}
6976
})
77+
const { session } = require('electron')
78+
79+
session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
80+
let c = {
81+
responseHeaders: {
82+
...details.responseHeaders,
83+
'Content-Security-Policy': config.contentSecurityPolicy ? config.contentSecurityPolicy : ['default-src \'self\' \'unsafe-inline\' \'unsafe-eval\' data:']
84+
}
85+
}
86+
callback(c)
87+
})
7088
handleUpdate()
7189
}
7290

@@ -86,6 +104,7 @@ app.on('activate', () => {
86104

87105
ipcMain.on('change-win-size', (e, args) => {
88106
mainWindow.setSize(args.width, args.height)
107+
mainWindow.center()
89108
})
90109
ipcMain.on('show-win-notify', (e, args) => {
91110
if (!mainWindow.isFocused()) {
@@ -95,6 +114,7 @@ ipcMain.on('show-win-notify', (e, args) => {
95114
ipcMain.on('show-win-model', (e, args) => {
96115
winModal.setSize(args.width, args.height)
97116
winModal.show()
117+
winModal.center()
98118
winModal.webContents.send('send-win-modal-img', args.src)
99119
})
100120
ipcMain.on('hide-win-modal', (e, args) => {
@@ -138,3 +158,14 @@ function handleUpdate () {
138158
autoUpdater.quitAndInstall()
139159
})
140160
}
161+
162+
function isShowExitNotify () {
163+
let size = mainWindow.getSize();
164+
if (size[0] === config.windowSize.login.width && size[1] === config.windowSize.login.height) {
165+
return false;
166+
}
167+
if (size[0] === config.windowSize.register.width && size[1] === config.windowSize.register.height) {
168+
return false;
169+
}
170+
return true;
171+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<script>
2+
import axios from '@/request'
3+
export default {
4+
data () {
5+
return {
6+
group: {}
7+
}
8+
},
9+
computed: {
10+
show: {
11+
get: function () {
12+
if (this.$store.getters.getGroupUserShow) {
13+
this.$Spin.hide();
14+
axios.getGroupMember(this.groupId).then((r) => {
15+
this.group = r.data.data
16+
})
17+
}
18+
return this.$store.getters.getGroupUserShow
19+
},
20+
set: function (val) {
21+
this.$store.dispatch('setGroupUserShow', val)
22+
}
23+
},
24+
groupId () {
25+
return this.$store.getters.selectId
26+
},
27+
user () {
28+
return this.$store.getters.getUser
29+
}
30+
},
31+
methods: {
32+
getUserInfo (uid) {
33+
if (uid === this.user.userId) {
34+
this.$Message.warning({
35+
content: this.$t('notify.thisIsYou'),
36+
duration: 3
37+
});
38+
return false;
39+
}
40+
this.$Spin.show()
41+
this.$store.dispatch('setUserInfo', uid).then((r) => {
42+
if (r.status === 200) {
43+
this.$store.dispatch('upUserInfoShow', true)
44+
}
45+
this.$Spin.hide();
46+
}).catch((e) => {
47+
this.$Message.warning({
48+
content: this.$t('notifyTitle.errorOccurred'),
49+
duration: 3
50+
});
51+
this.$Spin.hide();
52+
})
53+
}
54+
}
55+
}
56+
</script>
57+
<template>
58+
<Modal v-model="show" :mask-closable="false" :styles="{top: '50px'}" footer-hide>
59+
<p slot="header" style="text-align: center;">{{ $t('chat.groupInformation') }}</p>
60+
<div class="m-ui-content-group-user" v-if="group.group_id">
61+
<div class="m-ui-gu-gi">
62+
<Row class="m-ui-gu-row">
63+
<Col span="8">{{$t('chat.groupName')}}</Col><Col span="16">{{group.group_name}}</Col>
64+
</Row>
65+
<Row class="m-ui-gu-row">
66+
<Col span="8">{{$t('chat.chatId')}}</Col><Col span="16">{{group.group_number}}</Col>
67+
</Row>
68+
<Row class="m-ui-gu-row">
69+
<Col span="8">{{$t('chat.groupOwner')}}</Col><Col span="16">{{group.group_owner_name}}</Col>
70+
</Row>
71+
<Row class="m-ui-gu-row">
72+
<Col span="8">{{$t('chat.createTime')}}</Col><Col span="16">{{group.created_at}}</Col>
73+
</Row>
74+
</div>
75+
<Divider orientation="left" size="small">{{$t('chat.groupMembers')}}</Divider>
76+
<div class="m-ui-g-user" v-if="group.group_members" v-for="item in group.group_members" :key="item.group_user_id">
77+
<img :src="item.photo" width="50" height="50" @click="getUserInfo(item.user_id)" style="cursor: pointer"><span>{{item.group_user_name}}</span>
78+
</div>
79+
</div>
80+
<div class="m-ui-content-group-user" v-else><Spin fix></Spin></div>
81+
</Modal>
82+
</template>
83+
<style lang="less">
84+
.m-ui-content-group-user {
85+
position: relative;
86+
overflow-y: auto;
87+
max-height: calc(100vh - 250px);
88+
min-height: 150px;
89+
.m-ui-g-user {
90+
float: left;
91+
width: 25%;
92+
text-align: center;
93+
}
94+
.m-ui-gu-gi {
95+
margin-bottom: 10px;
96+
.m-ui-gu-row {
97+
padding: 6px 0;
98+
}
99+
}
100+
span {
101+
vertical-align: middle;
102+
text-align: center;
103+
display: block;
104+
}
105+
}
106+
</style>

src/renderer/components/Chat/Modal/messageHistory.vue

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
components: { messageItem },
55
data () {
66
return {
7-
message: null,
8-
loading: false
7+
message: null
98
}
109
},
1110
computed: {
@@ -49,10 +48,11 @@
4948
page: page
5049
}).then((res) => {
5150
this.message = res.data.data
52-
console.log(res)
53-
this.loading = true;
5451
}).catch((e) => {
55-
this.loading = true;
52+
this.$Message.warning({
53+
content: this.$t('notifyTitle.errorOccurred'),
54+
duration: 3
55+
});
5656
})
5757
}
5858
}
@@ -61,31 +61,44 @@
6161
<template>
6262
<Modal v-model="show" :mask-closable="false" :styles="{top: '50px'}">
6363
<p slot="header" style="text-align: center;">{{ $t('chat.messageHistory') }}</p>
64-
<div class="m-ui-content-message" v-if="message">
65-
<Row v-for="item in message.data">
64+
<div class="m-ui-content-message" v-if="message && message.data && message.data.length">
65+
<Row v-for="item in message.data" :key="item.id">
6666
<p>
6767
<span style="margin-right: 10px;"><b>{{item.user_name}}</b></span>
6868
<span style="color: darkturquoise"><Time :time="item.time * 1000" type="datetime" /></span>
6969
</p>
7070
<message-item v-bind:item="item"></message-item>
7171
</Row>
7272
</div>
73+
<div v-else-if="message" class="m-ui-content-message"><p class="m-ui-p">{{$t('notify.noDataQueried')}}</p></div>
7374
<div v-else class="m-ui-content-message"><Spin fix></Spin></div>
7475
<div slot="footer" v-if="message">
75-
<Page :total="message.total" :current="message.current_page" :page-size="parseInt(message.per_page)" @on-change="changePage" show-elevator />
76+
<Page :total="message.total" :current="message.current_page" :page-size="parseInt(message.per_page)" @on-change="changePage" size="small" show-elevator show-total />
7677
</div>
77-
<div v-else slot="footer"><Spin fix></Spin></div>
78+
<div v-else slot="footer"></div>
7879
</Modal>
7980
</template>
8081
<style lang="less">
8182
.m-ui-content-message {
8283
position: relative;
8384
overflow: auto;
84-
height: calc(100vh - 250px);
85+
max-height: calc(100vh - 250px);
86+
min-height: 100px;
8587
font-size: 12px;
8688
.m-mess-modal {
8789
background: none;
8890
width: 100% !important;
8991
}
92+
.m-ui-p {
93+
width:50%;
94+
position: absolute;
95+
top: 50%;
96+
left: 50%;
97+
-moz-transform: translate(-50%, -50%);
98+
-ms-transform: translate(-50%, -50%);
99+
-webkit-transform: translate(-50%, -50%);
100+
transform: translate(-50%, -50%);
101+
text-align: center;
102+
}
90103
}
91104
</style>

src/renderer/components/Chat/Modal/modifyAvatar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
headers () {
2828
return {
2929
'Accept': 'application/' + config.apiVersion + '+json',
30-
'Custom-Token': config.clientKey,
30+
'Client-Key': config.clientKey,
3131
'Authorization': localStorage.getItem('tokenType') + ' ' + localStorage.getItem('token')
3232
}
3333
}

src/renderer/components/Chat/message.vue

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,37 @@
3232
saveLocal: true,
3333
page: 1
3434
}).then((res) => {
35-
if (res.data.data && res.data.data.length === 0) {
35+
if (res.data.data.data && res.data.data.data.length === 0) {
3636
this.$Message.warning({
3737
content: this.$t('notify.noDataQueried'),
3838
duration: 3
3939
});
4040
}
4141
this.loading = true;
4242
}).catch((e) => {
43+
this.$Message.warning({
44+
content: this.$t('notifyTitle.errorOccurred'),
45+
duration: 3
46+
});
4347
this.loading = true;
4448
})
49+
},
50+
getUserInfo (item) {
51+
if (!item.self) {
52+
this.$Spin.show();
53+
this.$store.dispatch('setUserInfo', item.uid).then((r) => {
54+
if (r.status === 200) {
55+
this.$store.dispatch('upUserInfoShow', true)
56+
}
57+
this.$Spin.hide();
58+
}).catch((e) => {
59+
this.$Message.warning({
60+
content: this.$t('notifyTitle.errorOccurred'),
61+
duration: 3
62+
});
63+
this.$Spin.hide();
64+
})
65+
}
4566
}
4667
},
4768
directives: {

0 commit comments

Comments
 (0)