#
酷派 全魔王 8298-M02用于測試的手機(jī),需要root,試了7兔,kingroot,百度root,root精靈,最后在完美root這個工具root成功了。這手機(jī),還不錯,算是性價比非常高的手機(jī)了,在京東618的時候,以389入手。由于活動的原因,今天才收到。看到很多人也在求root,在這里發(fā)一貼,希望對root的人有幫忙了。不過,這手機(jī),真的不錯,超值了。可以確定比某米4A強(qiáng)!質(zhì)量也比它的好。我去酷派官網(wǎng)看了一下,原價是1299的,哈。 另:完美root好像已經(jīng)停止進(jìn)展了~~~
補(bǔ)充:這個手機(jī),居然還送一年樂視會員!太強(qiáng)了
對于vscode,已經(jīng)更新到1.13了,更新的好快啊。有的時候,需要在Linux下面工作,所以我選擇了centos 7.x 廢話一下ubuntu,最新17.04,我試裝過不少版本(虛擬機(jī)下),最后就一個字卡。所以,每次都果斷放棄了。反過來說,centos 桌面,雖然很多東西不是很新,但是在虛擬機(jī)下,它一點(diǎn)都不卡。centos 7.x的GUI也非常不錯。 對于怎么安裝vscode,參考官方的https://code.visualstudio.com/docs/setup/linux 有詳細(xì)的說明。 對于centos則如下: - sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
- sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
然后用yum命令安裝 - yum check-update
- sudo yum install code
完成后,就可以用vscode了 后面附兩張centos 7.x的UI


centos 安裝nodejs主要有兩種方式,一種是源碼,第二種是二進(jìn)制安裝。 Linux系統(tǒng)一般來說,不追求新,而是追求穩(wěn)定。centos 下的軟件往往不是最新的,卻是相對比較穩(wěn)定的。我想這也是我們很多人選擇centos的原因。(最重要的一點(diǎn),是用習(xí)慣了centos或rhel) 現(xiàn)在Node.js已經(jīng)8.1.2的,發(fā)展很快。如果用源碼編譯至少需要gcc 4.8.x或clang 3.xx,對于centos 6.x(默認(rèn)是gcc 4.4.x)是一個麻煩的事,如果你僅是使用nodejs,nodejs編譯時間又比較長,所以我這里還是傾向于二進(jìn)制安裝。 本身centos的yum默認(rèn)是不帶的node的安裝包的,所以需要第三方方法。 大家可以看這個網(wǎng)站,https://github.com/nodesource/distributions 上面提供了ubuntu,debian,linux Mint,還有centos(rhel)等安裝方法。 我這里,使用安裝 nodejs 8.x 所以內(nèi)容如下 #要求在root下執(zhí)行 curl -sL https://rpm.nodesource.com/setup_8.x | bash - yum install -y nodejs
很簡單,我在centos 6.x下就完成了node.js 8.1.2的安裝。
版權(quán)聲明:本文為zdhsoft博主原創(chuàng)文章,未經(jīng)博主允許不得轉(zhuǎn)載。 因?yàn)檠b了Android studio 2.3 所以就默認(rèn)安裝了android sdk和NDK,用的NDK的版本是r10d x64。在安裝RAD Studio的時候,就沒有選擇安裝android的sdk和NDK,然后,用C++Builder創(chuàng)建MultDevice工程 ,編譯為android目標(biāo)就報如下錯: 
問是是arm-Linux-androideabi-ld.exe執(zhí)行報錯,而Delphi的版本,則沒有問題! 然后找到RAD Studio的安裝包,發(fā)現(xiàn)它有一個android-ndk.7zip的文件,然后用7z工具打開,發(fā)現(xiàn)里面是一個NDK r9c的版本,然后我就它提出出來,放到一個目錄,如:d:\ndk\r9c,然后配置RAD studio 



