Skip to content

Commit

Permalink
v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
joehecn committed Nov 9, 2017
1 parent d8e092b commit 75dba6c
Show file tree
Hide file tree
Showing 18 changed files with 180 additions and 30 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ npm run lint
- [x] F 修复 login 200 重定向动态域名 v0.0.8
- [x] F 修复 MacOS 不能复制粘贴 添加菜单映射 v0.0.9
- [x] N 新增 导出好友列表完成后通知消息 v0.0.9
- [x] F 修复 侧边栏分组人数在切换用户后不对 - 分组对应用户 v0.1.0
- [x] N 新增 自定义 图灵key v0.1.0
- [x] N 新增 心跳图标 v0.1.0

## 依赖
This project was generated with [electron-vue](https://github.com/SimulatedGREG/electron-vue)@[de85f81](https://github.com/SimulatedGREG/electron-vue/tree/de85f81890c01500113738bfe57bef136f9fbf52) using [vue-cli](https://github.com/vuejs/vue-cli). Documentation about the original structure can be found [here](https://simulatedgreg.gitbooks.io/electron-vue/content/index.html).
6 changes: 3 additions & 3 deletions build/github/latest-mac.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.0.9",
"releaseDate": "2017-11-08T10:36:06.201Z",
"url": "https://github.com/joehecn/j/releases/download/v0.0.9/j-0.0.9-mac.zip"
"version": "0.1.0",
"releaseDate": "2017-11-09T03:47:40.668Z",
"url": "https://github.com/joehecn/j/releases/download/v0.1.0/j-0.1.0-mac.zip"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "j",
"version": "v0.0.9",
"version": "v0.1.0",
"author": "joehe <leanbrown@live.cn>",
"description": "An electron-vue project",
"main": "./dist/electron/main.js",
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/jbot/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default new class Daemon extends Emitter {
this.emit('on_memberlist', res.MemberList)

while (true) {
console.log('心跳')
// console.log('心跳')
res = await synccheck(ctx.BaseRequest, ctx.SyncKey.List)

// 新消息
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/jbot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default new class JBot extends Emitter {
}

async robotsendmsg (msg) {
const res = await tuling.sendmsg(msg.Content, msg.FromUserName.replace(/@/g, ''))
const res = await tuling.sendmsg(store.state.tulingkey, msg.Content, msg.FromUserName.replace(/@/g, ''))

CTX.method = 'sendmsg'

Expand Down
4 changes: 2 additions & 2 deletions src/renderer/jbot/tuling.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

import rpn from 'request-promise-native'

export const sendmsg = async (info, userid) => {
export const sendmsg = async (key, info, userid) => {
const res = await rpn({
url: 'http://www.tuling123.com/openapi/api',
method: 'POST',
json: true,
body: {
key: '778d4422ba5f4bbbbf87e968f43a9102',
key, // '778d4422ba5f4bbbbf87e968f43a9102'
info,
userid
}
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Vue from 'vue'

import './style/iconfont.css'

import {
Button,
Input,
Expand Down Expand Up @@ -29,6 +32,7 @@ Vue.use(TabPane)
// Vue.use(Upload)

Vue.prototype.$confirm = MessageBox.confirm
Vue.prototype.$prompt = MessageBox.prompt
Vue.prototype.$notify = Notification

// title
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
'use strict'

// import * as api from '@/api'
import { SET_USER } from './mutation-types.js'
import { SET_USER, SET_KEY } from './mutation-types.js'

export default {
setUser ({ commit }, user) {
commit(SET_USER, user)
},

setKey ({ commit }, key) {
commit(SET_KEY, key)
}
}
5 changes: 4 additions & 1 deletion src/renderer/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Vue from 'vue'
import Vuex from 'vuex'
import mutations from './mutations.js'
import actions from './actions.js'
import plugins from './plugins.js'
import { DEFAULT_USER } from '@/util'

Vue.use(Vuex)
Expand All @@ -14,10 +15,12 @@ export const USER_KEY = 'user' // Local Storage Key
const store = new Vuex.Store({
strict: process.env.NODE_ENV !== 'production',
state: {
tulingkey: window.localStorage.tulingkey || '',
user: DEFAULT_USER
},
mutations,
actions
actions,
plugins
})

export default store
1 change: 1 addition & 0 deletions src/renderer/store/mutation-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
'use strict'

export const SET_USER = 'SET_USER'
export const SET_KEY = 'SET_KEY'
6 changes: 5 additions & 1 deletion src/renderer/store/mutations.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@

'use strict'

import { SET_USER } from './mutation-types.js'
import { SET_USER, SET_KEY } from './mutation-types.js'

export default {
[SET_USER] (state, user) {
state.user = user
},

[SET_KEY] (state, key) {
state.tulingkey = key
}
}
15 changes: 15 additions & 0 deletions src/renderer/store/plugins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

'use strict'

import { SET_KEY } from './mutation-types.js'

const localStoragePlugin = store => {
store.subscribe((mutation, state) => {
if (mutation.type === SET_KEY) {
console.log(state)
window.localStorage.tulingkey = state.tulingkey
}
})
}

export default [localStoragePlugin]
19 changes: 19 additions & 0 deletions src/renderer/style/iconfont.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added src/renderer/style/iconfont.eot
Binary file not shown.
36 changes: 36 additions & 0 deletions src/renderer/style/iconfont.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/renderer/style/iconfont.ttf
Binary file not shown.
Binary file added src/renderer/style/iconfont.woff
Binary file not shown.
99 changes: 80 additions & 19 deletions src/renderer/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
<div id="home" class="fb fb-column" v-show="showPage">
<div class="head ft-none fb fb-justify-around fb-align-center">
<el-checkbox v-model="robot">自动回复</el-checkbox>
<el-button type="text" @click="removeKey">删除图灵key</el-button>
<el-button type="text" @click="downloadMemberlist" :disabled="downloading" :loading="downloading">导出好友列表</el-button>
<div>
<i class="hm-icon iconfont icon-hartfull"
:class="jumping ? 'hm-icon-life' : ''"></i>
</div>
</div>
<div class="ft-auto fb">
<div class="left ft-none fb fb-column">
Expand Down Expand Up @@ -118,7 +123,8 @@ export default {
data () {
return {
robot: false,
jumping: true,
robot: false, // 自动回复
memberlist: [],
batchlist: [],
// [
Expand Down Expand Up @@ -196,6 +202,16 @@ export default {
}
},
watch: {
robot (val) {
// 如果为 true, 检测 tuling key
// 如果没有 key, 打开 输入key对话框
if (val && !this.$store.state.tulingkey) {
this.openInputKey()
}
}
},
filters: {
filterNum (md5) {
let num = 0
Expand All @@ -209,32 +225,21 @@ export default {
},
mounted () {
this.groups = JSON.parse(window.localStorage.groups || '[]')
// this.memberlist = JSON.parse(window.localStorage.memberlist || '[]').map(item => {
// item.md5 = MD5(`${item.AttrStatus}${item.NickName}`)
// return item
// })
// this.showPage = true
jbot.on('on_error', err => {
console.log(err)
}).on('on_reluser', user => {
this.$store.dispatch('setUser', user)
this.groups = JSON.parse(window.localStorage[user.Uin] || '[]')
}).on('on_memberlist', memberlist => {
this.memberlist = memberlist.filter(item => {
return item.AttrStatus > 0 && item.UserName[0] === '@'
}).map(item => {
// item.md5 = MD5(`${item.AttrStatus}${item.NickName}`)
// console.log(item.md5)
item.md5 = SparkMD5.hash(`${item.AttrStatus}${item.NickName}`)
return item
})
this.showPage = true
}).on('on_msg', msg => {
// console.log(msg)
// console.log(this.robot)
// 自动回复 && 群聊不回复
if (this.robot && msg.FromUserName.substring(1, 2) !== '@') {
jbot.robotsendmsg(msg)
Expand All @@ -257,21 +262,51 @@ export default {
if (state === 'completed') {
this.$notify.success({
title: '成功',
message: '下载成功'
message: '导出好友成功'
})
} else {
this.$notify.error({
title: '失败',
message: '下载失败'
message: '导出好友失败'
})
}
})
// this.showPage = true
// 守护进程
jbot.daemon()
jbot.daemon().then(() => {
this.jumping = false
this.$notify.error({
title: '失败',
message: '守护进程已死',
duration: 0
})
})
},
methods: {
openInputKey () {
this.$prompt('提示: 如果没有key, 请到 www.tuling123.com 注册一个', '请输入图灵 key', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputPattern: /^[a-z0-9]{32}$/,
inputErrorMessage: 'key 格式不正确'
}).then(({ value }) => {
this.$store.dispatch('setKey', value)
}).catch(() => {
this.robot = false
})
},
removeKey () {
this.$store.dispatch('setKey', '')
this.robot = false
this.$notify.success({
title: '成功',
message: '删除图灵key成功'
})
},
downloadMemberlist () {
if (this.memberlist.length > 0) {
this.downloading = true
Expand Down Expand Up @@ -304,7 +339,7 @@ export default {
md5: {}
})
window.localStorage.groups = JSON.stringify(this.groups)
window.localStorage[this.$store.state.user.Uin] = JSON.stringify(this.groups)
}
this.newgroupname = ''
Expand All @@ -321,7 +356,7 @@ export default {
this.selected = -1
this.groups.splice(index, 1)
window.localStorage.groups = JSON.stringify(this.groups)
window.localStorage[this.$store.state.user.Uin] = JSON.stringify(this.groups)
}).catch(() => {})
},
Expand All @@ -330,7 +365,7 @@ export default {
let _item = this.groups[this.selected]
_item.md5[item.md5] = !item.checked
this.$set(this.groups, this.selected, _item)
window.localStorage.groups = JSON.stringify(this.groups)
window.localStorage[this.$store.state.user.Uin] = JSON.stringify(this.groups)
this.searchText = ''
},
Expand Down Expand Up @@ -465,6 +500,32 @@ export default {
border-bottom: 1px solid #ddd;
}
.hm-icon {
position: absolute;
margin-top: -14px;
font-size: 22px;
color: #ddd;
}
.hm-icon-life {
color: red;
animation:jump 1.5s infinite linear;
}
@keyframes jump {
0% {
font-size: 20px;
}
50% {
font-size: 24px;
}
100% {
font-size: 20px;
}
}
.left {
background: #eaeaea;
border-right: 1px solid #ddd;
Expand Down

0 comments on commit 75dba6c

Please sign in to comment.