Skip to content

Commit c799411

Browse files
author
Doge Chan
committed
add http server
1 parent 6229363 commit c799411

File tree

6 files changed

+77
-34
lines changed

6 files changed

+77
-34
lines changed

.travis.yml

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,30 @@
11
osx_image: xcode8.3
2-
sudo: required
2+
sudo: false
33
dist: trusty
4-
language: c
5-
matrix:
6-
include:
7-
- os: osx
8-
- os: linux
9-
env: CC=clang CXX=clang++ npm_config_clang=1
10-
compiler: clang
4+
language: node_js
5+
node_js: "8"
6+
7+
env:
8+
global:
9+
- ELECTRON_CACHE=$HOME/.cache/electron
10+
- ELECTRON_BUILDER_CACHE=$HOME/.cache/electron-builder
11+
12+
os:
13+
- linux
14+
- osx
15+
1116
cache:
1217
directories:
13-
- node_modules
14-
- "$HOME/.electron"
15-
- "$HOME/.cache"
16-
addons:
17-
apt:
18-
packages:
19-
- libgnome-keyring-dev
20-
- icnsutils
21-
before_install:
22-
- mkdir -p /tmp/git-lfs && curl -L https://github.com/github/git-lfs/releases/download/v1.2.1/git-lfs-$([
23-
"$TRAVIS_OS_NAME" == "linux" ] && echo "linux" || echo "darwin")-amd64-1.2.1.tar.gz
24-
| tar -xz -C /tmp/git-lfs --strip-components 1 && /tmp/git-lfs/git-lfs pull
25-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install --no-install-recommends -y icnsutils graphicsmagick xz-utils; fi
26-
install:
27-
- nvm install 7
28-
- curl -o- -L https://yarnpkg.com/install.sh | bash
29-
- source ~/.bashrc
30-
- npm install -g xvfb-maybe
31-
- yarn
18+
- node_modules
19+
- "$HOME/.electron"
20+
- “$HOME/.cache/electron-builder”
21+
- "$HOME/.cache"
22+
- "$HOME/.npm/_prebuilds"
23+
3224
script:
33-
- yarn run build
25+
- npm install
26+
- npm run build
27+
3428
branches:
3529
only:
36-
- master
30+
- master

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": null,
77
"main": "./dist/electron/main.js",
88
"scripts": {
9-
"build": "node .electron-vue/build.js && electron-builder --win --linux",
9+
"build": "node .electron-vue/build.js && electron-builder --publish onTagOrDraft",
1010
"build:dir": "node .electron-vue/build.js && electron-builder --dir",
1111
"build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js",
1212
"build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js",
@@ -53,7 +53,9 @@
5353
}
5454
},
5555
"dependencies": {
56+
"@koa/cors": "^2.2.2",
5657
"axios": "^0.18.0",
58+
"koa": "^2.6.2",
5759
"material-design-icons-iconfont": "^4.0.2",
5860
"rss-parser": "^3.5.3",
5961
"vue": "^2.5.16",

src/main/httpserver.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const Koa = require("koa");
2+
const cors = require("@koa/cors");
3+
const app = new Koa();
4+
app.use(cors());
5+
// response
6+
// app.use(ctx => {
7+
// ctx.body = "Hello Koa";
8+
// });
9+
10+
//TODO:功能 使用Bookmarklet 从浏览器里面获取url处理
11+
// use bookmarklet:
12+
// javascript: (function () { var request = new XMLHttpRequest(); request.open("GET", 'http://127.0.0.1:3000/open?url=' + document.location.href); request.send(null); })();
13+
app.use(async (ctx, next) => {
14+
ctx.status = 200;
15+
await next();
16+
console.log(ctx.request.query);
17+
});
18+
19+
app.listen(3000);

src/main/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { fetchFeed } from "./feeds.js";
33
import { resolve } from "url";
44
import { __await } from "tslib";
55
import "../renderer/store";
6+
import "./httpserver";
67
var fs = require("fs");
78

89
/**

src/renderer/App.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export default {
1414
/* CSS */
1515
html {
1616
height: 100%;
17+
font-family: "BlinkMacSystemFont", "Lucida Grande", "Segoe UI", Ubuntu,
18+
Cantarell, sans-serif;
19+
font-size: 14px;
20+
line-height: 1.5;
21+
background-color: #fff;
1722
}
1823
body {
1924
height: 100%;

src/renderer/components/index.vue

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
<template>
22
<v-app class="content">
3-
<v-navigation-drawer app v-model="drawer" :mini-variant.sync="mini" mini-variant-width=50 width=200 permanent>
3+
<v-navigation-drawer class="nav" app v-model="drawer" :mini-variant.sync="mini" v-on:mouseover.native="mini=false" v-on:mouseleave.native="mini=true" mini-variant-width=50 width=200 permanent>
44
<v-list>
55
<v-btn icon @click.stop="mini = !mini">
66
<v-icon>menu</v-icon>
77
</v-btn>
88
<template v-for="(item, index) in sites">
99
<v-list-tile :key="index" ripple :class="{'mini-tile':mini}" @click="siteItemClick(index)">
1010
<v-list-tile-action>
11-
<v-img :src="getFavicon(item.src)" max-width="16px" position="left center"></v-img>
11+
<v-badge v-if="feedCount[item.feed]>0&&mini" overlap color="cyan"><span slot="badge">{{feedCount[item.feed]}}</span>
12+
<v-img :src="getFavicon(item.src)" width="20px" position="left center"></v-img>
13+
</v-badge>
14+
<v-img v-else :src="getFavicon(item.src)" max-width="16px" position="left center"></v-img>
1215
</v-list-tile-action>
1316
<v-list-tile-content>
14-
<v-badge v-if="feedCount[item.feed]>0" color="grey"><span slot="badge">{{feedCount[item.feed]}}</span><span v-show="1">{{item.title}}</span></v-badge><span v-else>{{item.title}}</span>
17+
<v-badge v-if="feedCount[item.feed]>0" color="cyan"><span slot="badge">{{feedCount[item.feed]}}</span><span>{{item.title}}</span></v-badge><span v-else>{{item.title}}</span>
1518
</v-list-tile-content>
1619
</v-list-tile>
1720
<!-- <v-divider v-if="index + 1 < sites.length" :key="`site-${index}`"></v-divider> -->
@@ -65,7 +68,7 @@ export default {
6568
return {
6669
fab: false,
6770
drawer: true,
68-
mini: false,
71+
mini: true,
6972
webViewSrc: "https://www.v2ex.com/",
7073
sites: [
7174
{
@@ -104,6 +107,18 @@ export default {
104107
methods: {
105108
...mapActions(["setLoadingState"]),
106109
saveHtml() {
110+
const notification = {
111+
title: "基本通知",
112+
body: "简短的通知内容"
113+
};
114+
const myNotification = new window.Notification(
115+
notification.title,
116+
notification
117+
);
118+
myNotification.onclick = () => {
119+
console.log("通知被点击");
120+
};
121+
107122
var path =
108123
this.appPath +
109124
this.$refs.webView
@@ -206,6 +221,13 @@ export default {
206221
margin-top: -5px;
207222
z-index: 99;
208223
}
224+
.nav {
225+
background-color: hsl(0, 0%, 96%) !important;
226+
}
227+
.v-badge__badge {
228+
width: 18px !important;
229+
height: 18px !important;
230+
}
209231
</style>
210232

211233

0 commit comments

Comments
 (0)