Skip to content

About

🔧 💘code-tools

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Error in user YAML: (<unknown>): mapping values are not allowed in this context at line 2 column 11
---
/*
 * @Author: xn213
 * @Date: 2019-09-13 20:40:01
 * @Last Modified by: xn213
 * @Last Modified time: 2019-10-13 23:00:50
 */
---

开发技巧和工具

开发技巧

Vue

  • 全局安装 vue-cli3
cnpm install -g @vue/cli

vue -V // 查看版本是否为3.x
  • 启动单个 vue 文件
// 安装扩展,此后可以快速启动单个vue文件

cnpm install -g @vue/cli-service-global

vue serve demo.vue

快速启动 demo 文件 // 如果 style 中 lang='scss' 则需要安装 sass 依赖 sass-loader

  • 使用 vue 2.x 的模板
cnpm install -g @vue/cli-init

// 安装这个模块就可以使用vue 2.x的模板:
vue init webpack my-project

Node

  • 管理 node 版本
cnpm install -g n // 安装模块n 这个模块是专门用来管理node.js版本的

n stable // 升级node.js到最新稳定版

n 后面也可以跟随版本号比如:
n v0.10.26
或
n 0.10.26
  • node 开启本地服务器: node / express
node server.js // 开启本地服务器
  • nodemon 自动更新服务 serve.js 变化
(sudo)(mac下加个sudo) npm i nodemon -g

 // 使用 nodemon 自动保存server.js 中的变化(监听就不用重启服务了)
  • serve 开启静态服务,
cnpm i serve -g

应用: <pro-name>/使用: serve -s dist

  • python37 启动一个本地服务器 项目文件夹下:
(python -m SimpleHTTPSever 8080) // 旧版

python -m http.server 8080

浏览器打开项目文件夹下的demo.html : 即 localhost:8080/demo.html

npm

  • 淘宝镜像
npm install -g cnpm --registry=https://registry.npm.taobao.org
  • 常用命令
npm -v                 # 显示版本,检查npm 是否正确安装。

npm install express    # 安装express模块

npm install -g express # 全局安装express模块

npm list               # 列出已安装模块

npm show express       # 显示模块详情

npm update             # 升级当前目录下的项目的所有模块

npm update express     # 升级当前目录下的项目的指定模块

npm update -g express  # 升级全局安装的express模块

npm uninstall XXX -S   # 删除XXX依赖
npm uninstall express  # 删除指定的模块
npm i bcrypt
npm i jsonwebtoken
  • 验证 token 使用 passport passport-jwt
npm i passport passport-jwt
  • vue 前后端连载 cnpm i concurrently

    // 后端项目放外面, 项目里面新建 vue 前端项目 client

    // 而后配置 vue/package.json 加 "start": "npm run serve"

    // 而后配置后端 package.json

"scripts": {
  "client-install": "npm install --prefix client", // 新加 client前端 install依赖的模块,代表启动的时候要装client依赖的模块(--prefix 前缀)
  "client": "npm start --prefix client", // npm start启动前端client项目 --prefix 告诉他启动路径 client
  "start": "node server.js",
  "server": "nodemon server.js",
  "dev": "concurrently \"npm run server\" \"npm run client\"" // dev前后连载名字 依赖concurrently 后面分别前后启动项目命令
},


开发工具

命令行 Terminal Emulator

常用命令:

    1. ls -l 在一行显示文件夹
    1. ls -il 在一行显示文件夹(第一列显示索引)
    1. ls -lt 按修改时间排序,正序显示
    1. ls -ltr 按修改时间排序,反序显示
  1. 本地生成秘钥 SSH: ssh-keygen -t rsa -C "yourEmail"

  2. Cmder.exe win 集成 git / 部分 linux 命令 官方下载 / 静态下载

    • 添加到鼠标右键 命令行: Cmder.exe /REGISTER ALL
  3. 命令行翻译小工具:

    • cnpm i fanyi -g
    • Useage: fanyi <要翻译的内容>

Git

  1. Git 安装包国内镜像下载

Chrome

  1. 极简插件: https://chrome.zzzmh.cn/

  2. 推荐插件:


VSCode

  1. 插件
  1. 主题

其他工具

  • 全局安装 sgo , 克隆各种官方文档到本地 离线阅读,

    将文档克隆到本地,通过 sgo 工具预览本地各种文档的。

npm install -g sgo # 安装 sgo
sgo --fallback index.html # 创建静态服务,预览网站

// 如: [cn.vuejs.org](git clone https://github.com/vuejs/cn.vuejs.org.git --depth 1 -b gh-pages)

    • React

git clone https://github.com/reactjs/zh-hans.reactjs.org.git --depth 1 -b gh-pages

cd zh-hans.reactjs.org # 进入目录

sgo --fallback index.html # 创建静态服务,预览网站
    • Vue

git clone https://github.com/vuejs/cn.vuejs.org.git --depth 1 -b gh-pages
    • Ant Design

git clone https://gitee.com/ant-design/ant-design.git --depth 1 -b gh-pages

# or

git clone https://github.com/ant-design/ant-design.git --depth 1 -b gh-pages
    • Ant Design Pro

git clone https://gitee.com/ant-design/ant-design-pro-site.git --depth 1 -b master

# or

git clone https://github.com/ant-design/ant-design-pro.git --depth 1 -b gh-pages
    • uiw

git clone https://gitee.com/uiw/uiw.git --depth 1 -b gh-pages

# or

git clone https://github.com/uiwjs/uiwjs.github.io.git --depth 1 -b master

博客创建工具

  1. hexo 使用 hexo 创建博客

    hexo 创建的博客 git 部署工具: 项目根目录安装

    cnpm i --save hexo-deployer-git
  2. hugo 使用 hugo 创建博客

    • 相对于 hexo, 简单, 不易出错
  3. VuePress - Vue 驱动的静态网站生成器 文档类型

# ...
# git push -f ...
cd -

git add .

git commit -m $1

git push origin master:master # 推到github上

About

🔧 💘code-tools

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors