Commit 6706c728 by qlintonger xeno

报错信息添加

parent fd370773
...@@ -105,7 +105,7 @@ router.beforeEach(async (to, from, next) => { ...@@ -105,7 +105,7 @@ router.beforeEach(async (to, from, next) => {
} }
} else { } else {
//未登录 //未登录
if (to.name == 'Login') { if (to.name == 'Login' || to.name === 'test') {
next() next()
} else { } else {
next({ name: 'Login' }) next({ name: 'Login' })
......
...@@ -17,6 +17,12 @@ const routes: Array<RouteRecordRaw> = [ ...@@ -17,6 +17,12 @@ const routes: Array<RouteRecordRaw> = [
children: [] children: []
}, },
{ {
path: '/test',
name: 'test',
meta: { title: '测试眼镜URL' },
component: () => import( '@/views/test/index.vue')
},
{
path: '/404', path: '/404',
name: 'Error404', name: 'Error404',
component: () => import(/* webpackChunkName: "Error404" */ '@/views/error/index.vue'), component: () => import(/* webpackChunkName: "Error404" */ '@/views/error/index.vue'),
......
...@@ -9,6 +9,11 @@ ...@@ -9,6 +9,11 @@
</div> </div>
<div v-show="!showScanCode"> <div v-show="!showScanCode">
<h3 class="font-bold text-xl">{{ getLoginMethod.name }}</h3> <h3 class="font-bold text-xl">{{ getLoginMethod.name }}</h3>
<div class="flex justify-between items-center">
<div>测试API</div>
<qrcode-vue v-if="loginMethodType === 'scan'" :value="urlCodeTest" :size="101"
render-as="svg" />
</div>
<a-form ref="loginFormRef" :rules="rules" :model="loginForm" layout="vertical"> <a-form ref="loginFormRef" :rules="rules" :model="loginForm" layout="vertical">
<a-form-item field="username" label="用户名:" validate-trigger="change" hide-asterisk> <a-form-item field="username" label="用户名:" validate-trigger="change" hide-asterisk>
<a-input v-model="loginForm.username" placeholder="请输入你的用户名" size="large" allow-clear /> <a-input v-model="loginForm.username" placeholder="请输入你的用户名" size="large" allow-clear />
...@@ -80,6 +85,7 @@ const loginMethodType = ref<MethodType>('account') ...@@ -80,6 +85,7 @@ const loginMethodType = ref<MethodType>('account')
const getLoginMethod = computed(() => { const getLoginMethod = computed(() => {
return loginMethod[loginMethodType.value] return loginMethod[loginMethodType.value]
}) })
const urlCodeTest = `${location.origin}/#/test`
//切换登录模式 //切换登录模式
const handleLoginMethod = () => { const handleLoginMethod = () => {
if (loginMethodType.value == 'account') { if (loginMethodType.value == 'account') {
......
<template>
<div ref="sec">正在测试调用眼镜端URL....</div>
<div></div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { API_URL } from '../../../project.app.config.ts'
const sec = ref()
const demoURL = `${API_URL}/admin/getCaptcha`
onMounted(function() {
window.onerror = function() {
console.log('errors!!!!', arguments)
}
fetch(demoURL, {
'headers': {
'content-type': 'application/x-www-form-urlencoded'
},
'body': 'username=devzj3',
'method': 'POST',
}).then(res => res.blob())
.then((b: Blob) => {
const url = window.URL.createObjectURL(b)
const img = document.createElement('img')
img.src = url
sec.value.innerHTML = 'api调用成功!'
sec.value.nextElementSibling.append(img)
})
.catch((reason: any) => {
console.log('出现错误!', reason)
sec.value.innerHTML = '请求出错!'
sec.value.nextElementSibling.innerHTML = reason
})
})
</script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment