11<template >
2- <div id =" main" v-loading.fullscreen.lock =" fullscreenLoading" element-loading-text =" 解压中" >
2+ <div
3+ id =" main"
4+ v-loading.fullscreen.lock =" fullscreenLoading"
5+ element-loading-text =" 解压中"
6+ >
37 <el-row >
4- <el-col :lg =" {span:8,offset:8}" :md =" {span:8,offset:6}" >
5- <img id =" logo" src =" @/assets/jumpserver-menu-logo.png" alt =" electron-vue" />
8+ <el-col
9+ class =" main-col"
10+ :lg =" {span:8,offset:8}"
11+ :md =" {span:8,offset:6}"
12+ >
13+ <img
14+ id =" logo"
15+ src =" @/assets/jumpserver-menu-logo.png"
16+ alt =" electron-vue"
17+ />
618 </el-col >
7- <el-col :lg =" {span:8,offset:9}" :md =" {span:8,offset:7}" >
19+ <el-col
20+ class =" main-col"
21+ :lg =" {span:8,offset:9}"
22+ :md =" {span:8,offset:7}"
23+ >
824 <el-upload
925 class =" upload-demo"
1026 drag
1127 action =" "
1228 :show-file-list =' false'
13- :http-request =" checkfiletype "
29+ :http-request =" checkFileType "
1430 >
15- <i class =" el-icon-upload" ></i >
16- <div class =" el-upload__text" >将文件拖到此处,或<em >点击上传</em ></div >
17- <div class =" el-upload__tip" slot =" tip" >只能上传录像文件,且不超过500mb</div >
31+ <i class =" el-icon-upload" />
32+ <div class =" el-upload__text" >
33+ 将文件拖到此处,或<em >点击上传</em >
34+ </div >
35+ <div class =" el-upload__tip" slot =" tip" >
36+ 只能上传录像文件,且不超过500mb
37+ </div >
1838 </el-upload >
1939 </el-col >
20- <el-col v-if =" version === 1" :lg =" {span:8,offset:10}" :md =" {span:8,offset:9}" style =" margin-top :20px ;" >
40+ <el-col
41+ v-if =" version === 1"
42+ :lg =" {span:8,offset:10}"
43+ :md =" {span:8,offset:9}"
44+ style =" margin-top :20px ;"
45+ >
2146 <el-radio v-model =" type" label =" 1" >Linux录像</el-radio >
2247 <el-radio v-model =" type" label =" 2" >Windows录像</el-radio >
2348 </el-col >
24- <el-col v-if =" version === 1" :lg =" {span:4,offset:12}" :md =" {span:4,offset:11}" style =" margin-top :20px ;" >
49+ <el-col
50+ v-if =" version === 1"
51+ :lg =" {span:4,offset:12}"
52+ :md =" {span:4,offset:11}"
53+ style =" margin-top :20px ;"
54+ >
2555 <el-button round @click =" play" type =" primary" >播放</el-button >
2656 </el-col >
2757 </el-row >
@@ -39,13 +69,11 @@ export default {
3969 data () {
4070 return {
4171 type: ' 0' ,
42- ispushed : false ,
72+ isPushed : false ,
4373 filename: ' ' ,
4474 fullscreenLoading: false ,
4575 version: Number ,
4676 jsonData: ' '
47- // version 1 旧版本
48- // version 2 新版本
4977 }
5078 },
5179 methods: {
@@ -57,66 +85,68 @@ export default {
5785 // 解压文件
5886 // 1. 解压tar.gz
5987 // 2. 解压gz
60- checkfiletype : function (data ) {
88+ checkFileType : function (data ) {
6189 const configDir = (electron .app || electron .remote .app ).getPath (' userData' )
62- if (data .file .name .substring (data .file .name .length - 3 , data .file .name .length ) === ' tar' ) {
63- this .filename = data .file .name .substring (0 , data .file .name .length - 4 )
90+ const fileName = data .file .name
91+ const fileNameLength = fileName .length
92+ if (fileName .substring (fileNameLength - 3 , fileNameLength) === ' tar' ) {
93+ this .filename = fileName .substring (0 , fileNameLength - 4 )
6494 compressing .tar .uncompress (data .file .path , configDir).then ((files ) => {
6595 this .version = 2
66- const exists = fs .existsSync ((configDir + ' /' + this .filename + ' .replay.gz' ))
96+ let condensedFilePath = (configDir + ' /' + this .filename + ' .replay.gz' )
97+ const exists = fs .existsSync (condensedFilePath)
6798 if (exists) {
6899 this .type = ' 1'
69- this .uploadfile (this .filename , (configDir + ' /' + this .filename + ' .replay.gz' ))
70100 } else {
71101 this .type = ' 0'
72- this . uploadfile ( this . filename , ( configDir + ' /' + this .filename + ' .cast.gz' ))
102+ condensedFilePath = configDir + ' /' + this .filename + ' .cast.gz'
73103 }
104+ this .uploadFile (this .filename , condensedFilePath)
74105 })
75- } else if (data . file . name . substring (data . file . name . length - 2 , data . file . name . length ) === ' gz' ) {
76- this .filename = data . file . name . substring (0 , data . file . name . length - 6 )
106+ } else if (fileName . substring (fileNameLength - 2 , fileNameLength ) === ' gz' ) {
107+ this .filename = fileName . substring (0 , fileNameLength - 6 )
77108 this .version = 1
78- this .uploadfile (this .filename , data .file .path )
109+ this .uploadFile (this .filename , data .file .path )
79110 } else {
80111 this .$message .error (' 录像文件错误' )
81112 }
82113 },
83- unzipfile : function () {
114+ unzipFile : function () {
84115
85116 },
86- uploadfile : function (filename , filepath ) {
117+ uploadFile : function (filename , filepath ) {
87118 const configDir = (electron .app || electron .remote .app ).getPath (' userData' )
88119 compressing .gzip .uncompress (filepath, (configDir + ' /' + filename))
89120 .then (files => {
90121 this .fullscreenLoading = true
91122 if (this .version === 2 ) {
92- console .log (' uploadfile ' )
93- let jsonpeth = (configDir + ' /' + this .filename + ' .json' )
94- fs .readFile (jsonpeth , ' utf-8' , (_ , basicdata ) => {
123+ console .log (' uploadFile ' )
124+ let jsonPath = (configDir + ' /' + this .filename + ' .json' )
125+ fs .readFile (jsonPath , ' utf-8' , (_ , basicData ) => {
95126 try {
96- this .jsonData = JSON .parse (basicdata )
127+ this .jsonData = JSON .parse (basicData )
97128 } catch (e) {
98129 this .$message .error (' Json解析错误' )
99130 }
100- if (this .jsonData .protocol === ' rdp' ) {
131+ if (this .jsonData .protocol === ' rdp' || this . jsonData . protocol === ' vnc ' ) {
101132 this .type = ' 2'
102133 }
103134 })
104135 }
105136 return this .delay (5000 ).then (() => {
106137 this .fullscreenLoading = false
107- this .ispushed = true
138+ this .isPushed = true
108139 if (this .version === 1 ) {
109140 this .$message .warning (' 1.5.6以前版本的录像,请选择录像类型' )
110141 } else { this .play () }
111142 }
112143 )
113- })
114- .catch (() => {
144+ }).catch (() => {
115145 this .$message .error (' 压缩和录像文件不符, 请重试' )
116146 })
117147 },
118148 play : function () {
119- if (! this .ispushed ) {
149+ if (! this .isPushed ) {
120150 this .$message .error (' 请先上传文件' )
121151 return
122152 }
@@ -145,18 +175,24 @@ body {
145175}
146176
147177#main {
178+ display : flex ;
179+ justify-content : center ;
180+ align-items : center ;
181+ height : 100vh ;
182+ width : 100vw ;
148183 background : radial-gradient (
149184 ellipse at top left ,
150185 rgb (47 , 64 , 80 ) 40% ,
151186 rgb (103 , 106 , 108 ) 100%
152187 );
153- height : 100vh ;
154- padding : 60px 80px ;
155- width : 100vw ;
156188}
157189#logo {
158190 height : auto ;
159- margin-bottom : 20px ;
160191 width : 420px ;
192+ margin-top : -20px ;
193+ margin-bottom : 20px ;
194+ }
195+ .main-col {
196+ text-align : center ;
161197}
162198 </style >
0 commit comments