添加注册,修复加载动画,以及cid日志详情
This commit is contained in:
parent
fe0bb06f8d
commit
6331268a01
|
|
@ -22,7 +22,7 @@ export const loginService = (loginData) => {
|
||||||
|
|
||||||
export const registerService = (registerData) => {
|
export const registerService = (registerData) => {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
for (let key in loginData) {
|
for (let key in registerData) {
|
||||||
params.append(key, registerData[key])
|
params.append(key, registerData[key])
|
||||||
}
|
}
|
||||||
return request.post('/user/register', params)
|
return request.post('/user/register', params)
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,11 @@ request.interceptors.response.use(
|
||||||
router.push("/login")
|
router.push("/login")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if(result.data.code == 7){
|
||||||
|
alert("该用户已存在,请重新输入!");
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
if(result.data.code == 1){
|
if(result.data.code == 1){
|
||||||
alert("请求失败,请稍后重试!");
|
alert("请求失败,请稍后重试!");
|
||||||
}else{
|
}else{
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,12 @@ export default {
|
||||||
},
|
},
|
||||||
addDialogVisible: false,
|
addDialogVisible: false,
|
||||||
updateDialogVisible: false,
|
updateDialogVisible: false,
|
||||||
|
updateForm: {
|
||||||
|
create_time: "",
|
||||||
|
script: "",
|
||||||
|
end: "",
|
||||||
|
error: "",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -92,12 +98,10 @@ export default {
|
||||||
},
|
},
|
||||||
async updateButtonCID(index) {
|
async updateButtonCID(index) {
|
||||||
var id = this.tableData[index].ID;
|
var id = this.tableData[index].ID;
|
||||||
this.updateForm.name = this.tableData[index].Name;
|
this.updateForm.create_time = this.tableData[index].CreatedAt;
|
||||||
this.updateForm.url = this.tableData[index].Url;
|
|
||||||
this.updateForm.script = this.tableData[index].Script;
|
this.updateForm.script = this.tableData[index].Script;
|
||||||
this.updateForm.cidtoken = this.tableData[index].Token;
|
this.updateForm.end = this.tableData[index].Log;
|
||||||
this.updateForm.id = id;
|
this.updateForm.error = this.tableData[index].Error;
|
||||||
this.updateDialogVisible= true;
|
|
||||||
},
|
},
|
||||||
async addCID() {
|
async addCID() {
|
||||||
this.addDialogVisible = false;
|
this.addDialogVisible = false;
|
||||||
|
|
@ -212,52 +216,11 @@ export default {
|
||||||
>刷新</el-button
|
>刷新</el-button
|
||||||
>
|
>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
|
||||||
<el-dialog
|
|
||||||
v-model="addDialogVisible"
|
|
||||||
title="添加集成项目"
|
|
||||||
width="50%"
|
|
||||||
:before-close="handleClose"
|
|
||||||
>
|
|
||||||
<!-- 内容主体区域 -->
|
|
||||||
<el-form
|
|
||||||
ref="addFormRef"
|
|
||||||
:model="addForm"
|
|
||||||
:rules="addFormRules"
|
|
||||||
label-width="70px"
|
|
||||||
>
|
|
||||||
<el-form-item label="项目名称" prop="device_name">
|
|
||||||
<el-input
|
|
||||||
v-model="addForm.name"
|
|
||||||
autocomplete="on"
|
|
||||||
style="width: 400px"
|
|
||||||
></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="仓库地址" prop="device_ip">
|
|
||||||
<el-input v-model="addForm.url" style="width: 400px" autocomplete="on"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="脚本内容" prop="device_status">
|
|
||||||
<el-input type="textarea" v-model="addForm.script" style="width: 400px" :autosize="{ minRows: 4, maxRows: 8 }" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<!-- 底部区域 -->
|
|
||||||
<template #footer>
|
|
||||||
<span class="dialog-footer">
|
|
||||||
<el-button @click="addDialogVisible = false"
|
|
||||||
>取消</el-button
|
|
||||||
>
|
|
||||||
<el-button type="primary" @click="addCID()"
|
|
||||||
>确定</el-button
|
|
||||||
>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="updateDialogVisible"
|
v-model="updateDialogVisible"
|
||||||
title="修改集成项目"
|
title="查看集成项目日志"
|
||||||
width="50%"
|
width="50%"
|
||||||
:before-close="handleClose"
|
:before-close="handleClose"
|
||||||
>
|
>
|
||||||
|
|
@ -268,32 +231,28 @@ export default {
|
||||||
:rules="updateFormRules"
|
:rules="updateFormRules"
|
||||||
label-width="70px"
|
label-width="70px"
|
||||||
>
|
>
|
||||||
<el-form-item label="项目名称" prop="device_name">
|
<el-form-item label="创建时间" prop="create_time">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="updateForm.name"
|
v-model="updateForm.create_time"
|
||||||
autocomplete="on"
|
autocomplete="on"
|
||||||
style="width: 400px"
|
style="width: 400px"
|
||||||
></el-input>
|
></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="仓库地址" prop="device_ip">
|
<el-form-item label="脚本内容" prop="script">
|
||||||
<el-input v-model="updateForm.url" style="width: 400px" autocomplete="on"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="脚本内容" prop="device_status">
|
|
||||||
<el-input type="textarea" v-model="updateForm.script" style="width: 400px" :autosize="{ minRows: 4, maxRows: 8 }" />
|
<el-input type="textarea" v-model="updateForm.script" style="width: 400px" :autosize="{ minRows: 4, maxRows: 8 }" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="外部回调Token" prop="device_status">
|
<el-form-item label="执行结果" prop="end">
|
||||||
<el-input v-model="updateForm.cidtoken" style="width: 400px" />
|
<el-input type="textarea" v-model="updateForm.end" style="width: 400px" :autosize="{ minRows: 4, maxRows: 8 }" />
|
||||||
回调地址:https://gep.ljsea.xyz/cid/callback?token={{updateForm.cidtoken}}&id={{updateForm.id}}
|
</el-form-item>
|
||||||
|
<el-form-item label="错误内容" prop="error">
|
||||||
|
<el-input type="textarea" v-model="updateForm.error" style="width: 400px" :autosize="{ minRows: 4, maxRows: 8 }" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<!-- 底部区域 -->
|
<!-- 底部区域 -->
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<span class="dialog-footer">
|
<span class="dialog-footer">
|
||||||
<el-button @click="updateDialogVisible = false"
|
<el-button @click="updateDialogVisible = false"
|
||||||
>取消</el-button
|
>关闭</el-button
|
||||||
>
|
|
||||||
<el-button type="primary" @click="updateCID()"
|
|
||||||
>确定</el-button
|
|
||||||
>
|
>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,7 @@ export default {
|
||||||
data.expire
|
data.expire
|
||||||
);
|
);
|
||||||
this.session = data.im_session;
|
this.session = data.im_session;
|
||||||
|
this.loading=false
|
||||||
//暂停定时器
|
//暂停定时器
|
||||||
this.stopInterval();
|
this.stopInterval();
|
||||||
this.connectWebSocket();
|
this.connectWebSocket();
|
||||||
|
|
@ -285,7 +286,7 @@ export default {
|
||||||
this.socket = new WebSocket(socketUrl);
|
this.socket = new WebSocket(socketUrl);
|
||||||
//打开事件
|
//打开事件
|
||||||
this.socket.onopen = function () {
|
this.socket.onopen = function () {
|
||||||
this.loading = false;
|
this.loading=false
|
||||||
confirm("连接成功");
|
confirm("连接成功");
|
||||||
};
|
};
|
||||||
this.socket.onerror = (error) => {
|
this.socket.onerror = (error) => {
|
||||||
|
|
@ -324,7 +325,7 @@ export default {
|
||||||
//console.log("to_user_id:", this.to_user_id, this.to_user_name);
|
//console.log("to_user_id:", this.to_user_id, this.to_user_name);
|
||||||
this.startInterval();
|
this.startInterval();
|
||||||
|
|
||||||
setTimeout(() => this.loading=false, 3000);
|
//setTimeout(() => this.loading=false, 3000);
|
||||||
|
|
||||||
//this.connectWebSocket();
|
//this.connectWebSocket();
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,9 @@
|
||||||
></el-input>
|
></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" auto-insert-space>注册</el-button>
|
<el-button type="primary" @click="onRegister" auto-insert-space
|
||||||
|
>注册</el-button
|
||||||
|
>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item class="flex">
|
<el-form-item class="flex">
|
||||||
<el-link @click="isLogin = true"> 返回 </el-link>
|
<el-link @click="isLogin = true"> 返回 </el-link>
|
||||||
|
|
@ -86,13 +88,13 @@
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-row>
|
</el-row>
|
||||||
<div>
|
<div>
|
||||||
<div>二维码状态: {{qr_status}} </div>
|
<div>二维码状态: {{ qr_status }}</div>
|
||||||
<canvas ref="qrCodeCanvas"></canvas>
|
<canvas ref="qrCodeCanvas"></canvas>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, inject,onUnmounted } from "vue";
|
import { ref, onMounted, inject, onUnmounted } from "vue";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {
|
import {
|
||||||
getQRService,
|
getQRService,
|
||||||
|
|
@ -108,7 +110,7 @@ const isLogin = ref(true);
|
||||||
const qrCodeCanvas = ref(null);
|
const qrCodeCanvas = ref(null);
|
||||||
const globalData = inject("globalData");
|
const globalData = inject("globalData");
|
||||||
|
|
||||||
// 创建一个响应式引用来存储定时器ID
|
// 创建一个响应式引用来存储定时器ID
|
||||||
const intervalId = ref(null);
|
const intervalId = ref(null);
|
||||||
var uuid = "";
|
var uuid = "";
|
||||||
|
|
||||||
|
|
@ -164,22 +166,22 @@ onUnmounted(() => {
|
||||||
stopInterval();
|
stopInterval();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 开启定时器
|
// 开启定时器
|
||||||
const startInterval = () => {
|
const startInterval = () => {
|
||||||
if (intervalId.value) {
|
if (intervalId.value) {
|
||||||
// 如果定时器已经开启,则不执行任何操作
|
// 如果定时器已经开启,则不执行任何操作
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
intervalId.value = setInterval(getQRStatus, 2000);
|
intervalId.value = setInterval(getQRStatus, 2000);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 关闭定时器
|
// 关闭定时器
|
||||||
const stopInterval = () => {
|
const stopInterval = () => {
|
||||||
if (intervalId.value) {
|
if (intervalId.value) {
|
||||||
clearInterval(intervalId.value);
|
clearInterval(intervalId.value);
|
||||||
intervalId.value = null; // 清除引用中的定时器ID
|
intervalId.value = null; // 清除引用中的定时器ID
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const creatQrCode = async () => {
|
const creatQrCode = async () => {
|
||||||
console.log("creatQrCode:", uuid);
|
console.log("creatQrCode:", uuid);
|
||||||
|
|
@ -206,6 +208,34 @@ const login = async () => {
|
||||||
router.push("/videoList");
|
router.push("/videoList");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//注册接口调用
|
||||||
|
const onRegister = async () => {
|
||||||
|
//校验密码是否一致
|
||||||
|
if (registerData.value.password !== registerData.value.repassword) {
|
||||||
|
alert("两次密码不一致");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//校验邮箱是否合法
|
||||||
|
let email = registerData.value.email;
|
||||||
|
let reg = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
|
||||||
|
if (!reg.test(email)) {
|
||||||
|
alert("邮箱格式不正确");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let result = await registerService(register);
|
||||||
|
if (result !== null) {
|
||||||
|
globalData.token = result.data;
|
||||||
|
localStorage.setItem("token", result.data.token);
|
||||||
|
localStorage.setItem("userId", result.data.id);
|
||||||
|
localStorage.setItem("username", result.data.username);
|
||||||
|
let now = new Date();
|
||||||
|
localStorage.setItem("end_time", now.setDate(now.getHours() + 12)); //过期时间
|
||||||
|
//token.value= result.data;
|
||||||
|
router.push("/videoList");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const generateQRCode = () => {
|
const generateQRCode = () => {
|
||||||
// 假设我们有一个数据字符串要转换为二维码
|
// 假设我们有一个数据字符串要转换为二维码
|
||||||
const data = uuid;
|
const data = uuid;
|
||||||
|
|
@ -240,7 +270,11 @@ const generateQRCode = () => {
|
||||||
|
|
||||||
const getUUID = async () => {
|
const getUUID = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await getUUIDService({ device: "windows" ,"address": localStorage.getItem("address"),"ip": localStorage.getItem("ip")});
|
const response = await getUUIDService({
|
||||||
|
device: "windows",
|
||||||
|
address: localStorage.getItem("address"),
|
||||||
|
ip: localStorage.getItem("ip"),
|
||||||
|
});
|
||||||
uuid = response.data.toString();
|
uuid = response.data.toString();
|
||||||
let uid = uuid.toString();
|
let uid = uuid.toString();
|
||||||
//await creatQrCode(uid);
|
//await creatQrCode(uid);
|
||||||
|
|
@ -255,7 +289,7 @@ const getQRStatus = async () => {
|
||||||
if (result.code === 0) {
|
if (result.code === 0) {
|
||||||
if (result.data === "0") {
|
if (result.data === "0") {
|
||||||
} else if (result.data === "1") {
|
} else if (result.data === "1") {
|
||||||
qr_status.value="等待确认";
|
qr_status.value = "等待确认";
|
||||||
} else {
|
} else {
|
||||||
globalData.token = result.data;
|
globalData.token = result.data;
|
||||||
localStorage.setItem("token", result.data.token);
|
localStorage.setItem("token", result.data.token);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue