diff --git a/icons/128x128.png b/icons/128x128.png
index 0a829f3..65388ea 100644
Binary files a/icons/128x128.png and b/icons/128x128.png differ
diff --git a/icons/256x256.png b/icons/256x256.png
index ef02181..ddef713 100644
Binary files a/icons/256x256.png and b/icons/256x256.png differ
diff --git a/icons/512x512.png b/icons/512x512.png
index 5b26214..dc99b79 100644
Binary files a/icons/512x512.png and b/icons/512x512.png differ
diff --git a/icons/512x512.psd b/icons/512x512.psd
deleted file mode 100644
index 1f9d8c1..0000000
Binary files a/icons/512x512.psd and /dev/null differ
diff --git a/icons/app.icns b/icons/app.icns
index 7daa85b..f9fdd00 100644
Binary files a/icons/app.icns and b/icons/app.icns differ
diff --git a/src/css/app.css b/src/css/app.css
index 26398ed..a1a89ab 100644
--- a/src/css/app.css
+++ b/src/css/app.css
@@ -1 +1 @@
-html{font-size:12.8px;width:100%;height:100vh}body{display:flex;flex-direction:column;width:100%;height:100%;line-height:1.5;font-size:1.09375rem;color:#62778d;background:rgba(0,0,0,0.75)}
+html{font-size:12.8px;width:100%;height:100vh}body{display:flex;flex-direction:column;width:100%;height:100%;padding-top:.9375rem;line-height:1.25;font-size:1.09375rem;color:#f2f5fc;background:transparent}.app{position:relative;display:flex;flex-direction:column;height:100%;padding:1.25rem 0 .46875rem;border-radius:.46875rem;background:rgba(100,100,100,0.75)}.app::before{position:absolute;left:12.10938rem;top:-.54688rem;width:1.09375rem;height:1.09375rem;border-radius:.15625rem;background:linear-gradient(to bottom right, rgba(100,100,100,0.7) 50%, transparent 50%);-webkit-transform:rotate(45deg);transform:rotate(45deg);content:""}.app .option{position:absolute;right:.46875rem;top:.15625rem;--size: 1.09375rem;cursor:pointer;opacity:0}.app .option:hover{opacity:1}.app .list{flex:1}.app .list .item{display:flex;align-items:center;height:4.21875rem;padding:.78125rem .9375rem;line-height:1.17188rem;border-bottom:.07812rem solid rgba(200,200,200,0.1);border-top:.07812rem solid rgba(0,0,0,0.1)}.app .list .item:first-child{border-top:0}.app .list .item:last-child{border-bottom:0}.app .list .item .info{overflow:hidden;flex:1}.app .list .item .info h3{font-size:1.09375rem}.app .list .item .info cite{color:#dae1e9}.app .list .item .last-week{display:flex;justify-content:space-between;flex-flow:wrap-reverse;width:3.75rem;height:1.95312rem;margin:0 1.25rem}.app .list .item .last-week li{width:.23438rem;height:0;background:#fff}.app .list .item .today{width:4.0625rem;font-size:.9375rem;color:#fff;text-align:right}.app .list .item .today span{display:block;padding:0 .3125rem}.app .list .item .today .percent{border-radius:.15625rem}.app .list .item .today .percent.red{background:#ff5061}.app .list .item .today .percent.green{background:#4caf50}
diff --git a/src/css/app.scss b/src/css/app.scss
index ecae199..ae90465 100644
--- a/src/css/app.scss
+++ b/src/css/app.scss
@@ -13,7 +13,92 @@ html {font-size:12.8px;width:100%;height:100vh;}
body {
display:flex;flex-direction: column;
- width:100%;height:100%;line-height:1.5;
- font-size:px(14);color:nth($cd, 1);
- background:rgba(0, 0, 0, .75);
+ width:100%;height:100%;
+ padding-top:px(12);
+ line-height:1.25;
+ font-size:px(14);
+ color:nth($cp, 1);
+ background:transparent;
+}
+
+.app {
+ position:relative;
+ display:flex;
+ flex-direction: column;
+ height:100%;
+ padding:px(16) 0 px(6);
+ border-radius:px(6);
+ background:rgba(100, 100, 100, .75);
+
+ &::before {
+ position:absolute;
+ left:px(155); top:px(-7);
+ width:px(14); height:px(14);
+ border-radius:px(2);
+ background: linear-gradient(to bottom right, rgba(100, 100, 100, .7) 50%, transparent 50%);
+ transform:rotate(45deg);
+ content:"";
+ }
+
+ .option {
+ position:absolute;
+ right:px(6);top:px(2);
+ --size: #{px(14)};
+ cursor:pointer;
+ opacity:0;
+
+ &:hover {
+ opacity:1;
+ }
+ }
+
+ .list {
+ flex:1;
+
+ .item {
+ display:flex;
+ align-items:center;
+ height:px(54);
+ padding:px(10) px(12);
+ line-height:px(15);
+ border-bottom:px(1) solid rgba(200, 200, 200, .1);
+ border-top:px(1) solid rgba(0, 0, 0, .1);
+
+ &:first-child {border-top:0;}
+ &:last-child {border-bottom:0;}
+
+ .info {
+ overflow:hidden;
+ flex:1;
+
+ h3 {font-size:px(14);}
+ cite {color:nth($cp, 3);}
+ }
+
+ .last-week {
+ display:flex;
+ justify-content:space-between;
+ flex-flow: wrap-reverse;
+ width:px(48);height:px(25);
+ margin:0 px(16);
+
+ li {width:px(3);height:0;background:#fff;}
+ }
+
+ .today {
+ width:px(52);
+ font-size:px(12);
+ color:#fff;
+ text-align:right;
+
+ span {display:block;padding:0 px(4);}
+ .percent {
+ border-radius:px(2);
+
+ &.red {background:nth($cr, 1);}
+ &.green {background:nth($cg, 3);}
+ }
+ }
+ }
+ }
}
diff --git a/src/images/6EA1EDBC-2C8A-4360-BF52-2BEB82A6B68B.png b/src/images/6EA1EDBC-2C8A-4360-BF52-2BEB82A6B68B.png
deleted file mode 100644
index 4c9637b..0000000
Binary files a/src/images/6EA1EDBC-2C8A-4360-BF52-2BEB82A6B68B.png and /dev/null differ
diff --git a/src/images/app.png b/src/images/app.png
index ef02181..ddef713 100644
Binary files a/src/images/app.png and b/src/images/app.png differ
diff --git a/src/index.html b/src/index.html
index 1dbfe59..7ca5fa8 100644
--- a/src/index.html
+++ b/src/index.html
@@ -9,8 +9,34 @@
-
+
+
diff --git a/src/js/app.js b/src/js/app.js
index 3f62761..953bc7d 100644
--- a/src/js/app.js
+++ b/src/js/app.js
@@ -7,7 +7,8 @@
*/
import '/lib/anot.js'
-// import '/lib/request/index.js'
+import '/lib/form/button.js'
+import '/lib/scroll/index.js'
import layer from '/lib/layer/index.js'
import Utils from '/lib/utils.js'
@@ -20,10 +21,36 @@ const WIN = remote.getCurrentWindow()
const $doc = Anot(document)
+function getJsonp(str) {
+ return new Function(`function jsonpgz(d){return d}; return ${str}`)()
+}
+
+function getTableData(str) {
+ var match = str.match(/.*?<\/tbody>/)
+ var table = document.createElement('table')
+ var list = []
+ var max = 0
+
+ table.innerHTML = match[0]
+ list = Array.from(table.children[0].children).map(it => {
+ let m = +it.children[1].textContent
+ if (m > max) {
+ max = m
+ }
+ return { m }
+ })
+ max = Math.ceil(max)
+ list.forEach(it => {
+ it.h = ((100 * it.m) / max).toFixed(2) + '%'
+ })
+ return list
+}
+
Anot({
$id: 'app',
state: {
- list: []
+ list: [],
+ $dict: {}
},
watch: {
@@ -36,17 +63,19 @@ Anot({
},
mounted() {
WIN.on('blur', _ => {
- // this.focus = false
- // this.btns.min = this.btns.close = BTNS_DICT.grey
+ WIN.hide()
})
- // WIN.on('focus', _ => {
- // this.focus = true
- // this.btns.min = BTNS_DICT.min
- // this.btns.close = BTNS_DICT.close
- // })
+ var watch_list = Anot.ls('watch_list') || '[]'
+ if (watch_list) {
+ watch_list = JSON.parse(watch_list)
+ }
- this.getTodayStat('006736')
+ this.list = watch_list
+
+ for (let it of this.list) {
+ this.$dict[it.code] = it
+ }
},
methods: {
getTodayStat(id) {
@@ -54,11 +83,68 @@ Anot({
'net',
`https://fundgz.1234567.com.cn/js/${id}.js`
)
- // `http://fund.eastmoney.com/f10/F10DataApi.aspx?type=lsjz&code=006736`
- log(res)
- // fetch(`https://fundgz.1234567.com.cn/js/${id}.js`).then(res => {
- // log(res)
- // })
+ return getJsonp(res)
+ },
+
+ getLastWeek(id) {
+ var res = ipcRenderer.sendSync(
+ 'net',
+ `https://fund.eastmoney.com/f10/F10DataApi.aspx?type=lsjz&code=${id}`
+ )
+ return getTableData(res)
+ },
+ addGay() {
+ layer
+ .prompt('请输入鸡精代号', (val, done) => {
+ if (val.trim()) {
+ done()
+ }
+ })
+ .then(id => {
+ if (this.$dict[id]) {
+ return
+ }
+ Anot.nextTick(_ => {
+ var info = this.getTodayStat(id)
+ var last = this.getLastWeek(id)
+ if (info) {
+ var tmp = {
+ code: info.fundcode,
+ name: info.name,
+ yesterday: info.dwjz,
+ curr: info.gsz,
+ percent: +info.gszzl,
+ last
+ }
+ this.list.unshift(tmp)
+ this.$dict[tmp.code] = this.list[0]
+ Anot.ls('watch_list', this.list.$model)
+ }
+ })
+ })
+ .catch(Anot.noop)
+ },
+
+ updateGay(item) {
+ var info = this.getTodayStat(item.code)
+ if (info.dwjz !== item.yesterday) {
+ item.last = this.getLastWeek(id)
+ }
+ item.curr = info.gsz
+ item.percent = +info.gszzl
+
+ Anot.ls('watch_list', this.list.$model)
+ },
+
+ removeGay(item) {
+ layer
+ .confirm(`是否移除[${item.name.slice(0, 5)}...]?`)
+ .then(_ => {
+ item.$ups.it.$remove()
+ delete this.$dict[item.code]
+ Anot.ls('watch_list', this.list.$model)
+ })
+ .catch(Anot.noop)
}
}
})
diff --git a/src/lib/css/reset-basic.css b/src/lib/css/reset-basic.css
index 4546277..75b2a0c 100644
--- a/src/lib/css/reset-basic.css
+++ b/src/lib/css/reset-basic.css
@@ -1,7 +1,7 @@
@charset "UTF-8";
/**
*
- * @authors yutent (yutent@doui.cc)
+ * @authors yutent (yutent.io@gmail.com)
* @date 2014-10-10 00:45:09
*
* doui的CSS规范
@@ -35,11 +35,11 @@ q::before, q::after {content: '';content: none;}
table {border-collapse: collapse;border-spacing: 0;}
a:focus,input,textarea,button:focus,input:focus,textarea:focus {outline:none;}
::-moz-focus-inner {
- border:none;outline:none;
+ border:none;outline:none;
}
-body {font-family:Helvetica, Arial,"WenQuanYi Micro Hei","PingFang SC","Hiragino Sans GB","Segoe UI", "Microsoft Yahei", sans-serif;-webkit-font-smoothing: antialiased;text-size-adjust: 100%;-webkit-tap-highlight-color: transparent;}
+body {font-family:"Helvetica Neue", Arial,"WenQuanYi Micro Hei","PingFang SC","Hiragino Sans GB","Segoe UI", "Microsoft Yahei", sans-serif;-webkit-font-smoothing: antialiased;text-size-adjust: 100%;-webkit-tap-highlight-color: transparent;}
code,pre,samp {font-family:Menlo,Monaco,Consolas,"Courier New",monospace;}
-[anot],[\:repeat],[\:if],[is-widget],slot {visibility:hidden;}
+[anot],[\:repeat],[\:if] {visibility:hidden;}
.do-fn-cl { *zoom: 1; }
.do-fn-cl::after { content: "."; display: block; height: 0; clear: both; visibility: hidden; overflow:hidden;}
@@ -55,6 +55,4 @@ code,pre,samp {font-family:Menlo,Monaco,Consolas,"Courier New",monospace;}
.do-st-thin {-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;}
.do-st-hand {cursor:pointer;}
-[class^="do-icon-"], [class*=" do-icon-"] {display:inline-block;font-family:"uifont" !important;font-style:normal;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;}
-
diff --git a/src/main.js b/src/main.js
index c594a85..1ad1e23 100644
--- a/src/main.js
+++ b/src/main.js
@@ -59,7 +59,7 @@ protocol.registerSchemesAsPrivileged([
/* ----------------------------------------------------- */
-// app.dock.hide()
+app.dock.hide()
// 初始化应用
app.once('ready', () => {
@@ -74,7 +74,7 @@ app.once('ready', () => {
// 创建浏览器窗口
let win = new BrowserWindow({
title: '',
- width: 375,
+ width: 320,
height: 360,
resizable: false,
maximizable: false,
@@ -94,7 +94,7 @@ app.once('ready', () => {
win = null
})
- win.openDevTools()
+ // win.openDevTools()
// 然后加载应用的 index.html
win.loadURL('app://local/index.html')
@@ -102,6 +102,7 @@ app.once('ready', () => {
createMenu(win)
createTay(win)
})
+
ipcMain.on('net', (ev, url) => {
fetch(url).then(r => {
ev.returnValue = r
diff --git a/src/tools/tray.js b/src/tools/tray.js
index efec8f9..67346e6 100644
--- a/src/tools/tray.js
+++ b/src/tools/tray.js
@@ -15,7 +15,8 @@ module.exports = function(win) {
app.__TRAY__.on('click', _ => {
var b = app.__TRAY__.getBounds()
- win.setBounds({ x: b.x - 185, y: b.y + b.height + 4 })
+ win.setBounds({ x: b.x - 150, y: b.y + b.height + 4 })
win.show()
+ win.focus()
})
}