Browse Source

修复刷新时的 bug;增加手动刷新功能。

oldj 10 years ago
parent
commit
fbf95cc7ce

+ 2 - 2
app/SH3/MacGap/SwitchHosts!-Info.plist

@@ -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>

+ 3 - 1
app/SH3/public/css/iconfont/iconfont.css

@@ -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"; }
@@ -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"; }

BIN
app/SH3/public/css/iconfont/iconfont.eot


+ 12 - 4
app/SH3/public/css/iconfont/iconfont.svg

@@ -2,7 +2,7 @@
 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
 <svg xmlns="http://www.w3.org/2000/svg">
 <metadata>
-Created by FontForge 20120731 at Sun Dec 27 20:06:29 2015
+Created by FontForge 20120731 at Sat Jan 16 15:09:10 2016
  By Ads
 </metadata>
 <defs>
@@ -19,7 +19,7 @@ Created by FontForge 20120731 at Sun Dec 27 20:06:29 2015
     bbox="0 -212 1024 896"
     underline-thickness="50"
     underline-position="-100"
-    unicode-range="U+0078-E61C"
+    unicode-range="U+0078-E61E"
   />
 <missing-glyph horiz-adv-x="374" 
 d="M34 0v682h272v-682h-272zM68 34h204v614h-204v-614z" />
@@ -109,8 +109,8 @@ t-9.5 22.5t9.5 22.5t22.5 9.5t22.5 -9.5t9.5 -22.5t-9.5 -22.5t-22.5 -9.5zM704 64q0
 t22.5 -9.5t9.5 -22.5t-9.5 -22.5t-22.5 -9.5zM864 704q-13 0 -22.5 9.5t-9.5 22.5t9.5 22.5t22.5 9.5t22.5 -9.5t9.5 -22.5t-9.5 -22.5t-22.5 -9.5zM576 704h-128q-26 0 -45 -19t-19 -45v-192q0 -26 19 -45t45 -19h128q27 0 45.5 18.5t18.5 45.5v192q0 27 -18.5 45.5
 t-45.5 18.5z" />
     <glyph glyph-name="uniE616" unicode="&#xe616;" 
-d="M504 -67q-97 0 -179.5 48t-130.5 130.5t-48 179.5q0 110 62 201l93 -93v245h-246l92 -92q-85 -116 -85 -261q0 -90 35 -171.5t94.5 -141t141 -94.5t171.5 -35q85 0 163 31l-50 71q-55 -18 -113 -18zM720 193v-246h246l-96 96q76 112 76 248q0 72 -22 139.5t-63 122
-t-95.5 95.5t-122 63t-139.5 22q-70 0 -136 -21l52 -73q41 10 84 10q98 0 180.5 -47.5t130 -130t47.5 -180.5q0 -101 -52 -187z" />
+d="M504 17q-97 0 -179.5 48t-130.5 130.5t-48 179.5q0 110 62 201l93 -93v245h-246l92 -92q-20 -27 -35.5 -57.5t-26.5 -63.5t-17 -68.5t-6 -71.5q0 -90 35 -171.5t94.5 -141t141 -94.5t171.5 -35q85 0 163 31l-50 71q-55 -18 -113 -18zM720 277v-246h246l-96 96
+q37 54 56.5 117t19.5 131q0 90 -35 172t-94 141t-141 94t-172 35q-70 0 -136 -21l52 -73q41 10 84 10q59 0 113.5 -18t98.5 -51t77 -77t51 -98.5t18 -113.5q0 -50 -13.5 -98t-38.5 -89z" />
     <glyph glyph-name="uniE617" unicode="&#xe617;" 
 d="M512 802q-104 0 -192.5 -51.5t-140 -140t-51.5 -193t51.5 -193t140 -140t192.5 -51.5t192.5 51.5t140 140t51.5 193t-51.5 193t-140 140t-192.5 51.5zM660 214h-50v175h-196v-175h-50v395h50v-179h196v179h50v-395z" />
     <glyph glyph-name="uniE618" unicode="&#xe618;" 
@@ -134,5 +134,13 @@ t12 16.5l82 244q7 22 -17 22zM609 191h-194v48h194v-48z" />
     <glyph glyph-name="uniE61C" unicode="&#xe61c;" 
 d="M995 3l-272 227q-1 1 -2 1.5t-4 2.5q37 79 37 160q0 82 -34.5 158t-99.5 131q-105 89 -243 89q-82 0 -158 -35t-131 -100q-43 -52 -65.5 -114.5t-22.5 -128.5q0 -82 34.5 -158.5t100.5 -131.5q105 -88 241 -88h1q121 0 221 72q1 0 2 -2l1 -1l272 -227q10 -9 23 -14
 t26.5 -5t26.5 3.5t25 11t21 19.5l6 7q24 28 22 64.5t-28 58.5zM585 219q-40 -47 -94.5 -72t-113.5 -25q-98 1 -174 64q-47 39 -72 94t-25 114q0 99 64 174q39 48 93.5 72.5t113.5 24.5q99 0 174 -63q47 -40 72 -94.5t25 -113.5q0 -99 -63 -175z" />
