Network and Information Management Organization - SJTU
Node v8.9.4 LTS
JavaScript 运行时
附带 npm v5.6.0
Node的包管理器
Windows官网下载安装
Linux可先安装nvm,再使用nvm安装node
更新记录
v7.10.1
统一升至v8.9.4
没有发现坑。升级后新增package-lock.json
用于锁定依赖版本。请注意升级node后需要运行npm install
重新安装依赖
把这个项目clone到本地
进入项目目录
cd oscope
Build Setup
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
# build for production and view the bundle analyzer report
npm run build --report
For a detailed explanation on how things work, check out the guide and docs for vue-loader.
安装vue-cli
Vue.js
官方文档
开发时使用的版本为
v2.9.2
,已经出现v3.0.0-alpha
,具体差异不详。但开发过程中曾重新构建过一次项目,产生的差异包括:
- Windows下热更新不稳定问题得到解决
- ESlint增加了对不规则空格的检查(见下文项目配置-ESLint)
但产生差异的具体原因不详(LuminousXLB@2018-2-6)
运行vue init webpack oscope
模板配置
? Project name # 如实 oscope
? Project description # 如实
? Author LuminousXLB # 如实 NIMOweb2016
? Vue build # 默认 Runtime + Compiler
? Install vue-router? # 默认 Y
? Use ESLint to lint your code? # 默认 Y
? Pick an ESLint preset (Use arrow keys)
# 默认 Standard
? Set up unit tests # 取消 n 目前没有使用单元测试,如果认为有必要的话可以加装单元测试模块
? Setup e2e tests with Nightwatch?
# 取消 n 目前没有使用自动化测试,如果认为有必要的话可以加装自动化测试模块
? Should we run `npm install` for you after the project has been created?
# Yes, use NPM
参见package.json
在package.json中记录的依赖可以使用
npm install
自动安装
vue v2.6.10
vuex v3.0.1
状态管理vue-router v3.0.1
路由管理axios v0.17.1
请求promise.prototype.finally v3.1.0
element-ui v2.9.2
UI框架material-design-icons v3.0.1
图标库
clipboard v2.0.4
复制到剪贴板marked v0.3.16
markdown渲染引擎,用于公告渲染moment v2.20.1
日期时间处理vue-cropperjs v2.2.0
图片裁剪插件,用于头像处理compressorjs v1.0.5
压缩头像,防止上传时超出后端大小限制webpack v3.6.0
eslint v4.15.0
随着Webpack和Vue模板的升级,这里的配置可能产生差异,请以实际情况为准
/flags.js
module.exports = {
// target: 'development' or 'production'
target: 'development',
// `console.log` will have no effect if `logger` is false
logger: true,
// dev-server warning will be enabled if set to true
devserver: true,
// lazy-load will be enabled if set to true
lazyload: false,
// host for backend dev server. `static` need to be linked first.
backendDevServerHost: 'http://localhost:8000/'
}
.gitignore
,避免并线后项目状态混乱target: development
vs target: production
/config/index.js
修改dev
中的poll
键,可设置文件系统监视的轮询间隙(默认设置不使用轮询,经常出问题);
proxyTable
键,可设置前端开发服务器对后端的代理,详见代码。
/build/webpack.base.conf.js
在development环境下同步加载全部的组件,在production环境下使用懒加载
module.exports = {
resolve: {
alias: {
'%load%': process.env.NODE_ENV === 'production'
? path.join(resolve('src'), 'router', 'lazyload')
: path.join(resolve('src'), 'router', 'hotload')
}
}
}
具体的实现见/router/modules/
.eslintignore
ESLint忽略的文件
增加/src/components/Experiment/
Experiment
模块是在开发过程中用于尝试的playground即使不加也没啥关系,只是会在尝试的过程中保留各种格式上的限制
.eslintrc.js
ESLint配置
在rules
下增加
'camelcase': 'off'
取消js必须使用驼峰命名法的限制。原因是后端API的相应有很多字段使用了下划线命名法,在开发过程中强制使用驼峰命名法可能造成各种不便。但仍然建议在其他情况下使用驼峰命名法。
.DS_Store # macOS的隐藏文件
node_modules/ # npm安装的包,不要加在git里面。文件又多又杂,不需要人为修改,可以自动构建
dist/ # 项目编译的输出文件
fixtures/* # 已经弃用,此前准备用作测试用数据的储存
npm-debug.log* # npm运行失败的log
yarn-debug.log* # yarn的log,我们没用yarn,应该是早期自动生成的,现在已经没有了
yarn-error.log* # 同上
!dist/app.py # 开发初期曾经使用过flask作调试过程中的后端服务器。这就是之前做的
.vscode/* # vscode配置文件
flags.js # 项目配置文件
插件
配置
{
"editor.tabSize": 2,
"files.eol": "\n",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"element-helper.version": "2.5",
"vetur.format.defaultFormatter.js": "vscode-typescript",
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"typescript.format.insertSpaceBeforeFunctionParenthesis": true
}
vscode-element-helper
可能尚不支持当前的element-ui
版本,视情况设置一个较新的即可。
其他推荐插件
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。