ACS
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import {http2} from "@/utils/request.js";
|
||||
|
||||
|
||||
/**获取所有站点 */
|
||||
export const getSiteList = (data) => {
|
||||
return http2.get(`/v1/admin/audit/list?page=${data.page}&count=${data.count}&key=${data.key}`)
|
||||
}
|
||||
/**手动触发站点审计 */
|
||||
export const auditSite = () => {
|
||||
return http2.get(`/v1/admin/audit/start`)
|
||||
}
|
||||
/**删除违规网页审计 */
|
||||
export const delAudit = (data) => {
|
||||
return http2.post(`/v1/admin/audit/delete`,data,{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**获取违规网页审计列表 */
|
||||
export const getAuditList = (data) => {
|
||||
return http2.get(`/v1/admin/audit/violation_list?page=${data.page}&count=${data.count}&key=${data.key}`)
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import {http2} from "@/utils/request.js";
|
||||
/**获取消息列表 */
|
||||
export const getMessageList = (data) => {
|
||||
return http2.get(`/v1/messages/get_message_list?page=${data.page}&count=${data.count}&message_type=${data.message_type}`)
|
||||
}
|
||||
/**获取单条消息 */
|
||||
export const getMessage = (data) => {
|
||||
return http2.get(`/v1/messages/get_message?message_id=${data}`)
|
||||
}
|
||||
/**添加消息 */
|
||||
export const addMessage = (data) => {
|
||||
return http2.post(`/v1/messages/add_message`, data,{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**删除消息 */
|
||||
export const deleteMessage = (data) => {
|
||||
return http2.post(`/v1/messages/delete_message`, data,{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**修改消息 */
|
||||
export const editMessage = (data) => {
|
||||
return http2.post(`/v1/messages/update_message`, data,{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**获取附件列表 */
|
||||
export const getFileList = (data) => {
|
||||
return http2.get(`/v1/attachment/get_attachment_list?page=${data.page}&count=${data.count}&key=${data.key}&user_type=${data.user_type}`)
|
||||
}
|
||||
/**上传附件 */
|
||||
export const uploadFile = (data) => {
|
||||
return http2.post(`/v1/attachment/add_attachment`, data,{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**删除附件 */
|
||||
export const deleteFile = (data) => {
|
||||
return http2.get(`/v1/attachment/delete_attachment?aid=${data}`)
|
||||
}
|
||||
/**用户获取消息列表 */
|
||||
export const getUserMessageList = (data) => {
|
||||
return http2.get(`/v1/messages/get_message_list?page=${data.page}&count=${data.count}&message_type=${data.message_type}`)
|
||||
}
|
||||
/**用户获取单条消息 */
|
||||
export const getUserMessage = (data) => {
|
||||
return http2.get(`/v1/messages/get_message?message_id=${data}`)
|
||||
}
|
||||
|
||||
/**获取消息详情 */
|
||||
export const getMessageDetail = (data) => {
|
||||
return http2.get(`/v1/messages/get_message?message_id=${data.message_id}`)
|
||||
}
|
||||
/**修改图片大小 */
|
||||
export const compressAndConvertFileToBase64=async(file)=> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onload = function(e) {
|
||||
const img = new Image();
|
||||
img.src = e.target.result;
|
||||
|
||||
img.onload = function() {
|
||||
const canvas = document.createElement('canvas');
|
||||
const MAX_WIDTH = 300; // 压缩的最大宽度
|
||||
const MAX_HEIGHT = 200; // 压缩的最大高度
|
||||
|
||||
let width = img.width;
|
||||
let height = img.height;
|
||||
|
||||
// 计算压缩比例
|
||||
if (width > height) {
|
||||
if (width > MAX_WIDTH) {
|
||||
height *= MAX_WIDTH / width;
|
||||
width = MAX_WIDTH;
|
||||
}
|
||||
} else {
|
||||
if (height > MAX_HEIGHT) {
|
||||
width *= MAX_HEIGHT / height;
|
||||
height = MAX_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(img, 0, 0, width, height);
|
||||
|
||||
// 将canvas内容转换为jpeg并压缩质量
|
||||
const dataUrl = canvas.toDataURL('image/jpeg', 0.8); // 0.8是压缩质量,范围0-1
|
||||
|
||||
resolve(dataUrl);
|
||||
};
|
||||
|
||||
img.onerror = function(error) {
|
||||
reject(error);
|
||||
};
|
||||
};
|
||||
|
||||
reader.onerror = function(error) {
|
||||
reject(error);
|
||||
};
|
||||
|
||||
reader.readAsDataURL(file);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import {http2} from "@/utils/request.js";
|
||||
/**获取镜像列表 */
|
||||
export const getMirrorList = data => {
|
||||
return http2.get(`/v1/image/list?server_id=${data}`);
|
||||
};
|
||||
/*用户获取镜像列表 */
|
||||
export const getUserMirrorList = data => {
|
||||
return http2.get(
|
||||
`/v1/image/list?server_id=${data.server_id}&count=${data.count}&page=${data.page}&key=${data.key}`
|
||||
);
|
||||
};
|
||||
/**上传镜像 */
|
||||
export const uploadMirror = data => {
|
||||
return http2.post("/v1/image/pull", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**编辑镜像 */
|
||||
export const editMirror = data => {
|
||||
return http2.post("/v1/image/update", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**删除镜像 */
|
||||
export const delMirror = data => {
|
||||
return http2.post("/v1/image/delete", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**镜像同步 */
|
||||
export const syncMirror = data => {
|
||||
return http2.get(`/v1/image/sync?server_id=${data}`);
|
||||
};
|
||||
/**重新拉取镜像 */
|
||||
export const pullMirror = data => {
|
||||
return http2.post(`/v1/image/repull`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**获取镜像信息 */
|
||||
export const Mirrorinfo = data => {
|
||||
const serverType = data.server_type || "dockerContainer"; // 设置默认值
|
||||
return http2.get(
|
||||
`/v1/image/info?image_id=${data.image_id}&server_type=${serverType}`
|
||||
);
|
||||
};
|
||||
|
||||
export const addVirtualMirror = data => {
|
||||
return http2.post("/v1/image/create", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
export const getImageTypeList = (server_id) => {
|
||||
return http2.get(`/v1/image/class_list?server_id=${server_id}`);
|
||||
};
|
||||
|
||||
export const createImageType = (server_id,class_name,class_ico) => {
|
||||
return http2.post("/v1/image/class_create", {
|
||||
server_id,
|
||||
class_name,
|
||||
class_ico
|
||||
},{
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const updateImageType = (class_id,class_name,class_ico) => {
|
||||
return http2.post("/v1/image/class_update", {
|
||||
class_id,
|
||||
class_name,
|
||||
class_ico
|
||||
},{
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import {http2} from "@/utils/request.js";
|
||||
/**获取订单列表 */
|
||||
export const getOrderList = (data) => {
|
||||
return http2.get(`/v1/admin/trades/get_trades?page=${data.page}&count=${data.count}&key=${data.key}`)
|
||||
}
|
||||
/**编辑订单 */
|
||||
export const editOrder = (data) => {
|
||||
return http2.post('/v1/admin/trades/update_trades',data,{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**删除订单 */
|
||||
export const deleteOrder = (data) => {
|
||||
return http2.post('/v1/admin/trades/delete_trade',data,{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**用户获取订单列表 */
|
||||
export const getUserOrderList = (data) => {
|
||||
return http2.get(`/v1/user/procedure/get_trade_list?page=${data.page}&count=${data.count}&key=${data.key}`)
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import {http2} from "@/utils/request.js";
|
||||
/**获取用户列表 */
|
||||
export const get_pay_code = data => {
|
||||
return http2.get(
|
||||
`https://yun.tdhly.love/submit.php?pid=2&type=${data.type}&out_trade_no={商户订单号}¬ify_url={服务器异步通知地址}&name={商品名称}&money=${data.money}&sign=9vP6xvcc93YYi9c6F3HiY9HFuyZizIxe&sign_type=MD5`
|
||||
);
|
||||
};
|
||||
// /**email验证码 */
|
||||
// export const ask_update_user_email = data => {
|
||||
// return http2.post("/v1/user/info/ask_update_user_email", data, {
|
||||
// headers: {
|
||||
// "Content-Type": "multipart/form-data"
|
||||
// }
|
||||
// });
|
||||
// };
|
||||
/**获取容器订单金额 */
|
||||
export const procedure_get_price = data => {
|
||||
return http2.post("/v1/user/procedure/get_price", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**获取虚拟机订单金额 */
|
||||
export const procedure_vir_price = data => {
|
||||
return http2.post("/v1/user/procedure/get_vm_price", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,455 @@
|
||||
import {http2} from "@/utils/request.js";
|
||||
|
||||
/** 获取所有服务器 */
|
||||
export const getServer = (page, count, key, type = "dockerContainer") => {
|
||||
return http2.get(
|
||||
`/v1/admin/server/get_server_list?page=${page}&count=${count}&key=${key}&server_type=${type}`
|
||||
);
|
||||
};
|
||||
|
||||
/**新增服务器 */
|
||||
export const addServer = data => {
|
||||
return http2.post("/v1/admin/server/add_server", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**编辑服务器 */
|
||||
export const editServer = data => {
|
||||
return http2.post("/v1/admin/server/update_server", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**删除服务器 */
|
||||
export const deleteServer = data => {
|
||||
return http2.post("/v1/admin/server/delete_server", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**查询指定服务器 */
|
||||
export const selectServer = data => {
|
||||
return http2.post("/v1/admin/server/select_server", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取服务器套餐列表*/
|
||||
export const getServerPlan = data => {
|
||||
return http2.get(
|
||||
`/v1/admin/container_plan/get_server_plan_list?server_id=${data.server_id}&count=${data.count}`
|
||||
);
|
||||
};
|
||||
/**获取指定套餐 */
|
||||
export const selectServerPlan = data => {
|
||||
return http2.post("/v1/admin/container_plan/get_server_plan_detail", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**修改套餐信息 */
|
||||
export const editServerPlan = data => {
|
||||
return http2.post("/v1/admin/container_plan/update_server_plan", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**新增套餐 */
|
||||
export const addServerPlan = data => {
|
||||
return http2.post("/v1/admin/container_plan/add_server_plan", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**删除套餐 */
|
||||
export const deleteServerPlan = data => {
|
||||
return http2.post("/v1/admin/container_plan/delete_server_plan", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取容器列表 */
|
||||
export const getContainer = data => {
|
||||
return http2.get(
|
||||
`/v1/admin/container/get_container_list?server_id=${data.server_id}&user_id=${data.user_id}&page=${data.page}&count=${data.count}&key=${data.key}`
|
||||
);
|
||||
};
|
||||
/**获取单个指定容器 */
|
||||
export const getOneContainer = data => {
|
||||
return http2.post("/v1/admin/container/get_container_detail", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**查询指定虚拟机信息(管理员查询) */
|
||||
export const getVmAdminContainer = id => {
|
||||
return http2.get(`/v1/admin/instance/detail/${id}`);
|
||||
};
|
||||
// 暂停容器
|
||||
export const pauseContainer = data => {
|
||||
return http2.post("/v1/admin/container/pause_container", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
// 暂停虚拟机
|
||||
export const pauseInstance = (data, id) => {
|
||||
return http2.post(`/v1/admin/instance/pause/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**恢复虚拟机 */
|
||||
export const unpauseInstance = (id, data = "") => {
|
||||
return http2.post(`/v1/admin/instance/resume/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 解除暂停
|
||||
export const unpauseContainer = data => {
|
||||
return http2.post("/v1/admin/container/unpause_container", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取容器状态 */
|
||||
export const getContainerStatus = data => {
|
||||
return http2.post("/v1/admin/container/get_container_status", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取虚拟机状态 */
|
||||
export const getInstanceStatus = id => {
|
||||
return http2.get(`/v1/admin/instance/get_state/${id}`);
|
||||
};
|
||||
/**查询服务器状态 */
|
||||
export const getServerStatus = id => {
|
||||
return http2.get(`/v1/admin/server/send_server_status?server_id=${id}`);
|
||||
};
|
||||
/**开通容器 */
|
||||
export const openContainer = data => {
|
||||
return http2.post("/v1/admin/container/open_container", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**开通虚拟机 */
|
||||
export const openInstance = (id, data = "") => {
|
||||
return http2.post(`/v1/admin/instance/approve/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**启动容器 */
|
||||
export const startContainer = data => {
|
||||
return http2.post("/v1/admin/container/start_container", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**启动虚拟机 */
|
||||
export const startInstance = data => {
|
||||
return http2.get(`/v1/admin/instance/start/${data}`);
|
||||
};
|
||||
/**重装容器 */
|
||||
export const reinstallC = data => {
|
||||
return http2.post("/v1/admin/container/reinstall_container", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**重装虚拟机 */
|
||||
export const reinstallI = (data, id) => {
|
||||
return http2.post(`/v1/admin/instance/reinstall/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**获取容器日志 */
|
||||
export const getContainerLog = data => {
|
||||
return http2.post(`/v1/admin/container/get_container_log`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取虚拟机操作日志 */
|
||||
export const getInstanceLog = (id, data) => {
|
||||
return http2.get(
|
||||
`/v1/admin/instance/log/${id}?page=${data.page}&count=${data.count}`
|
||||
);
|
||||
};
|
||||
|
||||
/**重启容器 */
|
||||
export const restartContainer = data => {
|
||||
return http2.post("/v1/admin/container/reboot_container", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**重启虚拟机 */
|
||||
export const restartInstance = data => {
|
||||
return http2.get(`/v1/admin/instance/reboot/${data}`);
|
||||
};
|
||||
|
||||
/**停止容器 */
|
||||
export const stopContainer = data => {
|
||||
return http2.post("/v1/admin/container/stop_container", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**停止虚拟机 */
|
||||
export const stopInstance = data => {
|
||||
return http2.get(`/v1/admin/instance/stop/${data}`);
|
||||
};
|
||||
|
||||
/**删除容器 */
|
||||
export const deleteContainer = data => {
|
||||
return http2.post("/v1/admin/container/delete_container", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**删除虚拟机 */
|
||||
export const deleteInstance = (id, data = "") => {
|
||||
return http2.post(`/v1/admin/instance/delete/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**清除容器流量 */
|
||||
export const clearContainerTraffic = data => {
|
||||
return http2.post("/v1/admin/container/clear_container_traffic", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**连接控制台 */
|
||||
export const connectConsole = data => {
|
||||
return http2.post("/v1/admin/container/get_container_console", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取虚拟机控制台 */
|
||||
export const getInstanceConsole = data => {
|
||||
return http2.get(`/v1/admin/instance/console/${data}`);
|
||||
};
|
||||
/**查询容器所有卷信息 */
|
||||
export const getVolumeList = data => {
|
||||
return http2.get(`/v1/admin/volume/get_volume_list?container_id=${data}`);
|
||||
};
|
||||
/**查询虚拟机所有卷信息 */
|
||||
export const getInstanceVolumeList = data => {
|
||||
return http2.get(
|
||||
`/v1/admin/volume/get_volume_list?instance_id=${data.instance_id}&page=${data.page}&count=${data.count}`
|
||||
);
|
||||
};
|
||||
/**新增卷 */
|
||||
export const addVolume = data => {
|
||||
return http2.post("/v1/admin/volume/add_volume", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**修改卷大小 */
|
||||
export const updateVolume = data => {
|
||||
return http2.post("/v1/admin/volume/update_volume_size", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**删除数据卷 */
|
||||
export const deleteVolume = data => {
|
||||
return http2.post("/v1/admin/volume/delete_volume", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取容器网络信息 */
|
||||
export const getNetworkList = data => {
|
||||
return http2.get(
|
||||
`/v1/container/proxy/get_container_proxy?container_id=${data}`
|
||||
);
|
||||
};
|
||||
/**获取虚拟机端口列表 */
|
||||
export const getInstancePortList = data => {
|
||||
const params = new URLSearchParams();
|
||||
if (data.page !== undefined) params.append("page", data.page.toString());
|
||||
if (data.count !== undefined) params.append("count", data.count.toString());
|
||||
if (data.internal_port !== undefined)
|
||||
params.append("internal_port", data.internal_port.toString());
|
||||
return http2.get(
|
||||
`/v1/admin/instance_port/list?instance_id=${data.instance_id}&${params.toString()}`
|
||||
);
|
||||
};
|
||||
/**添加容器网络 */
|
||||
export const addNetwork = data => {
|
||||
return http2.post("/v1/container/proxy/add_container_proxy", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**创建端口 */
|
||||
export const addPort = data => {
|
||||
return http2.post("/v1/admin/instance_port/create", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取浮动ip列表 */
|
||||
export const getFloatingIpList = data => {
|
||||
return http2.get(
|
||||
`/v1/admin/floating_ip/get_list?server_id=${data.server_id}&page=${data.page}&count=${data.count}`
|
||||
);
|
||||
};
|
||||
/**新增浮动ip */
|
||||
export const addFloatingIp = data => {
|
||||
return http2.post("/v1/admin/floating_ip/add", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**批量添加浮动ip */
|
||||
export const addFloatingIpBatch = data => {
|
||||
return http2.post("/v1/admin/floating_ip/add_list", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**删除浮动ip */
|
||||
export const delFloatingIp = data => {
|
||||
return http2.post("/v1/admin/floating_ip/delete", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**获取单个用户操作日志 */
|
||||
export const getUserLog = data => {
|
||||
return http2.get(
|
||||
`/v1/user/procedure/get_user_log?user_id=${data.user_id}&page=${data.page}&count=${data.count}`
|
||||
);
|
||||
};
|
||||
|
||||
/**管理员修改头像 */
|
||||
export const editAvatar = data => {
|
||||
return http2.post("/v1/admin/users/upload_user_avatar", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**获取服务器硬盘信息 */
|
||||
export const getDiskInfo = data => {
|
||||
return http2.get(`/v1/admin/server/get_server_disk?server_id=${data}`);
|
||||
};
|
||||
/**获取服务器实际划分硬盘信息 */
|
||||
export const getRealDisk = data => {
|
||||
return http2.get(`/v1/admin/server/get_server_disk_info?server_id=${data}`);
|
||||
};
|
||||
/**获取服务器流量信息 */
|
||||
export const getTraffic = data => {
|
||||
return http2.get(`/v1/admin/server/get_server_bandwidth?server_id=${data}`);
|
||||
};
|
||||
/**获取版本更新 */
|
||||
export const getVersion = () => {
|
||||
return http2.get(`/v1/admin/version`);
|
||||
};
|
||||
|
||||
// 管理员删除https网络
|
||||
export const AdminDelHttps = data => {
|
||||
return http2.post("/v1/container/proxy/del_https_connet", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 管理员添加https网络
|
||||
export const AdminAddHttps = data => {
|
||||
return http2.post("/v1/container/proxy/add_https_proxy", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取指定端口信息 */
|
||||
export const getPortInfo = data => {
|
||||
return http2.get(`/v1/admin/instance_port/detail?port_id=${data}`);
|
||||
};
|
||||
/**新增卷 */
|
||||
export const addVolumeMount = data => {
|
||||
return http2.post("/v1/admin/volume/add_volume", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**进入救援系统 */
|
||||
export const rescueInstance = id => {
|
||||
return http2.get(`/v1/admin/instance/rescue/enter/${id}`);
|
||||
};
|
||||
|
||||
/**退出救援系统 */
|
||||
export const exitRescueInstance = id => {
|
||||
return http2.get(`/v1/admin/instance/rescue/exit/${id}`);
|
||||
};
|
||||
|
||||
/**修改虚拟机密码 */
|
||||
export const changeInstancePassword = (id, data) => {
|
||||
return http2.post(`/v1/admin/instance/update_password/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**修改虚拟机密码(用户) */
|
||||
export const changeInstancePasswordUser = (id, data) => {
|
||||
return http2.post(`/v1/user/instance/update_password/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
import {http2} from "@/utils/request.js";
|
||||
/**获取全局配置 */
|
||||
export const getSetting = () => {
|
||||
return http2.get('/v1/admin/settings/get_settings')
|
||||
}
|
||||
/**变更设置 */
|
||||
export const updateSetting = (data) => {
|
||||
return http2.post('/v1/admin/settings/update_settings', data, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**新增设置 */
|
||||
export const addSetting = (data) => {
|
||||
return http2.post('/v1/admin/settings/add_settings', data, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**删除设置 */
|
||||
export const deleteSetting = (data) => {
|
||||
return http2.post('/v1/admin/settings/delete_settings', data,{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
}
|
||||
/**获取单项配置 */
|
||||
export const getOneSetting = (data) => {
|
||||
return http2.get(`/v1/admin/settings/get_setting?name=${data}`)
|
||||
}
|
||||
/**获取多个配置 */
|
||||
export const getSettings = (data) => {
|
||||
// return http2.get(`/v1/admin/settings/get_settings?names=${data}`);
|
||||
const namesParam = data.join(',');
|
||||
// 将处理后的namesParam放入URL中
|
||||
return http2.get(`/v1/admin/settings/get_setting?names=${encodeURIComponent(namesParam)}`);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import {http2} from "@/utils/request.js";
|
||||
/**获取用户列表 */
|
||||
export const ask_update_user_email11 = data => {
|
||||
return http2.get(`/v1/user/info/ask_update_user_email?email=${data.email}`);
|
||||
};
|
||||
/**email验证码 */
|
||||
export const ask_update_user_email = data => {
|
||||
return http2.post("/v1/user/info/ask_update_user_email", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**email修改 */
|
||||
export const update_user_email = data => {
|
||||
return http2.post("/v1/user/info/update_user_email", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**phone验证码 */
|
||||
export const ask_update_user_phone = data => {
|
||||
return http2.post("/v1/user/info/ask_update_user_phone", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**phone修改 */
|
||||
export const update_user_phone = data => {
|
||||
return http2.post("/v1/user/info/update_user_phone", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**密码修改 */
|
||||
export const update_user_password = data => {
|
||||
return http2.post("/v1/user/info/update_user_password", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,501 @@
|
||||
|
||||
import {http2} from "@/utils/request.js";
|
||||
// import { getUserContainer } from './user';
|
||||
|
||||
// 获取图像验证码
|
||||
export const Captch = data => {
|
||||
return http2.get(`/v1/user/check/get_code_img`);
|
||||
};
|
||||
|
||||
/** 登录 */
|
||||
export const getLogin = data => {
|
||||
return http2.post("/v1/user/login", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// // /** 刷新token */
|
||||
// export const refreshTokenApi = (data?: object) => {
|
||||
// return http.request<RefreshTokenResult>("post", "/refresh-token", { data });
|
||||
// };
|
||||
|
||||
/**获取用户列表 */
|
||||
export const getUserList = data => {
|
||||
return http2.get(
|
||||
`/v1/admin/users/get_user_list?page=${data.page}&count=${data.count}&key=${data.key}`
|
||||
);
|
||||
};
|
||||
/**添加用户 */
|
||||
export const addUser = data => {
|
||||
return http2.post("/v1/admin/users/add_user", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**编辑用户信息 */
|
||||
export const editUser = data => {
|
||||
return http2.post("/v1/admin/users/update_user", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**修改用户密码 */
|
||||
export const editPassword = data => {
|
||||
return http2.post("/v1/admin/users/update_user_password", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**删除用户 */
|
||||
export const deleteUser = data => {
|
||||
return http2.post("/v1/admin/users/del_user", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**查询单个用户 */
|
||||
export const userDetail = data => {
|
||||
return http2.post("/v1/admin/users/select_user", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**修改用户余额 */
|
||||
export const editBalance = data => {
|
||||
return http2.post("/v1/admin/users/update_user_balance", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取用户服务器 */
|
||||
export const getUserServer = (data = {}) => {
|
||||
const serverType = data.server_type || "dockerContainer"; // 设置默认值
|
||||
return http2.get(
|
||||
`/v1/user/procedure/get_server_list?server_type=${serverType}`
|
||||
);
|
||||
};
|
||||
/**用户获取虚拟机列表 */
|
||||
export const getVirtualList = data => {
|
||||
let url = `/v1/user/instance/list?page=${data.page}&count=${data.count}`;
|
||||
if (data.key) {
|
||||
url += `&key=${data.key}`;
|
||||
}
|
||||
if (data.server_id) {
|
||||
url += `&server_id=${data.server_id}`;
|
||||
}
|
||||
return http2.get(url);
|
||||
};
|
||||
/**用户获取服务器套餐 */
|
||||
export const getUserPackage = data => {
|
||||
return http2.get(`/v1/user/procedure/get_server_plan_list?server_id=${data}`);
|
||||
};
|
||||
/**获取用户容器列表 */
|
||||
export const getUserContainer = data => {
|
||||
return http2.get(
|
||||
`/v1/user/container/list?page=${data.page}&count=${data.count}`
|
||||
);
|
||||
};
|
||||
/**用户按地区获取容器 */
|
||||
export const getUserContainerD = data => {
|
||||
return http2.get(
|
||||
`/v1/user/container/list?page=${data.page}&count=${data.count}&server_id=${data.server_id}`
|
||||
);
|
||||
};
|
||||
/**获取用户操作日志 */
|
||||
export const get_user_log = () => {
|
||||
return http2.get(`/v1/user/procedure/get_user_log`);
|
||||
};
|
||||
/**获取用户自身信息 */
|
||||
export const getUserInfo = () => {
|
||||
return http2.get(`/v1/user/procedure/get_user_info`);
|
||||
};
|
||||
/**获取用户自身信息 */
|
||||
export const getUserInfoV1 = () => {
|
||||
return http2.get(`/v1/user/info/get_user_info`);
|
||||
};
|
||||
/**用户实名 */
|
||||
export const realName = data => {
|
||||
return http2.post("/v1/external/real_name", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**发送手机验证码 */
|
||||
export const sendCode = data => {
|
||||
return http2.post("/v1/external/send_message", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**发送邮箱验证码 */
|
||||
export const sendEmailCode = data => {
|
||||
return http2.post("/v1/external/send_email", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**用户注册 */
|
||||
export const register = data => {
|
||||
return http2.post("/v1/user/register", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**手机号修改校证码 */
|
||||
export const CodePhone = data => {
|
||||
return http2.post("/v1/user/info/ask_update_user_phone", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**修改手机号码 */
|
||||
export const SetPhone = data => {
|
||||
return http2.post("/v1/user/info/update_user_phone", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**邮箱修改校证码 */
|
||||
export const CodeEmail = data => {
|
||||
return http2.post("/v1/user/info/ask_update_user_email", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**修改邮箱 */
|
||||
export const SetEmail = data => {
|
||||
return http2.post("/v1/user/info/update_user_email", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**上传头像 */
|
||||
export const uploadAvatar = data => {
|
||||
return http2.post("/v1/user/info/upload_user_avatar", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**手机号忘记密码 */
|
||||
export const forgetphone = data => {
|
||||
return http2.post("/v1/user/info/forget_user_password_phone", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**邮箱忘记密码 */
|
||||
export const forgetemail = data => {
|
||||
return http2.post("/v1/user/info/forget_user_password_email", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**管理员全局搜索 */
|
||||
export const Find = data => {
|
||||
return http2.post("/v1/admin/search", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
// 管理员删除容器网络
|
||||
export const delContainer = data => {
|
||||
return http2.post("/v1/user/container/delete_connect", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
// 删除端口
|
||||
export const delPort = data => {
|
||||
return http2.post("/v1/admin/instance_port/delete", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
// 自定义容器价格
|
||||
export const Containerpay = data => {
|
||||
return http2.post("/v1/admin/container/update_container_price", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
// 修改虚拟机续费价格
|
||||
export const Containerpaytime = (data, id) => {
|
||||
return http2.post(`/v1/admin/instance/update_price/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
// 自定义容器到期时间
|
||||
export const Containertime = data => {
|
||||
return http2.post("/v1/admin/container/update_container_expire_time", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
// 修改虚拟机续到期时间
|
||||
export const Containertimetime = (data, id) => {
|
||||
return http2.post(`/v1/admin/instance/update_expire_time/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
// 修改虚拟机信息
|
||||
export const editContainer = (data, id) => {
|
||||
return http2.post(`/v1/admin/instance/update/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/***************************************容器管理 ************************/
|
||||
|
||||
/** 容器操作 */
|
||||
export const startUserContainer = (type, id) => {
|
||||
return http2.post(
|
||||
"/v1/user/container/" + type,
|
||||
{
|
||||
container_id: id
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
/**用户容器退款 */
|
||||
export const backUserContainer = data => {
|
||||
return http2.post("/v1/user/container/delete", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**重装容器 */
|
||||
export const reinContainer = data => {
|
||||
return http2.post("/v1/user/container/reinstall", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**重装虚拟机 */
|
||||
export const reinVmContainer = (id, data) => {
|
||||
return http2.post(`/v1/user/instance/reinstall/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/** 容器操作 */
|
||||
export const startAdminContainer = (type, id) => {
|
||||
return http2.post(
|
||||
"/v1/admin/container/" + type,
|
||||
{
|
||||
container_id: id
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
/** 容器操作 */
|
||||
export const procedureUpdateContainerRenew = data => {
|
||||
return http2.post("/v1/user/procedure/update_container_renew", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取容器完整信息 */
|
||||
export const getContainerDetail = id => {
|
||||
return http2.get(`/v1/user/container/detail?container_id=${id}`);
|
||||
};
|
||||
/**获取虚拟机完整信息 */
|
||||
export const getVmContainerDetail = id => {
|
||||
return http2.get(`/v1/user/instance/detail/${id}`);
|
||||
};
|
||||
/**容器操作信息 */
|
||||
export const containerLog = data => {
|
||||
return http2.post("/v1/user/container/logs", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**虚拟机操作日志 */
|
||||
export const vmLog = data => {
|
||||
return http2.get(
|
||||
`/v1/user/instance/log/${data.id}?page=${data.page}&count=${data.count}`
|
||||
);
|
||||
};
|
||||
/**获取容器状态 */
|
||||
export const getContainerStatus = data => {
|
||||
return http2.post(`/v1/user/container/status`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取虚拟机状态 */
|
||||
export const getVmStatus = id => {
|
||||
return http2.get(`/v1/user/instance/get_state/${id}`);
|
||||
};
|
||||
/**获取容器运行日志 */
|
||||
export const getContainerLog = data => {
|
||||
return http2.post(`/v1/user/container/run_logs`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取容器购买网络订单 */
|
||||
export const getContainerList = data => {
|
||||
return http2.post(`/v1/user/procedure/add_network`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**计算容器网络价格 */
|
||||
export const getContainerPrice = data => {
|
||||
return http2.post(`/v1/user/procedure/get_price_network`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/** 启动虚拟机 */
|
||||
export const start_vm = id => {
|
||||
return http2.get(`/v1/user/instance/start/${id}`);
|
||||
};
|
||||
/** 停止虚拟机(关机) */
|
||||
export const stop_vm = id => {
|
||||
return http2.get(`/v1/user/instance/stop/${id}`);
|
||||
};
|
||||
/**重启虚拟机 */
|
||||
export const restart_vm = id => {
|
||||
return http2.get(`/v1/user/instance/reboot/${id}`);
|
||||
};
|
||||
/**获取虚拟机控制台 */
|
||||
export const get_vm_console = id => {
|
||||
return http2.get(`/v1/user/instance/console/${id}`);
|
||||
};
|
||||
/**进入救援系统 */
|
||||
export const rescue_vm = id => {
|
||||
return http2.get(`/v1/user/instance/rescue/enter/${id}`);
|
||||
};
|
||||
/**退出救援系统 */
|
||||
export const unrescue_vm = id => {
|
||||
return http2.get(`/v1/user/instance/rescue/exit/${id}`);
|
||||
};
|
||||
|
||||
// ******************************* new
|
||||
/** 提交充值订单 */
|
||||
export const user_update_container_recharge = data => {
|
||||
return http2.post("/v1/user/procedure/update_container_recharge", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/** 提交容器订单 */
|
||||
export const user_update_plan_info = data => {
|
||||
return http2.post("/v1/user/procedure/update_plan_info", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/** 提交虚拟机订单 */
|
||||
export const user_update_vm_info = data => {
|
||||
return http2.post("/v1/user/procedure/create_vm_trade", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取订单简略信息 */
|
||||
export const getOrderDetail = id => {
|
||||
return http2.get(`/v1/user/procedure/get_low_trade_info?trade_id=${id}`);
|
||||
};
|
||||
/**支付请求 */
|
||||
export const pay_request = data => {
|
||||
return http2.post("/v1/external/pay", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**用户删除容器网络 */
|
||||
export const deleteConNet = data => {
|
||||
return http2.post("/v1/user/container/delete_connect", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 添加https
|
||||
export const additionHttp = data => {
|
||||
return http2.post("/v1/user/container/add_https_connet", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 删除https
|
||||
export const DelHttp = data => {
|
||||
return http2.post("/v1/user/container/del_https_connet", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取新增虚拟机端口价格 */
|
||||
export const getVmPortPrice = data => {
|
||||
return http2.post("/v1/user/procedure/get_price_instance_port", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**提交新增虚拟机端口订单 */
|
||||
export const addVmPort = data => {
|
||||
return http2.post("/v1/user/procedure/add_instance_port", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,171 @@
|
||||
import {http2} from "@/utils/request.js";
|
||||
|
||||
|
||||
/**获取虚拟机列表 */
|
||||
export const getVirtualList = data => {
|
||||
let url = `/v1/admin/instance/list?page=${data.page}&count=${data.count}`;
|
||||
if (data.key) {
|
||||
url += `&key=${data.key}`;
|
||||
}
|
||||
if (data.user_id) {
|
||||
url += `&user_id=${data.user_id}`;
|
||||
}
|
||||
if (data.server_id) {
|
||||
url += `&server_id=${data.server_id}`;
|
||||
}
|
||||
return http2.get(url);
|
||||
};
|
||||
|
||||
/**新增虚拟机 */
|
||||
export const addVirtual = data => {
|
||||
return http2.post("/v1/admin/instance/create_vm", data);
|
||||
};
|
||||
|
||||
/**迁移数据卷 */
|
||||
export const migrate_disk = data => {
|
||||
return http2.post("/v1/admin/volume/migrate_volume", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**获取虚拟机访问控制列表 */
|
||||
export const getVirtualAccessList = data => {
|
||||
let url = `/v1/admin/instance/access_control/list?page=${data.page}&count=${data.count}&instance_id=${data.instance_id}`;
|
||||
return http2.get(url);
|
||||
};
|
||||
/**获取虚拟机访问控制列表(用户) */
|
||||
export const getUserAccessList = data => {
|
||||
let url = `/v1/user/instance/access_control/list?page=${data.page}&count=${data.count}&instance_id=${data.instance_id}`;
|
||||
return http2.get(url);
|
||||
};
|
||||
|
||||
/**创建访问控制 */
|
||||
export const createAccessControl = data => {
|
||||
return http2.post("/v1/admin/instance/access_control/create", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**创建访问控制(用户) */
|
||||
export const createUserAccessControl = data => {
|
||||
return http2.post("/v1/user/instance/access_control/create", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**删除访问控制 */
|
||||
export const deleteAccessControl = data => {
|
||||
return http2.post("/v1/admin/instance/access_control/delete", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**删除访问控制(用户) */
|
||||
export const deleteUserAccessControl = data => {
|
||||
return http2.post("/v1/user/instance/access_control/delete", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**获取虚拟机快照列表 */
|
||||
export const getSnapshotList = data => {
|
||||
let url = `/v1/admin/instance/snapshot/list/${data.instance_id}?page=${data.page}&count=${data.count}`;
|
||||
return http2.get(url);
|
||||
};
|
||||
/**获取虚拟机快照列表(用户) */
|
||||
export const getUserSnapshotList = data => {
|
||||
let url = `/v1/user/instance/snapshot/list/${data.instance_id}?page=${data.page}&count=${data.count}`;
|
||||
return http2.get(url);
|
||||
};
|
||||
/**创建虚拟机快照 */
|
||||
export const createSnapshot = (data, id) => {
|
||||
return http2.post(`/v1/admin/instance/snapshot/create/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**创建虚拟机快照(用户) */
|
||||
export const createUserSnapshot = (data, id) => {
|
||||
return http2.post(`/v1/user/instance/snapshot/create/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**删除虚拟机快照 */
|
||||
export const deleteSnapshot = (data, id) => {
|
||||
return http2.post(`/v1/admin/instance/snapshot/delete/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**恢复虚拟机快照 */
|
||||
export const recoverSnapshot = (data, id) => {
|
||||
return http2.post(`/v1/admin/instance/snapshot/restore/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**恢复虚拟机快照(用户) */
|
||||
export const recoverUserSnapshot = (data, id) => {
|
||||
return http2.post(`/v1/user/instance/snapshot/restore/${id}`, data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
/**获取实时监控 */
|
||||
export const getVirtualLog = data => {
|
||||
return http2.get(
|
||||
`/v1/admin/instance/run_logs/${data.id}?start_time=${data.start_time}&end_time=${data.end_time}`
|
||||
);
|
||||
};
|
||||
/**获取实时监控(用户) */
|
||||
export const getUserVirtualLog = data => {
|
||||
return http2.get(
|
||||
`/v1/user/instance/run_logs/${data.id}?start_time=${data.start_time}&end_time=${data.end_time}`
|
||||
);
|
||||
};
|
||||
|
||||
/**获取新增虚拟机快照数量价格 */
|
||||
export const getSnapshotPrice = data => {
|
||||
return http2.get(`/v1/user/procedure/get_price_snapshot?num=${data}`);
|
||||
};
|
||||
|
||||
/**提交虚拟机购买快照订单 */
|
||||
export const submitSnapshotOrder = data => {
|
||||
return http2.post("/v1/user/procedure/update_container_snapshot", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
// 获取购买虚拟机数据卷价格
|
||||
export const getVolumePrice = data => {
|
||||
return http2.post("/v1/user/procedure/get_price_volume", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 提交虚拟机数据卷订单
|
||||
export const submitVolumeOrder = data => {
|
||||
return http2.post("/v1/user/procedure/update_container_volume", data, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data"
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 复制文本到剪贴板
|
||||
* @param {string} text 要复制的文本
|
||||
* @returns {Promise<boolean>} 是否复制成功
|
||||
*/
|
||||
export const copyDomText = (text) => {
|
||||
// 优先使用 navigator.clipboard API (现代浏览器)
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
return navigator.clipboard.writeText(text)
|
||||
.then(() => {
|
||||
return true;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('复制到剪贴板失败:', error);
|
||||
return fallbackCopyTextToClipboard(text);
|
||||
});
|
||||
} else {
|
||||
// 回退方案
|
||||
return fallbackCopyTextToClipboard(text);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 使用传统方法复制文本到剪贴板
|
||||
* @param {string} text 要复制的文本
|
||||
* @returns {boolean} 是否复制成功
|
||||
*/
|
||||
const fallbackCopyTextToClipboard = (text) => {
|
||||
try {
|
||||
const textArea = document.createElement('textarea');
|
||||
textArea.value = text;
|
||||
|
||||
// 避免滚动到底部
|
||||
textArea.style.top = '0';
|
||||
textArea.style.left = '0';
|
||||
textArea.style.position = 'fixed';
|
||||
textArea.style.opacity = '0';
|
||||
|
||||
document.body.appendChild(textArea);
|
||||
textArea.focus();
|
||||
textArea.select();
|
||||
|
||||
const successful = document.execCommand('copy');
|
||||
document.body.removeChild(textArea);
|
||||
|
||||
return successful;
|
||||
} catch (err) {
|
||||
console.error('复制到剪贴板失败:', err);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
+73
-7
@@ -1,4 +1,26 @@
|
||||
import axios from 'axios'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import router from '@/router'
|
||||
|
||||
// 基础URL
|
||||
const baseUrl = 'https://apiservertest.s1f.ren'
|
||||
|
||||
// 检查URL是否需要认证
|
||||
const urlNeedAuth = (url) => {
|
||||
// 这里可以添加不需要认证的URL列表
|
||||
const noAuthUrls = ['/v1/user/login', '/v1/user/check/get_code_img', '/v1/user/register']
|
||||
return !noAuthUrls.some(noAuthUrl => url.includes(noAuthUrl))
|
||||
}
|
||||
|
||||
// 检查token是否过期
|
||||
const isTokenExpired = () => {
|
||||
const token = localStorage.getItem('token')
|
||||
if (!token) return true
|
||||
|
||||
// 这里可以添加token过期检查逻辑,如果有JWT可以解析它
|
||||
// 简单实现,仅检查token是否存在
|
||||
return false
|
||||
}
|
||||
|
||||
class Request {
|
||||
constructor(config = {}) {
|
||||
@@ -14,10 +36,10 @@ class Request {
|
||||
(config) => {
|
||||
// 在发送请求之前做些什么
|
||||
// 例如:添加 token
|
||||
// const token = localStorage.getItem('token')
|
||||
// if (token) {
|
||||
// config.headers.Authorization = `Bearer ${token}`
|
||||
// }
|
||||
const token = localStorage.getItem('token')
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`
|
||||
}
|
||||
return config
|
||||
},
|
||||
(error) => {
|
||||
@@ -49,7 +71,7 @@ class Request {
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
return Promise.reject(error)
|
||||
return error.response.data
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -82,11 +104,55 @@ class Request {
|
||||
|
||||
// 创建默认实例
|
||||
const request = new Request({
|
||||
baseURL: 'http://localhost:3000',
|
||||
baseURL: baseUrl,
|
||||
timeout: 5000,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
})
|
||||
|
||||
export const mainUrl = baseUrl + "/acs"
|
||||
|
||||
export const http2 = axios.create({
|
||||
baseURL: baseUrl,
|
||||
timeout: 5000,
|
||||
headers: {},
|
||||
});
|
||||
|
||||
http2.interceptors.request.use(config => {
|
||||
const token = localStorage.getItem('token'); // 假设 token 存储在 localStorage
|
||||
if(urlNeedAuth(config.url) && isTokenExpired()){
|
||||
if (token){
|
||||
localStorage.removeItem('token');
|
||||
ElMessage.warning('登陆过期,请重新登陆')
|
||||
}
|
||||
router.push('/login')
|
||||
return Promise.reject();
|
||||
}
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
|
||||
config.url = '/acs' + config.url
|
||||
return config
|
||||
})
|
||||
|
||||
http2.interceptors.response.use(
|
||||
response => response, // 正常响应时直接返回
|
||||
error => {
|
||||
console.log('出现错误', error.response);
|
||||
if (error.response == undefined) {
|
||||
ElMessage.error("服务器错误,请稍后再试");
|
||||
return Promise.reject(error);
|
||||
}
|
||||
const { status } = error.response;
|
||||
if (status === 401) {
|
||||
localStorage.removeItem('token');
|
||||
ElMessage.warning('登陆过期,请重新登陆')
|
||||
router.push('/login')
|
||||
return Promise.reject();
|
||||
}
|
||||
// 其他错误处理(可选)
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
export default request
|
||||
Reference in New Issue
Block a user