Files
----/后端源码/yifan.action-ai.cn/index/js/index.CJFXhG7y.js

506 lines
22 KiB
JavaScript

import { x as ElFormItem, y as ElInput, h as ElButton, w as ElForm, U as ElRow, V as ElCol, l as ElTooltip, ax as ElPopover, F as ElScrollbar, aC as ElCheckbox, al as ElTable, am as ElTableColumn, r as ElText, u as ElEmpty, ao as vLoading, T as ElCard, D as ElMessageBox } from "./element-plus.CkEW9frc.js";
import { _ as __unplugin_components_19 } from "./index.fgd49PES.js";
import { _ as _sfc_main$1 } from "./index.vue_vue_type_script_setup_true_lang.DSV4pgC3.js";
import { J as defineComponent, t as onMounted, aO as resolveComponent, aP as resolveDirective, S as openBlock, _ as createElementBlock, a1 as createBaseVNode, $ as createVNode, a0 as withCtx, o as unref, a6 as withDirectives, T as createBlock, a9 as createTextVNode, aw as withModifiers, H as Fragment, ay as renderList, a8 as createCommentVNode, aa as toDisplayString, z as isRef, r as ref, ak as reactive } from "./.pnpm.BW3P1y8f.js";
import { l as httpRequest } from "./index.CMd5bD1r.js";
import "./_plugin-vue_export-helper.1tPrXgE0.js";
import "./codemirror.CvJAcn2d.js";
const API_PATH = "/monitor/online";
const OnlineAPI = {
// 查询在线用户列表
listOnline(query) {
return httpRequest({
url: `${API_PATH}/list`,
method: "get",
params: query
});
},
// 强退用户
deleteOnline(body) {
return httpRequest({
url: `${API_PATH}/delete`,
method: "delete",
data: body
});
},
// 强退用户
clearOnline() {
return httpRequest({
url: `${API_PATH}/clear`,
method: "delete"
});
}
};
const _hoisted_1 = { class: "app-container" };
const _hoisted_2 = { class: "search-container" };
const _hoisted_3 = { class: "card-header" };
const _hoisted_4 = { class: "data-table__toolbar" };
const _hoisted_5 = { class: "data-table__toolbar--left" };
const _hoisted_6 = { class: "data-table__toolbar--right" };
const _sfc_main = /* @__PURE__ */ defineComponent({
...{
name: "Notice",
inheritAttrs: false
},
__name: "index",
setup(__props) {
const queryFormRef = ref();
const total = ref(0);
const selectIds = ref([]);
const loading = ref(false);
const pageTableData = ref([]);
const tableColumns = ref([
{ label: "选择框", prop: "selection", show: true },
{ label: "序号", prop: "index", show: true },
{ label: "会话编号", prop: "session_id", show: true },
{ label: "登录类型", prop: "login_type", show: true },
{ label: "登录名称", prop: "name", show: true },
{ label: "用户账号", prop: "user_name", show: true },
{ label: "主机", prop: "ipaddr", show: true },
{ label: "登录地点", prop: "login_location", show: true },
{ label: "操作系统", prop: "os", show: true },
{ label: "登录时间", prop: "login_time", show: true },
{ label: "操作", prop: "operation", show: true }
]);
const queryFormData = reactive({
page_no: 1,
page_size: 10,
name: void 0,
login_location: void 0,
ipaddr: void 0
});
async function handleRefresh() {
await loadingData();
}
async function loadingData() {
loading.value = true;
try {
const response = await OnlineAPI.listOnline(queryFormData);
pageTableData.value = response.data.data.items;
total.value = response.data.data.total;
} catch (error) {
console.error(error);
} finally {
loading.value = false;
}
}
async function handleQuery() {
queryFormData.page_no = 1;
loadingData();
}
async function handleResetQuery() {
queryFormRef.value.resetFields();
queryFormData.page_no = 1;
loadingData();
}
async function handleSelectionChange(selection) {
selectIds.value = selection.map((item) => item.id);
}
async function handleSubmit(session_id) {
ElMessageBox.confirm(`确认强制退出会话 ${session_id}?`, "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(async () => {
try {
loading.value = true;
await OnlineAPI.deleteOnline(session_id);
handleResetQuery();
} catch (error) {
console.error(error);
} finally {
loading.value = false;
}
}).catch(() => {
ElMessageBox.close();
});
}
async function handleClear() {
ElMessageBox.confirm("确认强制退出所有用户?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(async () => {
try {
loading.value = true;
await OnlineAPI.clearOnline();
handleResetQuery();
} catch (error) {
console.error(error);
} finally {
loading.value = false;
}
}).catch(() => {
ElMessageBox.close();
});
}
onMounted(() => {
loadingData();
});
return (_ctx, _cache) => {
const _component_el_input = ElInput;
const _component_el_form_item = ElFormItem;
const _component_el_button = ElButton;
const _component_el_form = ElForm;
const _component_QuestionFilled = resolveComponent("QuestionFilled");
const _component_el_tooltip = ElTooltip;
const _component_el_col = ElCol;
const _component_el_row = ElRow;
const _component_el_checkbox = ElCheckbox;
const _component_el_scrollbar = ElScrollbar;
const _component_el_popover = ElPopover;
const _component_el_empty = ElEmpty;
const _component_el_table_column = ElTableColumn;
const _component_el_text = ElText;
const _component_CopyButton = _sfc_main$1;
const _component_el_table = ElTable;
const _component_pagination = __unplugin_components_19;
const _component_el_card = ElCard;
const _directive_hasPerm = resolveDirective("hasPerm");
const _directive_loading = vLoading;
return openBlock(), createElementBlock("div", _hoisted_1, [
createBaseVNode("div", _hoisted_2, [
createVNode(_component_el_form, {
ref_key: "queryFormRef",
ref: queryFormRef,
model: unref(queryFormData),
inline: true,
"label-suffix": ":",
onSubmit: withModifiers(handleQuery, ["prevent"])
}, {
default: withCtx(() => [
createVNode(_component_el_form_item, {
prop: "ipaddr",
label: "IP地址"
}, {
default: withCtx(() => [
createVNode(_component_el_input, {
modelValue: unref(queryFormData).ipaddr,
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(queryFormData).ipaddr = $event),
placeholder: "请输入IP地址",
clearable: ""
}, null, 8, ["modelValue"])
]),
_: 1
}),
createVNode(_component_el_form_item, {
prop: "name",
label: "用户名"
}, {
default: withCtx(() => [
createVNode(_component_el_input, {
modelValue: unref(queryFormData).name,
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => unref(queryFormData).name = $event),
placeholder: "请输入用户名",
clearable: ""
}, null, 8, ["modelValue"])
]),
_: 1
}),
createVNode(_component_el_form_item, {
prop: "login_location",
label: "登录位置"
}, {
default: withCtx(() => [
createVNode(_component_el_input, {
modelValue: unref(queryFormData).login_location,
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => unref(queryFormData).login_location = $event),
placeholder: "请输入登录位置",
clearable: ""
}, null, 8, ["modelValue"])
]),
_: 1
}),
createVNode(_component_el_form_item, { class: "search-buttons" }, {
default: withCtx(() => [
withDirectives((openBlock(), createBlock(_component_el_button, {
type: "primary",
icon: "search",
"native-type": "submit"
}, {
default: withCtx(() => [..._cache[6] || (_cache[6] = [
createTextVNode(" 查询 ", -1)
])]),
_: 1
})), [
[_directive_hasPerm, ["module_monitor:online:query"]]
]),
withDirectives((openBlock(), createBlock(_component_el_button, {
icon: "refresh",
onClick: handleResetQuery
}, {
default: withCtx(() => [..._cache[7] || (_cache[7] = [
createTextVNode(" 重置 ", -1)
])]),
_: 1
})), [
[_directive_hasPerm, ["module_monitor:online:query"]]
])
]),
_: 1
})
]),
_: 1
}, 8, ["model"])
]),
createVNode(_component_el_card, { class: "data-table" }, {
header: withCtx(() => [
createBaseVNode("div", _hoisted_3, [
createBaseVNode("span", null, [
createVNode(_component_el_tooltip, { content: "在线用户列表" }, {
default: withCtx(() => [
createVNode(_component_QuestionFilled, { class: "w-4 h-4 mx-1" })
]),
_: 1
}),
_cache[8] || (_cache[8] = createTextVNode(" 在线用户列表 ", -1))
])
])
]),
footer: withCtx(() => [
createVNode(_component_pagination, {
total: unref(total),
"onUpdate:total": _cache[3] || (_cache[3] = ($event) => isRef(total) ? total.value = $event : null),
page: unref(queryFormData).page_no,
"onUpdate:page": _cache[4] || (_cache[4] = ($event) => unref(queryFormData).page_no = $event),
limit: unref(queryFormData).page_size,
"onUpdate:limit": _cache[5] || (_cache[5] = ($event) => unref(queryFormData).page_size = $event),
onPagination: loadingData
}, null, 8, ["total", "page", "limit"])
]),
default: withCtx(() => [
createBaseVNode("div", _hoisted_4, [
createBaseVNode("div", _hoisted_5, [
createVNode(_component_el_row, { gutter: 10 }, {
default: withCtx(() => [
createVNode(_component_el_col, { span: 1.5 }, {
default: withCtx(() => [
withDirectives((openBlock(), createBlock(_component_el_button, {
type: "danger",
icon: "delete",
onClick: handleClear
}, {
default: withCtx(() => [..._cache[9] || (_cache[9] = [
createTextVNode(" 强退所有 ", -1)
])]),
_: 1
})), [
[_directive_hasPerm, ["module_monitor:online:delete"]]
])
]),
_: 1
})
]),
_: 1
})
]),
createBaseVNode("div", _hoisted_6, [
createVNode(_component_el_row, { gutter: 10 }, {
default: withCtx(() => [
createVNode(_component_el_col, { span: 1.5 }, {
default: withCtx(() => [
createVNode(_component_el_tooltip, { content: "刷新" }, {
default: withCtx(() => [
withDirectives(createVNode(_component_el_button, {
type: "primary",
icon: "refresh",
circle: "",
onClick: handleRefresh
}, null, 512), [
[_directive_hasPerm, ["module_monitor:online:delete"]]
])
]),
_: 1
})
]),
_: 1
}),
createVNode(_component_el_col, { span: 1.5 }, {
default: withCtx(() => [
createVNode(_component_el_popover, {
placement: "bottom",
trigger: "click"
}, {
reference: withCtx(() => [
createVNode(_component_el_button, {
type: "danger",
icon: "operation",
circle: ""
})
]),
default: withCtx(() => [
createVNode(_component_el_scrollbar, { "max-height": "350px" }, {
default: withCtx(() => [
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(tableColumns), (column) => {
return openBlock(), createElementBlock(Fragment, {
key: column.prop
}, [
column.prop ? (openBlock(), createBlock(_component_el_checkbox, {
key: 0,
modelValue: column.show,
"onUpdate:modelValue": ($event) => column.show = $event,
label: column.label
}, null, 8, ["modelValue", "onUpdate:modelValue", "label"])) : createCommentVNode("", true)
], 64);
}), 128))
]),
_: 1
})
]),
_: 1
})
]),
_: 1
})
]),
_: 1
})
])
]),
withDirectives((openBlock(), createBlock(_component_el_table, {
ref: "dataTableRef",
data: unref(pageTableData),
"highlight-current-row": "",
class: "data-table__content",
height: "500",
"max-height": "500",
border: "",
stripe: "",
onSelectionChange: handleSelectionChange
}, {
empty: withCtx(() => [
createVNode(_component_el_empty, {
"image-size": 80,
description: "暂无数据"
})
]),
default: withCtx(() => {
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
return [
((_a = unref(tableColumns).find((col) => col.prop === "selection")) == null ? void 0 : _a.show) ? (openBlock(), createBlock(_component_el_table_column, {
key: 0,
type: "selection",
"min-width": "55",
align: "center"
})) : createCommentVNode("", true),
((_b = unref(tableColumns).find((col) => col.prop === "index")) == null ? void 0 : _b.show) ? (openBlock(), createBlock(_component_el_table_column, {
key: 1,
type: "index",
fixed: "",
label: "序号",
"min-width": "60"
}, {
default: withCtx((scope) => [
createTextVNode(toDisplayString((unref(queryFormData).page_no - 1) * unref(queryFormData).page_size + scope.$index + 1), 1)
]),
_: 1
})) : createCommentVNode("", true),
((_c = unref(tableColumns).find((col) => col.prop === "session_id")) == null ? void 0 : _c.show) ? (openBlock(), createBlock(_component_el_table_column, {
key: "session_id",
label: "会话编号",
prop: "session_id",
"min-width": "250",
"show-overflow-tooltip": ""
})) : createCommentVNode("", true),
((_d = unref(tableColumns).find((col) => col.prop === "login_type")) == null ? void 0 : _d.show) ? (openBlock(), createBlock(_component_el_table_column, {
key: "login_type",
label: "登录类型",
prop: "login_type",
"min-width": "100"
})) : createCommentVNode("", true),
((_e = unref(tableColumns).find((col) => col.prop === "ipaddr")) == null ? void 0 : _e.show) ? (openBlock(), createBlock(_component_el_table_column, {
key: "ipaddr",
label: "IP地址",
prop: "ipaddr",
"min-width": "150",
"show-overflow-tooltip": ""
}, {
default: withCtx((scope) => [
createVNode(_component_el_text, null, {
default: withCtx(() => [
createTextVNode(toDisplayString(scope.row.ipaddr), 1)
]),
_: 2
}, 1024),
scope.row.ipaddr ? (openBlock(), createBlock(_component_CopyButton, {
key: 0,
text: scope.row.ipaddr,
style: { marginLeft: "2px" }
}, null, 8, ["text"])) : createCommentVNode("", true)
]),
_: 1
})) : createCommentVNode("", true),
((_f = unref(tableColumns).find((col) => col.prop === "name")) == null ? void 0 : _f.show) ? (openBlock(), createBlock(_component_el_table_column, {
key: "name",
label: "用户名",
prop: "name",
"min-width": "80",
"show-overflow-tooltip": ""
})) : createCommentVNode("", true),
((_g = unref(tableColumns).find((col) => col.prop === "user_name")) == null ? void 0 : _g.show) ? (openBlock(), createBlock(_component_el_table_column, {
key: "user_name",
label: "账号",
prop: "user_name",
"min-width": "80"
})) : createCommentVNode("", true),
((_h = unref(tableColumns).find((col) => col.prop === "login_location")) == null ? void 0 : _h.show) ? (openBlock(), createBlock(_component_el_table_column, {
key: "login_location",
label: "登录位置",
prop: "login_location",
"min-width": "280",
"show-overflow-tooltip": ""
})) : createCommentVNode("", true),
((_i = unref(tableColumns).find((col) => col.prop === "os")) == null ? void 0 : _i.show) ? (openBlock(), createBlock(_component_el_table_column, {
key: "os",
label: "操作系统",
prop: "os",
"min-width": "120",
"show-overflow-tooltip": ""
})) : createCommentVNode("", true),
((_j = unref(tableColumns).find((col) => col.prop === "login_time")) == null ? void 0 : _j.show) ? (openBlock(), createBlock(_component_el_table_column, {
key: "login_time",
label: "登录时间",
prop: "login_time",
"min-width": "180"
})) : createCommentVNode("", true),
((_k = unref(tableColumns).find((col) => col.prop === "operation")) == null ? void 0 : _k.show) ? (openBlock(), createBlock(_component_el_table_column, {
key: "operation",
fixed: "right",
label: "操作",
"min-width": "100"
}, {
default: withCtx((scope) => [
withDirectives((openBlock(), createBlock(_component_el_button, {
type: "danger",
size: "small",
link: "",
icon: "delete",
onClick: ($event) => handleSubmit(scope.row.session_id)
}, {
default: withCtx(() => [..._cache[10] || (_cache[10] = [
createTextVNode(" 强退 ", -1)
])]),
_: 1
}, 8, ["onClick"])), [
[_directive_hasPerm, ["module_monitor:online:delete"]]
])
]),
_: 1
})) : createCommentVNode("", true)
];
}),
_: 1
}, 8, ["data"])), [
[_directive_loading, unref(loading)]
])
]),
_: 1
})
]);
};
}
});
export {
_sfc_main as default
};