Browse Source

消毒中登陆

master
maochaoying 2 years ago
parent
commit
d0ebef215a
  1. 10
      src/components/LoginForm.vue
  2. 2
      src/components/Progress.vue
  3. 4
      src/components/dialogs/LoginModal.vue
  4. 15
      src/pages/Home.vue
  5. 2
      src/store/modules/user.js
  6. 6
      src/store/modules/websocket.js

10
src/components/LoginForm.vue

@ -27,7 +27,7 @@ import Open from '@/assets/img/login/open.png'
import { useWebSocketStore, useUserStore } from '@/store' import { useWebSocketStore, useUserStore } from '@/store'
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { loginJSON } from '@/mock/command'
import { loginJSON, getAllUserJSON } from '@/mock/command'
const props = defineProps({ const props = defineProps({
handleShowKey: { handleShowKey: {
@ -50,6 +50,10 @@ const props = defineProps({
type: Boolean, type: Boolean,
default: false, default: false,
}, },
changeTab: {
type: Function,
default: () => {},
},
}) })
const activeInput = ref(1) const activeInput = ref(1)
@ -92,7 +96,6 @@ const handleLogin = () => {
tip.value = '' tip.value = ''
webSocketStore?.sendCommandMsg(loginJSON(username.value, password.value)) webSocketStore?.sendCommandMsg(loginJSON(username.value, password.value))
// //
console.log(userStore.allUserList)
let flag = false let flag = false
userStore.allUserList?.map(item => { userStore.allUserList?.map(item => {
if (item.uid == username.value && password.value == item.passwd) { if (item.uid == username.value && password.value == item.passwd) {
@ -101,10 +104,13 @@ const handleLogin = () => {
userStore.updatePermission(item.permission_level) userStore.updatePermission(item.permission_level)
userStore.updateLoginUser(item.uid) userStore.updateLoginUser(item.uid)
if (props.modal) { if (props.modal) {
props.changeTab(5)
props.hideLoginModal() props.hideLoginModal()
// TAB
} else { } else {
window.location.href = 'http://127.0.0.1/' window.location.href = 'http://127.0.0.1/'
} }
console.log(props.modal)
} }
}) })
if (!flag) { if (!flag) {

2
src/components/Progress.vue

@ -87,7 +87,7 @@
</svg> </svg>
<div class="left_log_wrap"> <div class="left_log_wrap">
<p class="text">当前剩余</p> <p class="text">当前剩余</p>
<p class="val">{{ deviceStore.nowlog || 0 }}log</p>
<p class="val">{{ deviceStore.nowlog?.toFixed(2) || 0 }}log</p>
</div> </div>
<div <div
class="btn" class="btn"

4
src/components/dialogs/LoginModal.vue

@ -8,6 +8,7 @@
:handleHideKey="handleHideKey" :handleHideKey="handleHideKey"
:hideLoginModal="hideLoginModal" :hideLoginModal="hideLoginModal"
:modal="true" :modal="true"
:changeTab="changeTab"
/> />
<svg <svg
@click="closeModal" @click="closeModal"
@ -44,6 +45,9 @@ const props = defineProps({
hideLoginModal: { hideLoginModal: {
type: Function, type: Function,
}, },
changeTab: {
type: Function,
},
}) })
const input = ref('') const input = ref('')

15
src/pages/Home.vue

@ -142,7 +142,6 @@
activeTab == 5 ? 'tab_btn style-btn active_btn' : 'style-btn tab_btn' activeTab == 5 ? 'tab_btn style-btn active_btn' : 'style-btn tab_btn'
" "
@click="changeTab(5)" @click="changeTab(5)"
v-if="userStore.loginUserPermission != 3"
> >
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
@ -307,7 +306,11 @@
:input="input" :input="input"
/> />
</div> </div>
<LoginModal v-if="loginModalVisible" :hideLoginModal="hideLoginModal" />
<LoginModal
:changeTab="changeTab"
v-if="loginModalVisible"
:hideLoginModal="hideLoginModal"
/>
</div> </div>
</template> </template>
@ -331,7 +334,12 @@ import {
useSettingStore, useSettingStore,
useUserStore, useUserStore,
} from '@/store' } from '@/store'
import { logoutJSON, getStateJSON, getAllSettingJSON } from '@/mock/command'
import {
logoutJSON,
getStateJSON,
getAllSettingJSON,
getAllUserJSON,
} from '@/mock/command'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
@ -381,6 +389,7 @@ const changeTab = index => {
if (userStore.loginUserPermission == 3) { if (userStore.loginUserPermission == 3) {
// //
// //
webSocketStore?.sendCommandMsg(getAllUserJSON)
loginModalVisible.value = true loginModalVisible.value = true
return return
} }

2
src/store/modules/user.js

@ -7,7 +7,7 @@ export const useUserStore = defineStore({
allUserList: [], allUserList: [],
operUser: '', operUser: '',
loginUser: '', loginUser: '',
loginUserPermission: 2,
loginUserPermission: 3,
} }
}, },
// actions // actions

6
src/store/modules/websocket.js

@ -198,9 +198,9 @@ export const useWebSocketStore = defineStore({
auditStore.updatePage(page) auditStore.updatePage(page)
break break
case 'login': case 'login':
if (ackcode == 0) {
window.location.href = 'http://127.0.0.1/'
}
// if (ackcode == 0) {
// window.location.href = 'http://127.0.0.1/'
// }
break break
case 'getAllRecords': case 'getAllRecords':
break break

Loading…
Cancel
Save