Skip to content

Commit

Permalink
修复刷新时的 bug;增加手动刷新功能。
Browse files Browse the repository at this point in the history
  • Loading branch information
oldj committed Jan 16, 2016
1 parent 4ae639c commit 2716a69
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 31 deletions.
4 changes: 2 additions & 2 deletions app/SH3/MacGap/SwitchHosts!-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.1.1</string>
<string>3.1.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>3044</string>
<string>3081</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
Expand Down
4 changes: 3 additions & 1 deletion app/SH3/public/css/iconfont/iconfont.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
.icon-icon:before { content: "\e600"; }
.icon-warnfill:before { content: "\e607"; }
.icon-warn:before { content: "\e608"; }
.icon-shuaxin1:before { content: "\e616"; }
.icon-refresh:before { content: "\e616"; }
.icon-ok:before { content: "\e604"; }
.icon-h:before { content: "\e617"; }
.icon-lock:before { content: "\e61d"; }
.icon-off:before { content: "\e613"; }
.icon-on:before { content: "\e614"; }
.icon-search:before { content: "\e61c"; }
Expand All @@ -35,6 +36,7 @@
.icon-add:before { content: "\e60c"; }
.icon-folder:before { content: "\e618"; }
.icon-files:before { content: "\e619"; }
.icon-lock2:before { content: "\e61e"; }
.icon-timescircle:before { content: "\e60e"; }
.icon-earth:before { content: "\e61a"; }
.icon-move:before { content: "\e60f"; }
Expand Down
Binary file modified app/SH3/public/css/iconfont/iconfont.eot
Binary file not shown.
16 changes: 12 additions & 4 deletions app/SH3/public/css/iconfont/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 modified app/SH3/public/css/iconfont/iconfont.ttf
Binary file not shown.
Binary file modified app/SH3/public/css/iconfont/iconfont.woff
Binary file not shown.
14 changes: 12 additions & 2 deletions app/SH3/public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,18 @@ a:hover {
#pswd-form .body .ln .inform {
color: #f03;
}
#edit-form .body .ln .delete-host,
#pswd-form .body .ln .delete-host {
#edit-form .body .ln.actions a,
#pswd-form .body .ln.actions a {
display: inline-block;
margin-right: 2em;
color: #212121;
}
#edit-form .body .ln.actions a:hover,
#pswd-form .body .ln.actions a:hover {
color: #09f;
}
#edit-form .body .ln.actions a.delete-host,
#pswd-form .body .ln.actions a.delete-host {
color: #f03;
}
#edit-form .foot,
Expand Down
13 changes: 12 additions & 1 deletion app/SH3/public/css/style.styl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ bg_left=#373d47
bd_color=bg_left
bg_prompt=#f5f5f5
left_width=240
color_hover=#09f
color_on=#af9
color_off=font_color_left
color_danger=#f03
Expand Down Expand Up @@ -194,9 +195,19 @@ unselectable()
.inform
color color_danger

.delete-host
.ln.actions
a
display inline-block
margin-right 2em
color font_color

a:hover
color color_hover

a.delete-host
color color_danger


.foot
background bg_prompt
padding 16px 20px
Expand Down
14 changes: 10 additions & 4 deletions app/SH3/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,18 @@ <h2>{{ lang[add_or_edit + '_host'] }}</h2>
<option value="{{ opt[0] }}" v-for="opt in refresh_options">{{ opt[1] }}</option>
</select>
<span class="info">
{{ lang.last_refresh }}: {{ _current_edit_host.last_refresh || 'N/A' }}
{{ lang.last_refresh }}: {{ current_host.last_refresh || 'N/A' }}
</span>
</div>
<div class="ln" v-if="add_or_edit=='edit'">
<a href="#" class="delete-host" @click="delHost(current_edit_host)"><i class="iconfont icon-delete"></i>
{{ lang.del_host }}</a>
<div class="ln actions" v-if="add_or_edit=='edit'">
<a href="#" class="delete-host" @click="delHost(current_edit_host)">
<i class="iconfont icon-delete"></i>
{{ lang.del_host }}
</a>
<a href="#" class="refresh-host" @click="refreshHost(current_host)" v-if="current_edit_host.where=='remote'">
<i class="iconfont icon-refresh"></i>
{{ lang.refresh }}
</a>
</div>
</div>
<div class="foot">
Expand Down
14 changes: 7 additions & 7 deletions app/SH3/public/js/main.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion app/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"use strict";

