全部修改架构
This commit is contained in:
@@ -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