Skip to content

Commit

Permalink
Merge pull request #14 from Jarvay/develop
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
Jarvay authored May 18, 2019
2 parents 86c3b3f + 2b5b6aa commit a37f83e
Show file tree
Hide file tree
Showing 15 changed files with 343 additions and 53 deletions.
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "desktop48",
"version": "1.0.2",
"version": "1.1.0",
"author": "jarvay <[email protected]>",
"description": "",
"license": null,
Expand Down Expand Up @@ -68,49 +68,49 @@
"iview": "^3.4.1",
"lowdb": "^1.0.0",
"m3u8-parser": "^4.3.0",
"mux.js": "^5.1.0",
"mux.js": "^5.1.3",
"video.js": "^7.5.4",
"vue": "^2.5.16",
"vue": "^2.6.10",
"vue-electron": "^1.0.6",
"vue-router": "^3.0.1"
"vue-router": "^3.0.6"
},
"devDependencies": {
"ajv": "^6.5.0",
"ajv": "^6.10.0",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.4",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.26.0",
"babili-webpack-plugin": "^0.1.2",
"cfonts": "^2.1.2",
"cfonts": "^2.4.3",
"chalk": "^2.4.1",
"copy-webpack-plugin": "^4.5.1",
"cross-env": "^5.1.6",
"css-loader": "^0.28.11",
"del": "^3.0.0",
"devtron": "^1.4.0",
"electron": "^2.0.4",
"electron-debug": "^1.5.0",
"electron": "^4.2.1",
"electron-builder": "^20.40.2",
"electron-debug": "^3.0.0",
"electron-devtools-installer": "^2.2.4",
"electron-builder": "^20.19.2",
"mini-css-extract-plugin": "0.4.0",
"file-loader": "^1.1.11",
"html-webpack-plugin": "^3.2.0",
"mini-css-extract-plugin": "0.4.0",
"multispinner": "^0.2.1",
"node-loader": "^0.6.0",
"node-sass": "^4.9.2",
"node-sass": "^4.12.0",
"sass-loader": "^7.0.3",
"style-loader": "^0.21.0",
"url-loader": "^1.0.1",
"vue-html-loader": "^1.2.4",
"vue-loader": "^15.2.4",
"vue-loader": "^15.7.0",
"vue-style-loader": "^4.1.0",
"vue-template-compiler": "^2.5.16",
"webpack": "^4.15.1",
"webpack-cli": "^3.0.8",
"webpack-dev-server": "^3.1.4",
"webpack-hot-middleware": "^2.22.2",
"vue-template-compiler": "^2.6.10",
"webpack": "^4.31.0",
"webpack-cli": "^3.3.2",
"webpack-dev-server": "^3.3.1",
"webpack-hot-middleware": "^2.25.0",
"webpack-merge": "^4.1.3"
}
}
2 changes: 2 additions & 0 deletions src/renderer/assets/js/api-urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ ApiUrls.FOLLOW_MEMBERS_URL = 'https://pocketapi.48.cn/user/api/v1/friendships/fr

ApiUrls.CHECK_IN_URL = 'https://pocketapi.48.cn/user/api/v1/checkin';

ApiUrls.TRIP_LIST_URL = 'https://pocketapi.48.cn/trip/api/trip/v1/list';

export default ApiUrls;
15 changes: 15 additions & 0 deletions src/renderer/assets/js/apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ class Apis {
});
}

/**
*
* @param lastTime
* @param userId
* @returns {*|Promise<any>}
*/
static trips(lastTime, userId = '0') {
return Apis.request(ApiUrls.TRIP_LIST_URL, {
isMore: 'true',
lastTime: lastTime,
limit: 20,
userId: userId
});
}

