浏览代码

Handle the jumping problem of the line being edited. #277

oldj 7 年之前
父节点
当前提交
7c702662bb
共有 8 个文件被更改,包括 268 次插入123 次删除
  1. 10 9
      app-ui/App.jsx
  2. 3 2
      app-ui/events/save.js
  3. 246 88
      app-ui/styles/main.css
  4. 2 2
      app/package.json
  5. 0 1
      app/ui/app.css
  6. 0 1
      app/ui/app.js
  7. 1 1
      app/version.js
  8. 6 19
      package.json

+ 10 - 9
app-ui/App.jsx

@@ -121,7 +121,7 @@ export default class App extends React.Component {
     clearTimeout(this._t)
 
     this._t = setTimeout(() => {
-      Agent.emit('save', this.state.list)
+      Agent.emit('save', this.state.list, null, true)
     }, 1000)
   }
 
@@ -129,14 +129,15 @@ export default class App extends React.Component {
     let {current, list} = this.state
     if (current.content === v) return // not changed
 
-    current = Object.assign({}, current, {
-      content: v || ''
-    })
-    list = list.slice(0)
-    let idx = list.findIndex(i => i.id === current.id)
-    if (idx !== -1) {
-      list.splice(idx, 1, current)
-    }
+    //current = Object.assign({}, current, {
+    //  content: v || ''
+    //})
+    //list = list.slice(0)
+    //let idx = list.findIndex(i => i.id === current.id)
+    //if (idx !== -1) {
+    //  list.splice(idx, 1, current)
+    //}
+    current.content = v
 
     this.setState({
       current,

+ 3 - 2
app-ui/events/save.js

@@ -6,11 +6,12 @@
 'use strict'
 
 import Agent from '../Agent'
+
 const updated = require('./list_updated')
 
-module.exports = (app, list, hosts = null) => {
+module.exports = (app, list, hosts = null, skip_update = false) => {
   return Agent.pact('saveHosts', list)
-    .then(new_list => updated(app, new_list, hosts))
+    .then(new_list => skip_update || updated(app, new_list, hosts))
     //.then(() => {
     //  console.log('saved.', hosts && hosts.content.substring(0, 50))
     //})

文件差异内容过多而无法显示
+ 246 - 88
app-ui/styles/main.css


+ 2 - 2
app/package.json

@@ -1,6 +1,6 @@
 {
   "name": "switchhosts",
-  "version": "3.3.9",
+  "version": "3.3.10",
   "description": "Switch hosts quickly!",
   "main": "main.js",
   "scripts": {
@@ -16,4 +16,4 @@
     "node-notifier": "^5.2.1",
     "request": "^2.85.0"
   }
-}
+}

文件差异内容过多而无法显示
+ 0 - 1
app/ui/app.css


文件差异内容过多而无法显示
+ 0 - 1
app/ui/app.js


+ 1 - 1
app/version.js

@@ -1 +1 @@
-exports.version = [3,3,9,5343];
+exports.version = [3,3,10,5344];

+ 6 - 19
package.json

@@ -1,6 +1,6 @@
 {
   "name": "switchhosts",
-  "version": "3.3.9",
+  "version": "3.3.10",
   "description": "Homepage: [https://oldj.github.io/SwitchHosts/](https://oldj.github.io/SwitchHosts/)",
   "main": "",
   "scripts": {
@@ -108,29 +108,16 @@
     "yargs": "^6.5.0"
   },
   "ava": {
-    "files": [
-      "src/**/*.ava.js",
-      "test/*.js",
-      "!**/node_modules/**/*.*"
-    ],
-    "source": [
-      "**/*.{js,jsx}",
-      "!dist/**/*"
-    ],
+    "files": ["src/**/*.ava.js", "test/*.js", "!**/node_modules/**/*.*"],
+    "source": ["**/*.{js,jsx}", "!dist/**/*"],
     "match": [],
     "concurrency": 5,
     "failFast": true,
     "tap": true,
     "powerAssert": false,
-    "require": [
-      "babel-polyfill",
-      "babel-register"
-    ],
+    "require": ["babel-polyfill", "babel-register"],
     "babel": {
-      "presets": [
-        "latest",
-        "stage-0"
-      ]
+      "presets": ["latest", "stage-0"]
     }
   }
-}
+}

部分文件因为文件数量过多而无法显示