1 Star 0 Fork 0

Robert/ForguncyK6

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Common.js 3.36 KB
一键复制 编辑 原始数据 按行查看 历史
Robert 提交于 2024-08-14 10:18 . 初始化
import http from 'k6/http';
export const host = "http://xa-dd3-hu/app1";
let enableLog = false;
let logBody = false;
let logStateCode = false;
export function EnableLog(){
enableLog = true;
logBody = true;
logStateCode = true;
}
function log(response, funcName){
if(enableLog){
console.log("-------" + funcName + "------------------------------------------");
if(logStateCode){
console.log("status:" + response.status);
if(response.status >= 400){
console.error(response);
return;
}
}
if(logBody){
if(response.body){
let body = response.body;
body = (body.length > 100 ? (body.substring(0,100) + ` (${body.length} chars)...`): body);
body = body.replace(/\r\n/g, '');
console.log("body: " + body);
}
else{
console.log("body is Empty");
}
}
}
}
export function index(){
const response = http.get(host,null, createDefaultHeder());
log(response, "index");
}
export function GetRSAPublicKey(){
const res = http.post(host + '/Account/GetRSAPublicKey',null, createDefaultHeder());
log(res, "GetRSAPublicKey");
return res;
}
export function login(userName = "Administrator"){
const response = http.post(encodeURI(`${host}/Account/Login`),
JSON.stringify( {
"userName": userName,
"password": "123456",
"rememberMe": false,
"deviceInfo": "25538D1E-3B9A-4E10-9FA2-3D850A47A8A6,PDF Viewer,Chrome PDF Viewer,Chromium PDF Viewer,Microsoft Edge PDF Viewer,WebKit built-in PDF,1415"
}), createDefaultHeder());
log(response, "Login");
return response;
}
export function GetMetadata(pageName = "FGC_登录"){
const response = http.post(
encodeURI(`${host}/Home/GetMetadata`),
{
pageName: `PathName:/Forguncy/${pageName}}`,
token: "",
isMobile: "false",
},createDefaultHeder()
);
log(response, "GetMetadata");
return response;
}
export function GetMetadata2(pageName = "FGC_登录"){
pageName = encodeURI(pageName);
const response = http.get(`${host}/Home/GetMetadata2?pageName=${pageName}`, null, createDefaultHeder());
log(response, "GetMetadata2");
return response;
}
export function GetMetadataGlobleConfig(){
const response = http.get(`${host}/Home/GetMetadata2?pageName=90AC3BB5-87DF-4E25-B6C3-A78CC93DF159&isMobile=false&v2=-600239608-598159596-598149576-598409572`,null, createDefaultHeder());
log(response, "GetMetadataGlobleConfig");
return response;
}
function createDefaultHeder(modityHeader = null){
const header = {
Accept: "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9",
//"Cache-Control": "no-cache",
Connection: "keep-alive",
"Content-Type": "application/json",
//Pragma: "no-cache",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
"X-Requested-With": "XMLHttpRequest",
"sec-ch-ua-platform": '"Windows"',
};
if(modityHeader){
for (const key in modityHeader){
header[key] = modityHeader[key];
}
}
return {
headers:header
};
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/roberthu/forguncy-k6.git
[email protected]:roberthu/forguncy-k6.git
roberthu
forguncy-k6
ForguncyK6
master

搜索帮助