配置完成后,就可以編譯android了,接上手機(jī),就可以在真機(jī)上跑了 初步試用通過,感覺還是一個半成品的樣子!C++Builder代碼提示還是卡,有點(diǎn)改善的樣子。
版權(quán)聲明:本文為zdhsoft博主原創(chuàng)文章,未經(jīng)博主允許不得轉(zhuǎn)載。 N久沒有碰C++Builder,雖然他給了一個注冊碼,基本版的,但是一想我XE6,XE7的時候,那個版本,對于我128G的C盤都覺得不夠,反正裝完就少了幾十個G,C盤提示一下就變紅了有沒有。今天想看看,于是下載了一個10.2版本, 下載地址:http://altd.embarcadero.com/download/radstudio/10.2/delphicbuilder10_2.iso 安裝的時候,需要.net 3.5,我只能說,從C++Builder 6以后,就摔不開.net 然后就順利安裝完成。給我最大的驚喜是安裝的臨時文件都清理了,只需要11G就OK了!以前要是要30G以上,少于40G剩余空間,則會安裝不了。 先用delphi創(chuàng)建一個mult device 應(yīng)用,就隨便選了一個,如下圖: 
然后就直接編譯運(yùn)行,在Android運(yùn)行OK 當(dāng)一切都順利的時候,我接著用C++Builder創(chuàng)建一個同樣的工程 然后就報這樣的錯: 
所有的C++Builder的android應(yīng)用 ,都是同樣的錯誤,對于iOS和Linux,由于空間有限,就沒有選擇安裝。 對于win32程序,則暫時OK!
使用appium輸入中文,發(fā)現(xiàn)好慢!至少5秒以上,如果在這樣的情況下做測試,這就好悲劇了。 從appium(1.6.3)代碼上來看,沒有什么問題,直接是通過boostrap的setText的方法。說是就下載了appium-bootstrap的代碼看,從這里開發(fā)找到的代碼,都是java的代碼,找到 io.appium.android.bootstrap.handler.SetText 在new Clear().execute(command);時間長達(dá)5秒(打日志發(fā)現(xiàn)),不管文本框有沒有內(nèi)容,都會執(zhí)行 /* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
package io.appium.android.bootstrap.handler;
import com.android.uiautomator.core.UiDevice; import com.android.uiautomator.core.UiObjectNotFoundException; import com.android.uiautomator.core.UiSelector; import io.appium.android.bootstrap.*; import io.appium.android.bootstrap.exceptions.ElementNotFoundException; import io.appium.android.bootstrap.handler.Find; import org.json.JSONException;
import java.util.Hashtable;
/** * This handler is used to set text in elements that support it. * */ public class SetText extends CommandHandler {
/* * @param command The {@link AndroidCommand} used for this handler. * * @return {@link AndroidCommandResult} * * @throws JSONException * * @see io.appium.android.bootstrap.CommandHandler#execute(io.appium.android. * bootstrap.AndroidCommand) */ @Override public AndroidCommandResult execute(final AndroidCommand command) throws JSONException { AndroidElement el = null; if (command.isElementCommand()) { el = command.getElement(); Logger.debug("Using element passed in: " + el.getId()); } else { try { AndroidElementsHash elements = AndroidElementsHash.getInstance(); el = elements.getElement(new UiSelector().focused(true), ""); Logger.debug("Using currently-focused element: " + el.getId()); } catch (ElementNotFoundException e) { Logger.debug("Error retrieving focused element: " + e); return getErrorResult("Unable to set text without a focused element."); } } try { final Hashtable<String, Object> params = command.params(); boolean replace = Boolean.parseBoolean(params.get("replace").toString()); String text = params.get("text").toString(); boolean pressEnter = false; if (text.endsWith("\\n")) { pressEnter = true; text = text.replace("\\n", ""); Logger.debug("Will press enter after setting text"); } boolean unicodeKeyboard = false; if (params.get("unicodeKeyboard") != null) { unicodeKeyboard = Boolean.parseBoolean(params.get("unicodeKeyboard").toString()); } String currText = el.getText(); new Clear().execute(command); //不管有沒有,這里都會執(zhí)行 if (!el.getText().isEmpty()) { // clear could have failed, or we could have a hint in the field // we'll assume it is the latter Logger.debug("Text not cleared. Assuming remainder is hint text."); currText = ""; } if (!replace) { text = currText + text; } final boolean result = el.setText(text, unicodeKeyboard); if (!result) { return getErrorResult("el.setText() failed!"); } if (pressEnter) { final UiDevice d = UiDevice.getInstance(); d.pressEnter(); } return getSuccessResult(result); } catch (final UiObjectNotFoundException e) { return new AndroidCommandResult(WDStatus.NO_SUCH_ELEMENT, e.getMessage()); } catch (final Exception e) { // handle NullPointerException return getErrorResult("Unknown error"); } } } 然后,我們再看Clear的代碼 /* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * See the NOTICE file distributed with this work for additional * information regarding copyright ownership. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */
package io.appium.android.bootstrap.handler;
import android.graphics.Rect; import android.os.SystemClock; import android.view.InputDevice; import android.view.KeyCharacterMap; import android.view.KeyEvent; import com.android.uiautomator.core.UiObject; import com.android.uiautomator.core.UiObjectNotFoundException; import com.android.uiautomator.core.UiSelector; import io.appium.android.bootstrap.AndroidCommand; import io.appium.android.bootstrap.AndroidCommandResult; import io.appium.android.bootstrap.AndroidElement; import io.appium.android.bootstrap.CommandHandler; import io.appium.android.bootstrap.Logger; import io.appium.android.bootstrap.WDStatus; import io.appium.uiautomator.core.InteractionController; import io.appium.uiautomator.core.UiAutomatorBridge; import org.json.JSONException;
import java.lang.reflect.InvocationTargetException;
/** * This handler is used to clear elements in the Android UI. * * Based on the element Id, clear that element. * * UiAutomator method clearText is flaky hence overriding it with custom implementation. */ public class Clear extends CommandHandler {
/* * Trying to select entire text with correctLongClick and increasing time intervals. * Checking if element still has text in them and and if true falling back on UiAutomator clearText * * @param command The {@link AndroidCommand} * * @return {@link AndroidCommandResult} * * @throws JSONException * * @see io.appium.android.bootstrap.CommandHandler#execute(io.appium.android. * bootstrap.AndroidCommand) */ @Override public AndroidCommandResult execute(final AndroidCommand command) throws JSONException { if (command.isElementCommand()) { try { final AndroidElement el = command.getElement();
// first, try to do native clearing Logger.debug("Attempting to clear using UiObject.clearText()."); el.clearText(); //無條件都會執(zhí)行這塊。然后再分析clearText if (el.getText().isEmpty()) { return getSuccessResult(true); }
// see if there is hint text if (hasHintText(el)) { Logger.debug("Text remains after clearing, " + "but it appears to be hint text."); return getSuccessResult(true); }
// next try to select everything and delete Logger.debug("Clearing text not successful. Attempting to clear " + "by selecting all and deleting."); if (selectAndDelete(el)) { return getSuccessResult(true); }
// see if there is hint text if (hasHintText(el)) { Logger.debug("Text remains after clearing, " + "but it appears to be hint text."); return getSuccessResult(true); }
// finally try to send delete keys Logger.debug("Clearing text not successful. Attempting to clear " + "by sending delete keys."); if (sendDeleteKeys(el)) { return getSuccessResult(true); }
if (!el.getText().isEmpty()) { // either there was a failure, or there is hint text if (hasHintText(el)) { Logger.debug("Text remains after clearing, " + "but it appears to be hint text."); return getSuccessResult(true); } else if (!el.getText().isEmpty()) { Logger.debug("Exhausted all means to clear text but '" + el.getText() + "' remains."); return getErrorResult("Clear text not successful."); } } return getSuccessResult(true); } catch (final UiObjectNotFoundException e) { return new AndroidCommandResult(WDStatus.NO_SUCH_ELEMENT, e.getMessage()); } catch (final Exception e) { // handle NullPointerException return getErrorResult("Unknown error clearing text"); } } return getErrorResult("Unknown error"); }
private boolean selectAndDelete(AndroidElement el) throws UiObjectNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { Rect rect = el.getVisibleBounds(); // Trying to select entire text. TouchLongClick.correctLongClick(rect.left + 20, rect.centerY(), 2000); UiObject selectAll = new UiObject(new UiSelector().descriptionContains("Select all")); if (selectAll.waitForExists(2000)) { selectAll.click(); } // wait for the selection SystemClock.sleep(500); // delete it UiAutomatorBridge.getInstance().getInteractionController().sendKey(KeyEvent.KEYCODE_DEL, 0);
return el.getText().isEmpty(); }
private boolean sendDeleteKeys(AndroidElement el) throws UiObjectNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { String tempTextHolder = "";
// Preventing infinite while loop. while (!el.getText().isEmpty() && !tempTextHolder.equalsIgnoreCase(el.getText())) { // Trying send delete keys after clicking in text box. el.click(); // Sending delete keys asynchronously, both forward and backward for (int key : new int[] { KeyEvent.KEYCODE_DEL, KeyEvent.KEYCODE_FORWARD_DEL }) { tempTextHolder = el.getText(); final int length = tempTextHolder.length(); final long eventTime = SystemClock.uptimeMillis(); KeyEvent deleteEvent = new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, key, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 0, InputDevice.SOURCE_KEYBOARD); for (int count = 0; count < length; count++) { UiAutomatorBridge.getInstance().injectInputEvent(deleteEvent, false); } } }
return el.getText().isEmpty(); }
private boolean hasHintText(AndroidElement el) throws UiObjectNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { // to test if the remaining text is hint text, try sending a single // delete key and testing if there is any change. // ignore the off-chance that the delete silently fails and we get a false // positive. String currText = el.getText();
try { if (!el.getBoolAttribute("focused")) { Logger.debug("Could not check for hint text because the element is not focused!"); return false; } } catch (final Exception e) { Logger.debug("Could not check for hint text: " + e.getMessage()); return false; }
InteractionController interactionController = UiAutomatorBridge.getInstance().getInteractionController(); interactionController.sendKey(KeyEvent.KEYCODE_DEL, 0); interactionController.sendKey(KeyEvent.KEYCODE_FORWARD_DEL, 0);
return currText.equals(el.getText()); } }
再看看AndroidElement.clearText是什么樣的 public void clearText() throws UiObjectNotFoundException { el.clearTextField(); } 這個都就是com.android.uiautomator.core.UiObject.clearTextField 于是找再找到uiautomator的代碼再來分析(這個代碼需要下載andriod sdk,在對應(yīng)android版本的目錄下,會有源碼,也有uiautomator的源代碼),我這里的路徑是: Android\sdk\sources\android-19\com\android\uiautomator\core 在UiObject.java找到clearTextField實(shí)現(xiàn) /** * Clears the existing text contents in an editable field. * * The {@link UiSelector} of this object must reference a UI element that is editable. * * When you call this method, the method first sets focus at the start edge of the field. * The method then simulates a long-press to select the existing text, and deletes the * selected text. * * If a "Select-All" option is displayed, the method will automatically attempt to use it * to ensure full text selection. * * Note that it is possible that not all the text in the field is selected; for example, * if the text contains separators such as spaces, slashes, at symbol etc. * Also, not all editable fields support the long-press functionality. * * @throws UiObjectNotFoundException * @since API Level 16 */ public void clearTextField() throws UiObjectNotFoundException { Tracer.trace(); // long click left + center AccessibilityNodeInfo node = findAccessibilityNodeInfo(mConfig.getWaitForSelectorTimeout()); if(node == null) { throw new UiObjectNotFoundException(getSelector().toString()); } Rect rect = getVisibleBounds(node); getInteractionController().longTapNoSync(rect.left + 20, rect.centerY()); //長按 // check if the edit menu is open UiObject selectAll = new UiObject(new UiSelector().descriptionContains("Select all")); if(selectAll.waitForExists(50)) selectAll.click(); // wait for the selection SystemClock.sleep(250); //這里等250ms // delete it getInteractionController().sendKey(KeyEvent.KEYCODE_DEL, 0); } 相信大家,可以找到慢的原因了。這里做一次長按,然再再做全選,然后再sleep(250),還有一個selectAll.waitForExists(50), 這些都是耗費(fèi)時間的。 再找一下UiObject.java中setText的實(shí)現(xiàn) public boolean setText(String text) throws UiObjectNotFoundException { Tracer.trace(text); clearTextField(); return getInteractionController().sendText(text); }
發(fā)現(xiàn)這里又調(diào)用了一次clearTextField,這樣算來,設(shè)一次文本,都會清理兩次文本,于是,這時間就長了。 優(yōu)化:只需要將io.appium.android.bootstrap.handler.SetText中的new Clear().execute(command)去掉就可以了。
node進(jìn)步很快,一年前,我用的還是node 4.x LTS,現(xiàn)在都 node 6.x LTS了,而node 7.x也在開發(fā)中,node 8.x已經(jīng)也展開了。 node 6.x已經(jīng)到了node 6.10.2了,則7.x也到了7.9.0了 對比后,這里把發(fā)現(xiàn)的差異列一下 n次方運(yùn)算符 **例如 let a = 2 ** 3; console.log(a); //顯示為8 let b = 3; b **= 4; console.log(b); //顯示為81 let c = Function("return 5**2"); console.log(c()); //顯示為25
- 6.10.2 需要–harmony 標(biāo)志
- 7.9.0 支持
Object.values和Object.entries6.10.2支持Object.keys,但是不支持 values和entries let a = { a: 100, b: '2423423', c: 'jjj' }; let k = Object.keys(a); let v = Object.values(a); let e = Object.entries(a); console.log(k); //顯示為:[ 'a', 'b', 'c' ] console.log(v); //顯示為:[ 100, '2423423', 'jjj' ] console.log(e); //顯示為:[ [ 'a', 100 ], [ 'b', '2423423' ], [ 'c', 'jjj' ] ]
這個功能在很多地方,都很用了,可以不需要lodash了 - 6.10.2 需要–harmony 標(biāo)志
- 7.9.0 支持
String的padStart和padEnd在顯示時間的時候,我們需要對齊顯示 如2017-04-26 23:01:01這樣顯示比較整齊,如果顯示為2017-4-26 23:1:1就不好看了,之前都是我們自己寫pad函數(shù),但是node支持這個功能了 console.log('1'.padStart(2,'00')); //顯示為 '01' console.log('2'.padEnd(2,'00')); //顯示為 '20' console.log('1234'.padStart(10)); //顯示為 ' 1234' console.log('1234'.padEnd(10)); //顯示為 '1234 ' console.log('abc'.padEnd(10,'0123456789')); //顯示為 'abc0123456' console.log('abc'.padStart(10,'0123456789'));//顯示為 '0123456abc' //其它的使用辦法,大家就自己研究了
- 6.10.2 需要–harmony 標(biāo)志
- 7.9.0 需要–harmony 標(biāo)志
async和await這個是es2017最重要的特性了,有了它,寫異步程序就方便多了 //一個延時指定時間的函數(shù) async function aaa_sleep(time) { return new Promise(function (resolve) { setTimeout(() => { resolve(); console.log("finish", new Date()); }, time); }); } async function m() { console.log(new Date()); await aaa_sleep(2000); console.log(new Date()); } m(); //注意:await一定要在async函數(shù)中出現(xiàn),不然會報錯
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
等LTS版本出來了,就可以放棄babel來編譯了,可惜import引入模塊的方式,一直沒有被放到標(biāo)準(zhǔn)
基于vscode的node的ES2015(ES6)運(yùn)行環(huán)境搭建用了vscode也有一段時間了,在輕量級的開發(fā)環(huán)境,它的功能是最強(qiáng)的。跨平臺,不依賴Java, .net等,UI也很現(xiàn)代,運(yùn)行速度也相對比較快,占用內(nèi)存少,平板電腦的win10都可以輕松開發(fā)。 環(huán)境說明:- node.js 6.9.x
- vscode 1.11.2
- 操作系統(tǒng) win10 (win7之后的系統(tǒng),安裝方法應(yīng)該都一樣)
- 編譯插件:babel
第一步:安裝nodewww.nodejs.org 下載安裝包 6.x,默認(rèn)安裝 注意:在生產(chǎn)環(huán)境,建議使用LTS,比較穩(wěn)定,bug相對比較少。 下載后,一路默認(rèn)安裝就可以了 第二步:安裝vscodevscode我就不介紹了,去https://code.visualstudio.com/下載對應(yīng)的安裝包就可以了,寫這個文章的版本是1.11.2 下載后,一路默認(rèn)安裝就可以了 (如果是國產(chǎn)軟件,千萬不要一路默認(rèn)安裝,如百****du,會給你默認(rèn)安裝一個全家桶,占領(lǐng)你的啟動,瞬間讓你的電腦卡成翔) 第三步:安裝全局的babel在命令提示符下,輸入下面命令: npm install babel-cli babel-eslint -g
完成后,可以輸入 babel --version
可以顯示babel的版本號 第四步:用npm init創(chuàng)建工程如果已創(chuàng)建,則跳過 在控制臺下,建好工程目錄,如:d:\work\firstnode 然后進(jìn)入該目錄 d: cd d:\work\firstnode ppm init
完成node的工程創(chuàng)建 為了便于管理,我們將源代碼目錄放在lib目錄下面,或src目錄,在這里我用的是lib目錄 編譯后可以運(yùn)行的目錄放在build目錄下面 這樣就會有兩個目錄 d:\work\firstnode\lib d:\work\firstnode\build
第五步:安裝編譯插件在控制臺下,目錄為d:\work\firstnode安裝插件,輸入: npm install –save-dev babel-preset-eslatest-node6 第六步:編寫.babelrc //---------------------------------------------------------- { "presets": ["eslatest-node6"], "plugins": [ ] } //---------------------------------------------------------------
第七步:用vscode編寫代碼在控制臺并在d:\work\firstnode下面,輸入code .就可以打開當(dāng)前工程 或者先啟動vscode后,選擇打開文件夾,選擇這個目錄也可以。 在vscode的左邊的資源管理器,新建一個index.js放到lib目錄下面 //-------------index.js-------------------------------------- console.log("hello world"); //---------------------------------------------------------------
然后在控制臺下輸入命令 babel lib -d build\lib
就可以看到在build\lib目錄面,多了一個index.js 第八步:配置運(yùn)行用vscode選擇調(diào)試,調(diào)試顯示的是沒有配置,然后進(jìn)行配置,就會進(jìn)入vscode配置lanuch.json編輯 { // Use IntelliSense to learn about possible Node.js debug attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "啟動程序", "program": "${workspaceRoot}\\bulid\\lib\\index.js" }, { "type": "node", "request": "attach", "name": "附加到端口", "address": "localhost", "port": 5858 } ] }
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
將program改為${workspaceRoot}\bulid\lib\index.js就可以了,然后按F5就可以運(yùn)行了。 為了方便調(diào)試,修改package.json中的script,增加如下內(nèi)容 "scripts": { "build": "babel lib -d build/lib -s inline", "babelWatch":"babel lib/**/*.js -d build -w -s inline", "releaseBuild":"babel lib -d release/lib --no-comments --compact true --minified" },
然后在控制臺下,輸入npm run build就會執(zhí)行babel lib -d build/lib -s inline 這樣,就完成了node的vscode環(huán)境操作 第九步:最后- 除了配置了build,還配置了babelWatch,這樣就可以處于監(jiān)視狀態(tài),只要lib目錄下一有文件保存,就可以實(shí)時編譯到build目錄下面。-s inline則是生成sourceMap,這樣,用vscode斷點(diǎn)調(diào)試的時候,就可以正常的代碼位置。
- 另外:這個使用的插件是babel-preset-eslatest-node6,這個插件的作用是將ES2015或更ES2017的js代碼編譯成node 6.x支持的js代碼,而不是ES5,node 6.x已經(jīng)支持99%的ES2015了,這樣編譯后的代碼變化不大。
概述vscode是一個不錯的開源IDE,可以完全替代sublime,又是跨平臺,使用起來還比較方便.使用一段時間后,我覺得有些插件,值得推薦一下.我這里的開發(fā)環(huán)境是win10下vscode+Node.js 在vscode的主UI的左邊工具欄的最下邊,就是插件管理了,如下圖
 beautify這是一個代碼美化插件,一定要有 ESLint這是一個代碼檢查的插件,一定要有,很不錯.下面是我的配置使用.eslintrc module.exports = { "env": { "commonjs": true, "es6": true, "node": true }, parser: "babel-eslint", "parserOptions": { "sourceType": "module", }, "extends": "eslint:recommended", "rules": { "no-console": 0, "semi": [2, "always"], "no-this-before-super": 2, "no-var": 2, "no-cond-assign": 2, //禁止在條件表達(dá)式中使用賦值語句 "no-dupe-args": 2, //函數(shù)參數(shù)禁止重名 "no-dupe-keys": 2, "no-duplicate-case": 2, "no-extra-semi": 0, "no-constant-condition": 0, "no-ex-assign": 2, "no-func-assign": 2, "no-extra-semi": 2, "no-irregular-whitespace": 2, "no-negated-in-lhs": 2, "no-obj-calls": 2, "no-unreachable": 2, "use-isnan": 2, "default-case": 2, "no-invalid-this": 2, "consistent-return": 0, "valid-jsdoc": 2, "block-scoped-var": 0, "complexity": [2, 20], "require-yield": 0, "no-mixed-spaces-and-tabs": 2, //注釋格式要求JSDoc格式 "require-jsdoc": [2, { "require": { "FunctionDeclaration": true, "MethodDefinition": false, "ClassDeclaration": false } }], "linebreak-style": 0 } };
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
JavaScript (ES6) code snippets從node 6.x后,就支持JavaScript ES6很多語法了, 6.9.x開始,已經(jīng)支持99%的ES6了,所以這個插件很必要. 不能理解,node 6.x為什么不支持import Numbered Bookmarks一個書簽工具,還是很有必要的,但是感覺功能還比較弱 tortoise-svnSVN的集成插件,雖然都用Git了,但svn還是很不錯的 VSCode Great Icons這個是非常必要的,這個為每個文件類型增加了一個圖標(biāo),例得項目的目錄樹很直觀,這個一定要用. 最后上述是我常用的插件,還有很多新插件,還不清楚,等大家一起發(fā)現(xiàn),有好的,都推薦一下.
在很多聊天中,會有許多表情,這些表情都是類似”[微笑]”的這種,然后寫了一個正則表達(dá)式,保留在這里,便于以后使用中.這里的提取支持提取中文.在Node.js 6.10.2下運(yùn)行通過.
1 let testStr = "now [里斯本] [test002] [ddddd] [adfasd][3234]"; 2 3 function getFaceTag(message) { 4 let re = /\[([\u4e00-\u9fa5\w]+)\]/g; 5 let r = {fulltag:[],tags:[]}; 6 let m; 7 while(m = re.exec(message)) { 8 r.fulltag.push(m[0]); 9 r.tags.push(m[1]); 10 } 11 return r; 12 } 13 14 let k = getFaceTag(testStr); 15 console.log(k);
|