LandingPage.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <div id="wrapper">
  3. <!--<img id="logo" src="~@/assets/logo.png" alt="electron-vue">-->
  4. <!--<main>-->
  5. <!--<div class="left-side">-->
  6. <!--<span class="title">-->
  7. <!--Welcome to your new project!-->
  8. <!--</span>-->
  9. <!--<system-information></system-information>-->
  10. <!--</div>-->
  11. <!--<div class="right-side">-->
  12. <!--<div class="doc">-->
  13. <!--<div class="title">Getting Started</div>-->
  14. <!--<p>-->
  15. <!--electron-vue comes packed with detailed documentation that covers everything from-->
  16. <!--internal configurations, using the project structure, building your application,-->
  17. <!--and so much more.-->
  18. <!--</p>-->
  19. <!--<button @click="open('https://simulatedgreg.gitbooks.io/electron-vue/content/')">Read the Docs</button><br><br>-->
  20. <!--</div>-->
  21. <!--<div class="doc">-->
  22. <!--<div class="title alt">Other Documentation</div>-->
  23. <!--<button class="alt" @click="open('https://electron.atom.io/docs/')">Electron</button>-->
  24. <!--<button class="alt" @click="open('https://vuejs.org/v2/guide/')">Vue.js</button>-->
  25. <!--<el-button></el-button>-->
  26. <!--</div>-->
  27. <!--</div>-->
  28. <!--</main>-->
  29. 当前连接设备数:{{hasConnectCount}} <br/>
  30. <el-button @click="startSetZero" :disabled="hasConnectCount == 0">开始取零</el-button>
  31. <el-button @click="stopSetZero" :disabled="hasConnectCount == 0">停止取零</el-button>
  32. <el-button @click="startCollection" :disabled="hasConnectCount == 0">开始采集</el-button>
  33. <el-button @click="stopCollection" :disabled="hasConnectCount == 0">停止采集</el-button>
  34. <el-button @click="resetDevice" :disabled="hasConnectCount == 0">复位</el-button>
  35. <el-button @click="toConfig" :disabled="hasConnectCount == 0">跳转至配置</el-button>
  36. <el-button @click="toBlueToothSend" :disabled="deviceStatus != 'deviceSuccess'" >跳转至蓝牙发送</el-button>
  37. <el-button @click="toRealTimeBluetooth" >跳转至 实时蓝牙</el-button>
  38. <br/>
  39. <div style="width:540px;height:540px;position:relative;margin-top:30px" >
  40. <div ref="heatsample" style="width:540px;height:540px;position:absolute;top:0;left:0" />
  41. <chart id="heatmap" style="width:540px;height:540px;position:absolute;top:0" ref="heatmap"></chart>
  42. </div>
  43. </div>
  44. </template>
  45. <script>
  46. function toArrayBuffer(buf) {
  47. var ab = new ArrayBuffer(buf.length);
  48. var view = new Uint8Array(ab);
  49. for (var i = 0; i < buf.length; ++i) {
  50. view[i] = buf[i];
  51. }
  52. return ab;
  53. }
  54. import h337 from "heatmap.js";
  55. import {mapState, mapGetters} from "vuex";
  56. export default {
  57. name: 'landing-page',
  58. data(){
  59. return {
  60. h337:null
  61. }
  62. },
  63. methods: {
  64. open (link) {
  65. this.$electron.shell.openExternal(link)
  66. },
  67. // 开始取零
  68. startSetZero() {
  69. this.$socket.emit('startSetZero','setZero')
  70. },
  71. // 停止取零
  72. stopSetZero() {
  73. this.$socket.emit('stopSetZero','setZero')
  74. },
  75. // 开始采集
  76. startCollection () {
  77. this.$socket.emit('startCollection','startCollection')
  78. },
  79. // 停止采集
  80. stopCollection() {
  81. this.$socket.emit('stopCollection','stopCollection')
  82. },
  83. // 复位
  84. resetDevice() {
  85. this.$socket.emit('resetDevice','resetDevice')
  86. this.h337.setData({
  87. max: 255,
  88. data: {}
  89. });
  90. },
  91. // 跳转至配置
  92. toConfig() {
  93. this.$router.push('/config')
  94. },
  95. toBlueToothSend() {
  96. this.$router.push('/blueTooth')
  97. },
  98. toRealTimeBluetooth() {
  99. this.$router.push('/rt_ble')
  100. }
  101. },
  102. mounted() {
  103. this.$socket.emit('syncConnectCount','resetDevice')
  104. setTimeout(()=>{
  105. var gradient = require('../assets/heatmap_gradient.json')
  106. var dst = this.$refs.heatsample;
  107. var heatmap = h337.create({
  108. container: dst,
  109. radius:6,
  110. blur:0.7,
  111. gradient: gradient
  112. });
  113. this.h337 = heatmap;
  114. },1000)
  115. // var buf = Buffer.from('ab1c')
  116. // console.log(buf.toString('hex'))
  117. // console.log(toArrayBuffer(buf))
  118. },
  119. computed:{
  120. ...mapGetters([
  121. 'hasConnectCount',
  122. 'pressureData',
  123. 'deviceStatus',
  124. ]),
  125. },
  126. watch:{
  127. pressureData:function (val) {
  128. if(this.h337 != null) {
  129. this.h337.setData({
  130. max: 255,
  131. data: val
  132. });
  133. }
  134. },
  135. // 监听蓝牙服务是否成功开启
  136. deviceStatus:function (val) {
  137. if(val == 'deviceSuccess') {
  138. this.$notify({
  139. title: '提示',
  140. message: '蓝牙服务开启成功',
  141. duration: 3500
  142. });
  143. } else if(val == 'noUsb') {
  144. this.$notify({
  145. title: '提示',
  146. message: '请插入蓝牙适配器后重启软件',
  147. duration: 0
  148. });
  149. } else if(val == 'deviceError') {
  150. this.$notify({
  151. title: '提示',
  152. message: '请安装插件识别的蓝牙驱动后重启软件',
  153. duration: 0
  154. });
  155. }
  156. }
  157. }
  158. }
  159. </script>
  160. <style>
  161. @import url('https://fonts.googleapis.com/css?family=Source+Sans+Pro');
  162. * {
  163. box-sizing: border-box;
  164. margin: 0;
  165. padding: 0;
  166. }
  167. body { font-family: 'Source Sans Pro', sans-serif; }
  168. #wrapper {
  169. background:
  170. radial-gradient(
  171. ellipse at top left,
  172. rgba(255, 255, 255, 1) 40%,
  173. rgba(229, 229, 229, .9) 100%
  174. );
  175. height: 700px;
  176. padding: 60px 80px;
  177. width: 100vw;
  178. }
  179. #logo {
  180. height: auto;
  181. margin-bottom: 20px;
  182. width: 420px;
  183. }
  184. main {
  185. display: flex;
  186. justify-content: space-between;
  187. }
  188. main > div { flex-basis: 50%; }
  189. .left-side {
  190. display: flex;
  191. flex-direction: column;
  192. }
  193. .welcome {
  194. color: #555;
  195. font-size: 23px;
  196. margin-bottom: 10px;
  197. }
  198. .title {
  199. color: #2c3e50;
  200. font-size: 20px;
  201. font-weight: bold;
  202. margin-bottom: 6px;
  203. }
  204. .title.alt {
  205. font-size: 18px;
  206. margin-bottom: 10px;
  207. }
  208. .doc p {
  209. color: black;
  210. margin-bottom: 10px;
  211. }
  212. .doc button {
  213. font-size: .8em;
  214. cursor: pointer;
  215. outline: none;
  216. padding: 0.75em 2em;
  217. border-radius: 2em;
  218. display: inline-block;
  219. color: #fff;
  220. background-color: #4fc08d;
  221. transition: all 0.15s ease;
  222. box-sizing: border-box;
  223. border: 1px solid #4fc08d;
  224. }
  225. .doc button.alt {
  226. color: #42b983;
  227. background-color: transparent;
  228. }
  229. </style>