static async chatRoomToken() {
const cookieVal = '48web' + Math.random().toString(36).substr(2);

Expand Down
2 changes: 2 additions & 0 deletions src/renderer/assets/js/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Constants.JUJU_MSG_TYPE = JUJU_MSG_TYPE;
const MENU = {};
MENU.LIVES = 'LIVES';
MENU.REVIEWS = 'REVIEWS';
MENU.TRIPS = 'TRIPS';
MENU.SETTINGS = 'SETTINGS';
MENU.MESSAGES = 'MESSAGES';
MENU.JUJU = 'JUJU';
Expand Down Expand Up @@ -87,6 +88,7 @@ Constants.REVIEW_SCREEN = REVIEW_SCREEN;
*/
const EVENT = {};
EVENT.LOGIN = 'LOGIN';
EVENT.LOGOUT = 'LOGOUT';
EVENT.USER_INFO = 'USER_INFO';
EVENT.LIVE_OPEN = 'LIVE_OPEN';
EVENT.TO_CHECK_IN = 'TO_CHECK_IN';
Expand Down
36 changes: 35 additions & 1 deletion src/renderer/assets/js/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Database {
}

static getToken() {
return Database.get('token', '');
return Database.get('token', '');
}

static setToken(token) {
Expand Down Expand Up @@ -130,6 +130,32 @@ class Database {
return Database.get('lastCheckInTime', null);
}

static addHiddenMember(memberId) {
Database.removeHiddenMember(memberId);
Database.db.get('hiddenMembers').push(memberId).write();
}

static removeHiddenMember(memberId) {
Database.db.get('hiddenMembers').pull(memberId).write();
}

static getHiddenMembers() {
return Database.get('hiddenMembers', []);
}

static addNoticeMember(memberId) {
Database.removeNoticeMember(memberId);
Database.db.get('noticeMembers').push(memberId).write();
}

static removeNoticeMember(memberId) {
Database.db.get('noticeMembers').pull(memberId).write();
}

static getNoticeMembers() {
return Database.get('noticeMembers', []);
}

static setConfig(key, value) {
Database.db.set(`config.${key}`, value).write();
}
Expand All @@ -156,6 +182,14 @@ class Database {
if (!Database.db.has('badgeCount').value()) {
Database.db.set('badgeCount', []).write();
}

if (!Database.db.has('onlyShowMembers').value()) {
Database.db.set('onlyShowMembers', []).write();
}

if (!Database.db.has('hiddenMembers').value()) {
Database.db.set('hiddenMembers', []).write();
}
}

static get(key, defaultValue) {
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/components/Account.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@
sendText: '获取验证码',
verifyLoginDisabled: false,
loginDisabled: false,
userInfo: {}
userInfo: null
};
},
computed: {
isLogin() {
return typeof this.userInfo !== "undefined";
return this.userInfo != null;
}
},
created() {
Expand Down Expand Up @@ -181,7 +181,7 @@
this.verifyLoginDisabled = false;
Database.removeLoginUserInfo();
Database.removeToken();
this.userInfo = undefined;
this.userInfo = null;
this.$eventBus.$emit(this.Constants.EVENT.LOGOUT);
},
Expand Down
64 changes: 64 additions & 0 deletions src/renderer/components/HiddenMembers.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<template>
<div>
<Collapse>
<Panel>
<span slot="">不看她的直播|回放</span>
<Collapse slot="content" simple accordion>
<Panel v-for="(team, teamIndex) in teams">
<span>{{team.teamName}}</span>
<div slot="content">
<Tag @on-change="onChange" checkable :checked="member.checked"
:name="member.userId"
:color="`#${team.teamColor}`"
v-for="member in team.members">
{{member.realName}}
</Tag>
</div>
</Panel>
</Collapse>
</Panel>
</Collapse>
</div>
</template>

<script>
import Database from "../assets/js/database";
import Dev from "../assets/js/dev";
export default {
name: "HiddenMembers",
data() {
return {
teams: []
};
},
created() {
this.teams = Database.teamsDB.value();
this.teams = this.teams.filter(team => {
team.members = Database.membersDB.filter({teamId: team.teamId, status: 1}).value();
team.members = team.members.map(member => {
member.checked = Database.getHiddenMembers().some(memberId => {
return memberId == member.userId;
});
return member;
});
return team.members.length > 0;
});
},
methods: {
onChange: function (checked, memberId) {
if (checked) {
Database.addHiddenMember(memberId);
} else {
Database.removeHiddenMember(memberId);
}
Dev.log('hiddenMembers', Database.getHiddenMembers());
}
}
}
</script>

<style scoped>
</style>
6 changes: 5 additions & 1 deletion src/renderer/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<Menu :active-name="Constants.MENU.LIVES" theme="dark" width="auto" @on-select="onMenuSelect">
<MenuItem :name="Constants.MENU.LIVES">直播</MenuItem>
<MenuItem :name="Constants.MENU.REVIEWS">回放</MenuItem>
<MenuItem :name="Constants.MENU.TRIPS">行程</MenuItem>
<MenuItem :name="Constants.MENU.JUJU">聚聚</MenuItem>
<MenuItem :name="Constants.MENU.MESSAGES">消息</MenuItem>
<MenuItem :name="Constants.MENU.SETTINGS">设置</MenuItem>
Expand All @@ -26,6 +27,8 @@
:teams="teams"
:groups="groups"></Reviews>

<Trips v-show="menus[Constants.MENU.TRIPS]"></Trips>

<MessageBox v-show="menus[Constants.MENU.MESSAGES]"></MessageBox>

<JuJu v-show="menus[Constants.MENU.JUJU]"></JuJu>
Expand Down Expand Up @@ -59,6 +62,7 @@
import JuJu from "./JuJu";
import Dev from "../assets/js/dev";
import Tools from "../assets/js/tools";
import Trips from "./Trips";
const menus = {};
Object.keys(Constants.MENU).forEach(key => {
Expand All @@ -67,7 +71,7 @@
export default {
name: 'Home',
components: {JuJu, Settings, MessageBox, Lives, Reviews, Live},
components: {Trips, JuJu, Settings, MessageBox, Lives, Reviews, Live},
data() {
return {
homeClosable: false,
Expand Down
39 changes: 25 additions & 14 deletions src/renderer/components/JuJu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@
if (Database.isLogin()) {
this.init();
}
this.connectHomeChatRoom();
this.registerEvent();
},
methods: {
init: function () {
this.juJuList();
this.connectHomeChatRoom();
},
juJuList: function () {
Apis.juJuList().then(content => {
Expand Down Expand Up @@ -156,20 +156,31 @@
messages.forEach(message => {
if (message.type == 'text') {
const custom = JSON.parse(message.custom);
const index = this.list.findIndex(item => {
return item.ownerId == custom.ownerId;
});
if (index != -1) {
const matchedItem = this.list[index];
matchedItem.msgTime = custom.msgTime;
matchedItem.msg = custom.msg;
matchedItem.newTime = new Date(custom.msgTime).format('hh:mm');
matchedItem.badgeCount++;
Database.incrementBadgeCount(matchedItem.ownerId);
this.list.splice(index, 1);
this.list.unshift(matchedItem);
if (custom.msg == '[直播消息]') {
if (Database.isLogin()) {
const index = this.list.findIndex(item => {
return item.ownerId == custom.ownerId;
});
if (index != -1) {
const matchedItem = this.list[index];
matchedItem.msgTime = custom.msgTime;
matchedItem.msg = custom.msg;
matchedItem.newTime = new Date(custom.msgTime).format('hh:mm');
matchedItem.badgeCount++;
Database.incrementBadgeCount(matchedItem.ownerId);
this.list.splice(index, 1);
this.list.unshift(matchedItem);
if (custom.msg == '[直播消息]') {
this.notification(matchedItem.ownerId);
}
}
} else {
Dev.log('not login on message', custom);
const toNotice = Database.getNoticeMembers().some(memberId => {
return memberId == custom.ownerId;
});
if (toNotice && custom.msg == '[直播消息]') {
this.notification(matchedItem.ownerId);
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/renderer/components/Live.vue
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@
onMessage: messages => {
messages.forEach(message => {
if (message.type == 'text') {
console.log(message.custom);
const custom = JSON.parse(message.custom);
switch (custom.messageType) {
case this.Constants.MESSAGE_TYPE.BARRAGE_NORMAL: //弹幕消息
Expand Down Expand Up @@ -315,12 +314,12 @@
break;
}
} else {
console.log(message);
Dev.log(message);
}
});
},
onError: error => {
console.log(error);
Dev.error(error);
}
};
ChatRoomTools.chatroom(options).then(chatroom => {
Expand Down
Loading

0 comments on commit a37f83e

Please sign in to comment.