# iot-mqtt-vue **Repository Path**: wugemen/iot-mqtt-vue ## Basic Information - **Project Name**: iot-mqtt-vue - **Description**: 对接iot-mqtt-demo后端 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2021-12-06 - **Last Updated**: 2022-04-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # vue展示mqtt后台数据 ------------------------ #### 技术栈 vue2 + vuex + vue-router + webpack + ES6/7 + axios + elementUI + 阿里图标iconfont #### 说明 > 本项目主要用于对接第三方平台 > 为了方便后期修改使用,具体修改看下面【强调】 > 开发环境 w10 Chrome #### 目录结构 ------------------------ ```bash ├── /build/ # 项目构建(webpack)相关配置 ├── /config/ # 项目开发环境配置 ├── /src/ # 源码目录 │ ├── /api/ # 请求 │ ├── /assets/ # 组件静态资源(图片) │ ├── /components/ # 公共组件 | ├── /api/ # 请求接口 │ ├── /router/ # 路由配置 │ ├── /vuex/ # vuex状态管理 │ ├── /views/ # 路由组件(页面维度) │ ├── /config/ # 接口配置文件(请求地址) │ ├── App.vue # 组件入口 │ └── main.js # 程序入口 ├── /static/ # 非组件静态资源 ├── .babelrc # ES6语法编译配置 ├── .editorconfig # 定义代码格式 ├── .eslintignore # ES6规范忽略文件 ├── .eslintrc.js # ES6语法规范配置 ├── .gitignore # git忽略文件 ├── index.html # 页面入口 ├── package.json # 项目依赖 └── README.md # 项目文档 ``` #### 强调 webSocket地址端口在index.html中,请根据实际后端配置修改 ```html ``` 接口地址需要修改config/index.js文件 dev ``` bash proxyTable: { '/api': { target: 'http://xxx.xxx.xxx.xxx:xxx', // 你请求的第三方接口 changeOrigin: true, // 在本地会创建一个虚拟服务端,然后发送请求的数据,并同时接收请求的数据,这样服务端和服务端进行数据的交互就不会有跨域问题 pathRewrite: { // 路径重写, '^/api': '/api' // 替换target中的请求地址 } } }, ``` #### 完成功能 - [x] 登录 -- 完成 - [x] 路由拦截 -- 完成 - [x] 实时数据展示(搜索、控制变量) -- 完成 #### 运行项目 ------------------------ ``` bash # 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 # run unit tests npm run unit # run e2e tests npm run e2e # run all tests npm test ``` #### Nginx部署 1、运行npm run build 生成dist文件夹 2、把dist文件夹下的文件(static目录,index.html)拷贝到nginx根目录下,比如(/usr/share/nginx/html) 3、修改nginx.conf 配置文件,如果该文件末尾显示include /etc/nginx/conf.d/*.conf;,请在/conf.d/default.conf中添加配置,配置后台转发路径如下: ```bash location ^~/etung_iot/ { proxy_pass http://127.0.0.1:8989; } ``` 4、重启nginx