Skip to content

Commit

Permalink
v0.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
joehecn committed Nov 8, 2017
1 parent c7da095 commit d8e092b
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 25 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ npm run lint
- [x] 消息发送完成后清空消息框 v0.0.3
- [x] 没有选择组时,不显示 tabs v0.0.3
- [x] 显示版本号 v0.0.4
- [ ] 导出好友列表完成后通知消息 - 暂时没有好办法?托盘?
- [x] 软件版本更新提示 github api v0.0.5
- [x] 构建 Windows 版本 v0.0.6
- [x] F 修复 Windows 下侧边栏太窄添加按钮显示不全的问题 v0.0.6
- [x] N 新增 群 v0.0.7
- [x] N 新增 发送图片 v0.0.7
- [x] F 修复 login 200 重定向动态域名 v0.0.8
- [x] F 修复 MacOS 不能复制粘贴 添加菜单映射 v0.0.9
- [x] N 新增 导出好友列表完成后通知消息 v0.0.9

## 依赖
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.8",
"releaseDate": "2017-11-08T03:47:04.055Z",
"url": "https://github.com/joehecn/j/releases/download/v0.0.8/j-0.0.8-mac.zip"
"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"
}
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.8",
"version": "v0.0.9",
"author": "joehe <leanbrown@live.cn>",
"description": "An electron-vue project",
"main": "./dist/electron/main.js",
Expand Down
53 changes: 52 additions & 1 deletion src/main/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

import { app, BrowserWindow } from 'electron'
import { app, Menu, BrowserWindow } from 'electron'

/**
* Set `__static` path to static files in production
Expand All @@ -16,6 +16,34 @@ const winURL = process.env.NODE_ENV === 'development'
: `file://${__dirname}/index.html`

function createWindow () {
/**
* Menu
*/
const template = [
{
submenu: [
{role: 'quit', label: '退出小J'}
]
},
{
label: '编辑',
submenu: [
{role: 'undo', label: '撤销'},
{role: 'redo', label: '重做'},
{type: 'separator'},
{role: 'cut', label: '剪切'},
{role: 'copy', label: '复制'},
{role: 'paste', label: '粘贴'},
{role: 'pasteandmatchstyle', label: '粘贴并匹配样式'},
{role: 'delete', label: '删除'},
{role: 'selectall', label: '全选'}
]
}
]

// 注册菜单
Menu.setApplicationMenu(Menu.buildFromTemplate(template))

/**
* Initial window options
*/
Expand All @@ -30,6 +58,29 @@ function createWindow () {
mainWindow.on('closed', () => {
mainWindow = null
})

mainWindow.webContents.session.on('will-download', (event, item, webContents) => {
item.on('updated', (event, state) => {
if (state === 'interrupted') {
console.log('Download is interrupted but can be resumed')
} else if (state === 'progressing') {
if (item.isPaused()) {
console.log('Download is paused')
} else {
console.log(`Received bytes: ${item.getReceivedBytes()}`)
}
}
})
item.once('done', (event, state) => {
if (state === 'completed') {
console.log('Download successfully')
} else {
console.log(`Download failed: ${state}`)
}

mainWindow.webContents.send('downloaded', state)
})
})
}

app.on('ready', createWindow)
Expand Down
58 changes: 39 additions & 19 deletions src/renderer/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<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="downloadMemberlist">导出好友列表</el-button>
<el-button type="text" @click="downloadMemberlist" :disabled="downloading" :loading="downloading">导出好友列表</el-button>
</div>
<div class="ft-auto fb">
<div class="left ft-none fb fb-column">
Expand Down Expand Up @@ -95,8 +95,8 @@
</template>

<script>
import { ipcRenderer } from 'electron'
import jbot from '@/jbot'
// import MD5 from 'md5'
import SparkMD5 from 'spark-md5'
import stringify from 'csv-stringify'
import { saveAs } from 'filesaver.js'
Expand Down Expand Up @@ -134,7 +134,8 @@ export default {
message: '',
sending: false,
imgsending: false,
showPage: false
showPage: false,
downloading: false
}
},
Expand Down Expand Up @@ -214,7 +215,7 @@ export default {
// item.md5 = MD5(`${item.AttrStatus}${item.NickName}`)
// return item
// })
this.showPage = true
// this.showPage = true
jbot.on('on_error', err => {
console.log(err)
Expand Down Expand Up @@ -251,28 +252,47 @@ export default {
// console.log(this.batchlist)
})
ipcRenderer.on('downloaded', (event, state) => {
this.downloading = false
if (state === 'completed') {
this.$notify.success({
title: '成功',
message: '下载成功'
})
} else {
this.$notify.error({
title: '失败',
message: '下载失败'
})
}
})
// 守护进程
jbot.daemon()
},
methods: {
downloadMemberlist () {
const input = this.memberlist.map((item, index) => {
return [
index + 1,
item.AttrStatus,
item.NickName,
Sex[item.Sex] || ''
]
})
if (this.memberlist.length > 0) {
this.downloading = true
const input = this.memberlist.map((item, index) => {
return [
index + 1,
item.AttrStatus,
item.NickName,
Sex[item.Sex] || ''
]
})
stringify(input, { header: true, columns: [ 'SN', 'AttrStatus', 'NickName', 'Sex' ], eof: false }, (err, data) => {
console.log(err)
if (data) {
const blob = new Blob([data], {type: 'text/plain;charset=utf-8'})
saveAs(blob, `contact-${formatTime()}.csv`)
}
})
stringify(input, { header: true, columns: [ 'SN', 'AttrStatus', 'NickName', 'Sex' ], eof: false }, (err, data) => {
console.log(err)
if (data) {
const blob = new Blob([data], {type: 'text/plain;charset=utf-8'})
saveAs(blob, `contact-${formatTime()}.csv`)
}
})
}
},
addGroup () {
Expand Down

0 comments on commit d8e092b

Please sign in to comment.