module.exports = {
VERSION: '3.1.1'
VERSION: '3.1.2'
, bundle_version: 3081
, url_chk_version: 'http://oldj.github.io/SwitchHosts/v.txt'
, url_homepage: 'http://oldj.github.io/SwitchHosts/'
, url_feedback: 'https://github.com/oldj/SwitchHosts/issues'
Expand Down
2 changes: 2 additions & 0 deletions app/src/lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var languages = {
, bad_url: 'URL is not valid.'
, auto_refresh: 'Auto refresh'
, last_refresh: 'Last refresh'
, refresh: 'Refresh'
, never: 'never'
, hour: 'hour'
, hours: 'hours'
Expand Down Expand Up @@ -65,6 +66,7 @@ var languages = {
, bad_url: 'URL 地址有误。'
, auto_refresh: '自动更新'
, last_refresh: '上次更新'
, refresh: '刷新'
, never: '从不'
, hour: '小时'
, hours: '小时'
Expand Down
18 changes: 12 additions & 6 deletions app/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var app = new Vue({
},
refresh_options: [
[0, lang.never],
//[0.005, '0.005 ' + lang.hour],
[0.005, '0.005 ' + lang.hour],
[1, '1 ' + lang.hour],
[24, '1 ' + lang.day],
[24 * 7, '7 ' + lang.days]
Expand All @@ -50,7 +50,8 @@ var app = new Vue({
},
on_after_permission: [],
could_tmp_clean_on: true,
current_edit_host: {},
//_current_edit_host: {}, // 指向当前 host 对象
current_edit_host: {}, // 当前 host 对象的一个深拷贝
add_or_edit: '',
sudo_pswd: ''
},
Expand Down Expand Up @@ -124,7 +125,8 @@ var app = new Vue({
this.is_edit_show = true;

host.where = host.where || 'local';
this._current_edit_host = host;
this.log('edit ' + host.title + ', ' + host.last_refresh);
//this._current_edit_host = host;
this.current_edit_host = util.copyObj(host, true);
this.add_or_edit = 'edit';

Expand Down Expand Up @@ -183,6 +185,9 @@ var app = new Vue({
getRemoteHost: function (host) {
refresh.getRemoteHost(this, host);
},
refreshHost: function (host) {
this.getRemoteHost(host);
},
toSave: function () {
if (!this.chkHostTitle() || !this.chkHostUrl()) {
return;
Expand All @@ -192,7 +197,7 @@ var app = new Vue({
//if (this.hosts.list.indexOf(this.current_edit_host) > -1) {
if (this.add_or_edit == 'edit') {
// edit
util.updateObj(this._current_edit_host, this.current_edit_host);
//util.updateObj(this._current_edit_host, this.current_edit_host);
this.getRemoteHost(this.current_edit_host);
} else {
// add new
Expand Down Expand Up @@ -417,8 +422,8 @@ var app = new Vue({

checkRefresh: function () {
var _this = this;
var t = 60 * 5 * 1000;
//var t = 1000;
//var t = 60 * 5 * 1000;
var t = 1000;
refresh.checkRefresh(this);

setTimeout(function () {
Expand All @@ -442,6 +447,7 @@ var ui = require('./ui');
ui.init(app);

setTimeout(function () {
app.log('ccc');
app.checkRefresh();
}, 1000);

Expand Down
3 changes: 3 additions & 0 deletions app/src/refresh.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ function getRemoteHost(app, host) {
var now = moment().format('YYYY-MM-DD HH:mm:ss');
host.content = tpl.concat(['# UPDATE: ' + now, '', 'FAIL to get!', status]).join('\n');
host.last_refresh = now;
if (host == app.current_host) {
app.current_edit_host.last_refresh = now;
}
app.onCurrentHostChange(host);
app.doSave();
});
Expand Down
3 changes: 2 additions & 1 deletion app/src/stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
var url = 'http://lab.oldj.net/s.gif';
var queue = [];
var session_id = (new Date()).getTime() + ':' + Math.random();
var v = require('./config').VERSION;
var config = require('./config');
var v = [config.VERSION, config.bundle_version].join('.');

function record(action) {
queue.push(action);
Expand Down
11 changes: 9 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ gulp.task('zip', function () {
});

gulp.task('ver', function () {
var fn_config = './app/src/config.js';
const config = require('./app/src/config');

let c = fs.readFileSync(plist_fn, 'utf-8');
let m;
let v;
let v2;

m = c.match(/CFBundleShortVersionString[^\d]*?([\d\.]+)/);
if (!m) {
Expand All @@ -73,11 +75,16 @@ gulp.task('ver', function () {
return;
}
v = parseInt(m[1]);
console.log(`version: ${v} -> ${v + 1}`);
c = c.replace(/(CFBundleVersion[^\d]*?)(\d+)/, `$1${v + 1}`);
v2 = v + 1;
console.log(`version: ${v} -> ${v2}`);
c = c.replace(/(CFBundleVersion[^\d]*?)(\d+)/, `$1${v2}`);

//console.log(c);
fs.writeFileSync(plist_fn, c, 'utf-8');

c = fs.readFileSync(fn_config, 'utf-8');
c = c.replace(/(bundle_version:\s*)(\d+)/, `$1${v2}`);
fs.writeFileSync(fn_config, c, 'utf-8');
});

gulp.task('js', ['ver'], function () {
Expand Down

0 comments on commit 2716a69

Please sign in to comment.