全部修改架构
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
<div class="absolute elec-qty-border"></div>
|
||||
<div class="elec-txt"></div>
|
||||
</div>
|
||||
<i class="el-icon-user-solid icon-user" :style="{'color': $store.getters.userInfo === 'true' ? '#00ff29' : '#737f92'}" @click="loginModalHandle"></i>
|
||||
<i class="el-icon-user-solid icon-user" :style="{'color': $store.getters.userInfo === 'true' ? '#00d0fc' : '#737f92'}" @click="loginModalHandle"></i>
|
||||
<i class="el-icon-s-tools icon-tools" @click="configModalHandle"></i>
|
||||
</el-row>
|
||||
</el-col>
|
||||
@@ -47,6 +47,7 @@ import LoginModal from './login-modal.vue'
|
||||
import ConfigModal from './config-modal.vue'
|
||||
import { sendWebsocket, closeWebsocket } from '@/config/websocket.js'
|
||||
export default {
|
||||
name: 'ShellIndex',
|
||||
components: {
|
||||
LoginModal,
|
||||
ConfigModal
|
||||
@@ -92,6 +93,7 @@ export default {
|
||||
mounted () {
|
||||
this.checkTextOverflow()
|
||||
window.addEventListener('resize', this.checkTextOverflow)
|
||||
// this.$store.dispatch('setAgvObj', this.topInfo)
|
||||
},
|
||||
beforeDestroy () {
|
||||
window.removeEventListener('resize', this.checkTextOverflow)
|
||||
@@ -133,15 +135,14 @@ export default {
|
||||
})
|
||||
},
|
||||
_queryHead () {
|
||||
let url = this.$store.getters.baseUrl
|
||||
url = url.substring(7)
|
||||
let sid = this.$store.getters.userInfo === 'true' ? 1 : 2
|
||||
sendWebsocket(`ws://${url}/webSocket/VehicleInfo/${sid}`, {}, this.wsMessage, this.wsErr)
|
||||
const wsHost = process.env.VUE_APP_API_BASE_URL.replace(/^https?:\/\//, '')
|
||||
const sid = this.$store.getters.userInfo === 'true' ? 1 : 2
|
||||
sendWebsocket(`ws://${wsHost}/webSocket/VehicleInfo/${sid}`, {}, this.wsMessage, this.wsErr)
|
||||
},
|
||||
wsMessage (res) {
|
||||
clearTimeout(this.timer)
|
||||
this.topInfo = res.data
|
||||
this.$store.dispatch('setAgvObj', JSON.stringify(this.topInfo))
|
||||
this.$store.dispatch('setAgvObj', this.topInfo)
|
||||
},
|
||||
wsErr () {
|
||||
this.timer = setTimeout(() => {
|
||||
@@ -153,7 +154,7 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
@import '~@style/mixin'
|
||||
@import '../../style/mixin'
|
||||
.header-container
|
||||
_wh(100%, .48rem)
|
||||
padding 0 2%
|
||||
|
||||
@@ -14,15 +14,15 @@
|
||||
</el-form>
|
||||
</div>
|
||||
<el-row type="flex" justify="space-around" style="margin-top: .3rem">
|
||||
<el-col :span="7"><button class="button_control button_control_disabled" @click="exitUser"><p>{{ $t('Logout') }}</p></button></el-col>
|
||||
<el-col :span="7"><button class="button_control" @click="dataFormSubmit"><p>{{$t('Login')}}</p></button></el-col>
|
||||
<el-col :span="7" v-if="$store.getters.userInfo === 'true'"><button class="button_control button_control_disabled" @click="exitUser"><p>{{ $t('Logout') }}</p></button></el-col>
|
||||
<el-col :span="7" v-else><button class="button_control" @click="dataFormSubmit"><p>{{$t('Login')}}</p></button></el-col>
|
||||
</el-row>
|
||||
<vue-touch-keyboard id="keyboard" :options="options" v-if="visible" :layout="layout" :cancel="hide" :accept="accept" :input="input" :next="next" />
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
import config from '../../../public/config.json'
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
@@ -48,35 +48,19 @@ export default {
|
||||
methods: {
|
||||
init () {
|
||||
this.dialogVisible = true
|
||||
this.loadPasswords()
|
||||
},
|
||||
exitUser () {
|
||||
this.dialogVisible = false
|
||||
this.visible = false
|
||||
this.$store.dispatch('setSignOut')
|
||||
},
|
||||
async loadPasswords () {
|
||||
try {
|
||||
const response = await axios.get('../../static/password.txt', {responseType: 'text'})
|
||||
let fileContent = response.data || ''
|
||||
if (typeof fileContent !== 'string') {
|
||||
fileContent = String(fileContent)
|
||||
}
|
||||
this.passwords = fileContent.split('\n').map(line => line.trim()).filter(line => line)
|
||||
if (this.passwords.length === 0) {
|
||||
throw new Error('密码文件为空或格式不正确')
|
||||
}
|
||||
} catch (error) {
|
||||
this.$message('加载密码文件失败')
|
||||
}
|
||||
},
|
||||
dataFormSubmit () {
|
||||
this.dialogVisible = false
|
||||
this.visible = false
|
||||
if (this.$store.getters.userInfo === 'true') {
|
||||
return
|
||||
}
|
||||
if (this.passwords.includes(this.dataForm.password)) {
|
||||
if (this.dataForm.password === config.password) {
|
||||
this.$store.dispatch('userInfo', 'true')
|
||||
this.$message({
|
||||
message: '登录成功',
|
||||
|
||||
Reference in New Issue
Block a user