完成url获取用户账号功能
This commit is contained in:
parent
83b256a832
commit
2a226831dc
|
@ -1 +1,2 @@
|
|||
VITE_URL_VALIDATE_ACCOUNT=http://
|
||||
NODE_ENV = 'development'
|
||||
VITE_URL_VALIDATE_ACCOUNT=http://222.76.244.118:11001/desktop_archievement_backend/account/query_staff_info.do
|
|
@ -28,6 +28,7 @@
|
|||
"eslint": "^8.35.0",
|
||||
"eslint-config-recommended": "^4.1.0",
|
||||
"eslint-plugin-vue": "^9.9.0",
|
||||
"sass": "^1.58.3",
|
||||
"vite": "^4.1.0"
|
||||
}
|
||||
},
|
||||
|
@ -2184,7 +2185,6 @@
|
|||
"resolved": "https://registry.npmmirror.com/anymatch/-/anymatch-3.1.3.tgz",
|
||||
"integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"normalize-path": "^3.0.0",
|
||||
"picomatch": "^2.0.4"
|
||||
|
@ -2435,7 +2435,6 @@
|
|||
"resolved": "https://registry.npmmirror.com/binary-extensions/-/binary-extensions-2.2.0.tgz",
|
||||
"integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
|
@ -2676,7 +2675,6 @@
|
|||
"resolved": "https://registry.npmmirror.com/chokidar/-/chokidar-3.5.3.tgz",
|
||||
"integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"anymatch": "~3.1.2",
|
||||
"braces": "~3.0.2",
|
||||
|
@ -2698,7 +2696,6 @@
|
|||
"resolved": "https://registry.npmmirror.com/glob-parent/-/glob-parent-5.1.2.tgz",
|
||||
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"is-glob": "^4.0.1"
|
||||
},
|
||||
|
@ -7114,6 +7111,12 @@
|
|||
"node": ">= 4"
|
||||
}
|
||||
},
|
||||
"node_modules/immutable": {
|
||||
"version": "4.2.4",
|
||||
"resolved": "https://registry.npmmirror.com/immutable/-/immutable-4.2.4.tgz",
|
||||
"integrity": "sha512-WDxL3Hheb1JkRN3sQkyujNlL/xRjAo3rJtaU5xeufUauG66JdMr32bLj4gF+vWl84DIA3Zxw7tiAjneYzRRw+w==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/import-fresh": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmmirror.com/import-fresh/-/import-fresh-3.3.0.tgz",
|
||||
|
@ -7324,7 +7327,6 @@
|
|||
"resolved": "https://registry.npmmirror.com/is-binary-path/-/is-binary-path-2.1.0.tgz",
|
||||
"integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"binary-extensions": "^2.0.0"
|
||||
},
|
||||
|
@ -10096,7 +10098,6 @@
|
|||
"resolved": "https://registry.npmmirror.com/readdirp/-/readdirp-3.6.0.tgz",
|
||||
"integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"picomatch": "^2.2.1"
|
||||
},
|
||||
|
@ -10320,6 +10321,23 @@
|
|||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/sass": {
|
||||
"version": "1.58.3",
|
||||
"resolved": "https://registry.npmmirror.com/sass/-/sass-1.58.3.tgz",
|
||||
"integrity": "sha512-Q7RaEtYf6BflYrQ+buPudKR26/lH+10EmO9bBqbmPh/KeLqv8bjpTNqxe71ocONqXq+jYiCbpPUmQMS+JJPk4A==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"chokidar": ">=3.0.0 <4.0.0",
|
||||
"immutable": "^4.0.0",
|
||||
"source-map-js": ">=0.6.2 <2.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"sass": "sass.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/schema-utils": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmmirror.com/schema-utils/-/schema-utils-3.1.1.tgz",
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
"eslint": "^8.35.0",
|
||||
"eslint-config-recommended": "^4.1.0",
|
||||
"eslint-plugin-vue": "^9.9.0",
|
||||
"sass": "^1.58.3",
|
||||
"vite": "^4.1.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
$color-bg-01: #ba1800;
|
||||
$color-bg-02: #f27620;
|
||||
$color-bg-03: #fecb96;
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
$bg-color-01: #ba1800;
|
||||
$bg-color-02: #f27620;
|
||||
$bg-color-03: #fecb96;
|
|
@ -11,9 +11,10 @@ body {
|
|||
/* background-color: #8796a6; */
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
/* border: 1px solid red; */
|
||||
border: 1px solid green;
|
||||
/* overflow: hidden; */
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* @Author: Kane
|
||||
* @Date: 2023-02-28 19:30:40
|
||||
* @LastEditors: Kane
|
||||
* @FilePath: /task_schedule/src/utils/api/account.ts
|
||||
* @Description:
|
||||
* @FilePath: /deskop_task_schedule/code/web/task_schedule/src/utils/api/url.ts
|
||||
* @Description: 对URL的操作
|
||||
*
|
||||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
*/
|
||||
|
@ -11,17 +11,17 @@
|
|||
/**
|
||||
* 将url的参数拆分成对象
|
||||
* @param url 访问的url
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
function getURL(url: string)
|
||||
function getURLParams(url: string)
|
||||
{
|
||||
const arr = url.split('?');
|
||||
const params = arr[1].split('&');
|
||||
const arr = url.split("?");
|
||||
const params = arr[1].split("&");
|
||||
const obj = {};
|
||||
|
||||
for (let i = 0; i < params.length; i++)
|
||||
{
|
||||
const param = params[i].split('=');
|
||||
const param = params[i].split("=");
|
||||
|
||||
obj[param[0]] = param[1];
|
||||
}
|
||||
|
@ -29,4 +29,54 @@ function getURL(url: string)
|
|||
return obj;
|
||||
}
|
||||
|
||||
export { getURL };
|
||||
/**
|
||||
* 对URL中的参数进行拆分,拆分的参数名称和值作为一个对象属性的键值对。
|
||||
* @param url url字符串
|
||||
* @returns 返回包含url中参数作为key,值作为value的对象。
|
||||
*/
|
||||
function getParamsFromURL(url: string): any
|
||||
{
|
||||
const indexOfQuestionMark: number = url.indexOf("?");
|
||||
const indexOfSharp: number = url.indexOf("#");
|
||||
const paramObj = {};
|
||||
let paramString;
|
||||
|
||||
//url中没有问号,说明没有参数
|
||||
if (indexOfQuestionMark < 0)
|
||||
{
|
||||
return paramObj;
|
||||
}
|
||||
|
||||
//检查是否有#号
|
||||
if (indexOfSharp < 0)
|
||||
{
|
||||
//没有#号,可以直接截取参数字符串
|
||||
paramString = url.substring(indexOfQuestionMark);
|
||||
}
|
||||
else
|
||||
{
|
||||
//有#号,截取?和#之间的字符串
|
||||
const end: number = indexOfQuestionMark < indexOfSharp ? indexOfSharp : url.length;
|
||||
|
||||
paramString = url.substring(indexOfQuestionMark + 1, end);
|
||||
}
|
||||
|
||||
//拆分属性
|
||||
const paramArray: string[] = paramString.split("&");
|
||||
|
||||
paramArray.forEach((item) =>
|
||||
{
|
||||
if (item.length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const param = item.split("=");
|
||||
|
||||
paramObj[param[0]] = param[1] || "";
|
||||
});
|
||||
|
||||
return paramObj;
|
||||
}
|
||||
|
||||
export { getURLParams, getParamsFromURL };
|
|
@ -2,7 +2,7 @@
|
|||
* @Author: Kane
|
||||
* @Date: 2023-02-28 00:57:21
|
||||
* @LastEditors: Kane
|
||||
* @FilePath: /deskop_task_schedule/code/web/task_schedule/src/components/login/Login.vue
|
||||
* @FilePath: /deskop_task_schedule/code/web/task_schedule/src/views/Login.vue
|
||||
* @Description:
|
||||
* 登录页面,路由默认指向这个页面
|
||||
* 1、判断url中的参数,取得用户信息,根据用户的部门改变路由
|
||||
|
@ -10,15 +10,16 @@
|
|||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
-->
|
||||
<template>
|
||||
<span>{{ ui.p13uid }}</span>
|
||||
<br>
|
||||
<span>存储的P13:{{ ui.savedP13uid }}
|
||||
</span>
|
||||
<div class="page-wrap">
|
||||
<span v-show="ui.showNeedAccountTip">请在链接中提供用户的P13账号或P09工号。</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { reactive } from "vue";
|
||||
import { service as instance } from "@/utils/api/request";
|
||||
import { getParamsFromURL } from "@/utils/api/url";
|
||||
|
||||
|
||||
const URL = "http://222.76.244.118:11001/admin-system/account/p13_account_check";
|
||||
|
||||
|
@ -29,40 +30,39 @@ export default {
|
|||
const ui = reactive({
|
||||
p13uid: "",
|
||||
savedP13uid: "",
|
||||
showNeedAccountTip: false,
|
||||
});
|
||||
|
||||
//根据url获取用户账号
|
||||
const urlParams = getParamsFromURL(window.location.href);
|
||||
|
||||
console.log(window.location.href);
|
||||
console.log(urlParams);
|
||||
|
||||
const userInfo = {
|
||||
p13account: "wangwei-202",
|
||||
password: "Kane@1983",
|
||||
};
|
||||
|
||||
instance.request(
|
||||
{
|
||||
method: "post",
|
||||
url: URL,
|
||||
data: userInfo,
|
||||
}
|
||||
)
|
||||
.then((response) =>
|
||||
{
|
||||
// debugger;
|
||||
const data = response.data;
|
||||
|
||||
if (data.success === true)
|
||||
{
|
||||
ui.savedP13uid = data.staff_info;
|
||||
}
|
||||
})
|
||||
.catch((error) =>
|
||||
{
|
||||
ui.savedP13uid = error;
|
||||
});
|
||||
if (urlParams.account == undefined)
|
||||
{
|
||||
ui.showNeedAccountTip = true;
|
||||
}
|
||||
|
||||
return { ui, };
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
<style scoped>
|
||||
.page-wrap {
|
||||
box-sizing: border-box;
|
||||
height: calc(100vh - 100px);
|
||||
width: calc(100vw - 100px);
|
||||
margin: 50px;
|
||||
border: 1px solid red;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 30px;
|
||||
color: red;
|
||||
}
|
||||
</style>
|
File diff suppressed because it is too large
Load Diff
|
@ -1,3 +1,4 @@
|
|||
{
|
||||
"java.configuration.updateBuildConfiguration": "automatic"
|
||||
"java.configuration.updateBuildConfiguration": "automatic",
|
||||
"java.compile.nullAnalysis.mode": "automatic"
|
||||
}
|
Loading…
Reference in New Issue