+    <glyph glyph-name="uniE61D" unicode="&#xe61d;" 
+d="M427 151q0 23 11 42.5t31 31t43 11.5q35 0 60 -25t25 -60q0 -11 -2.5 -22t-8 -20t-12.5 -16.5t-16 -13.5q1 -6 3 -16t6.5 -38.5t8.5 -55.5q0 -8 -4.5 -15.5t-11.5 -12t-16 -4.5h-64q-13 0 -22.5 9.5t-9.5 22.5l18 110q-39 25 -39 72zM341 385v150q0 23 6.5 45t17.5 41
+t26.5 34.5t34.5 26.5t41 17t45 6q46 0 85.5 -22.5t62.5 -62t23 -85.5v-150h-342zM235 535v-150h-64q-36 0 -61 -25t-25 -60v-427q0 -35 25 -60t61 -25h682q36 0 61 25t25 60v427q0 35 -25 60t-61 25h-64v150q0 115 -81 196t-196 81q-56 0 -107.5 -22t-88.5 -59t-59 -88.5
+t-22 -107.5z" />
+    <glyph glyph-name="uniE61E" unicode="&#xe61e;" 
+d="M769 448v135q-3 104 -77.5 176.5t-178.5 72.5q-51 0 -97.5 -19.5t-81 -52.5t-55 -79t-22.5 -97v-136h-1q-17 0 -32 -8.5t-23.5 -23.5t-8.5 -32v-384q0 -27 18.5 -45.5t45.5 -18.5h512q17 0 32 8.5t23.5 23.5t8.5 32v384q0 26 -18.5 45t-44.5 19zM321 581q2 78 58 132.5
+t134 54.5q31 0 60 -9.5t52 -26.5t41 -40t28 -51.5t11 -59.5v-133h-384v133zM768 32q0 -9 -4.5 -16t-11.5 -11.5t-16 -4.5h-448q-4 0 -8.5 1t-8 3t-6.5 5t-5 6.5t-3 8t-1 8.5v320q0 13 9.5 22.5t22.5 9.5h448q5 0 10 -1.5t9 -4.5t7 -7t4.5 -9t1.5 -10v-320zM544 206v52
+q0 13 -9.5 22.5t-22.5 9.5q-9 0 -16 -4.5t-11.5 -11.5t-4.5 -16v-52q-28 -18 -28 -51q0 -25 17.5 -42.5t42.5 -17.5t42.5 17.5t17.5 42.5q0 33 -28 51z" />
   </font>
 </defs></svg>

BIN
app/SH3/public/css/iconfont/iconfont.ttf


BIN
app/SH3/public/css/iconfont/iconfont.woff


+ 12 - 2
app/SH3/public/css/style.css

@@ -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,

+ 12 - 1
app/SH3/public/css/style.styl

@@ -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
@@ -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

+ 10 - 4
app/SH3/public/index.html

@@ -104,12 +104,18 @@
 					<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">

File diff suppressed because it is too large
+ 0 - 0
app/SH3/public/js/main.js


+ 2 - 1
app/src/config.js

@@ -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'

+ 2 - 0
app/src/lang.js

@@ -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'
@@ -65,6 +66,7 @@ var languages = {
         , bad_url: 'URL 地址有误。'
         , auto_refresh: '自动更新'
         , last_refresh: '上次更新'
+        , refresh: '刷新'
         , never: '从不'
         , hour: '小时'
         , hours: '小时'

+ 12 - 6
app/src/main.js

@@ -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]
@@ -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: ''
     },
@@ -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';
 
@@ -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;
@@ -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
@@ -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 () {
@@ -442,6 +447,7 @@ var ui = require('./ui');
 ui.init(app);
 
 setTimeout(function () {
+    app.log('ccc');
     app.checkRefresh();
 }, 1000);
 

+ 3 - 0
app/src/refresh.js

@@ -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();
     });

+ 2 - 1
app/src/stat.js

@@ -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);

+ 9 - 2
gulpfile.js

@@ -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) {
@@ -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 () {

Some files were not shown because too many files changed in this diff