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

752 lines
30 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { x as ElFormItem, y as ElInput, aq as ElSelect, ar as ElOption, h as ElButton, t as ElLink, i as ElIcon, w as ElForm, T as ElCard, ae as user_default, aA as clock_default, C as ElAvatar, aB as monitor_default, q as ElTag, ao as vLoading, u as ElEmpty, l as ElTooltip, P as ElRadioGroup, Q as ElRadio, L as ElDrawer, E as ElMessage, D as ElMessageBox } from "./element-plus.CkEW9frc.js";
import { _ as __unplugin_components_19 } from "./index.fgd49PES.js";
import { _ as _sfc_main$1 } from "./UserTableSelect.vue_vue_type_script_setup_true_lang.7Fjc3bJT.js";
import { J as defineComponent, dY as useRouter, 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, T as createBlock, a8 as createCommentVNode, a6 as withDirectives, a9 as createTextVNode, aa as toDisplayString, aw as withModifiers, H as Fragment, ay as renderList, a3 as normalizeClass, z as isRef, r as ref, ak as reactive, j as computed, n as nextTick } from "./.pnpm.BW3P1y8f.js";
import { l as httpRequest, u as useAppStore, g as useTagsViewStore, D as DeviceEnum } from "./index.CMd5bD1r.js";
import { f as formatToDateTime } from "./dateUtil.SHphbRyf.js";
import { _ as _export_sfc } from "./_plugin-vue_export-helper.1tPrXgE0.js";
import "./codemirror.CvJAcn2d.js";
const API_PATH = "/application/myapp";
const ApplicationAPI = {
/**
* 获取应用详情
* @param id 应用ID
*/
detailApp(id) {
return httpRequest({
url: `${API_PATH}/detail/${id}`,
method: "get"
});
},
/**
* 查询应用列表
* @param query 查询参数
*/
listApp(query) {
return httpRequest({
url: `${API_PATH}/list`,
method: "get",
params: query
});
},
/**
* 创建应用
* @param body 应用信息
*/
createApp(body) {
return httpRequest({
url: `${API_PATH}/create`,
method: "post",
data: body
});
},
/**
* 修改应用
* @param id 应用ID
* @param body 应用信息
*/
updateApp(id, body) {
return httpRequest({
url: `${API_PATH}/update/${id}`,
method: "put",
data: body
});
},
/**
* 删除应用
* @param body 应用ID数组
*/
deleteApp(body) {
return httpRequest({
url: `${API_PATH}/delete`,
method: "delete",
data: body
});
},
/**
* 批量修改应用状态
* @param body 批量操作参数
*/
batchApp(body) {
return httpRequest({
url: `${API_PATH}/available/setting`,
method: "patch",
data: body
});
}
};
const _hoisted_1 = { class: "app-container" };
const _hoisted_2 = { class: "search-container" };
const _hoisted_3 = { class: "card-header" };
const _hoisted_4 = { class: "app-grid-container" };
const _hoisted_5 = { class: "grid-wrapper" };
const _hoisted_6 = ["onMouseenter", "onClick"];
const _hoisted_7 = { class: "app-info-header" };
const _hoisted_8 = { class: "app-title-wrap" };
const _hoisted_9 = ["title"];
const _hoisted_10 = { class: "app-content" };
const _hoisted_11 = ["title"];
const _hoisted_12 = { class: "card-footer" };
const _hoisted_13 = { class: "footer-item" };
const _hoisted_14 = { class: "footer-text" };
const _hoisted_15 = { class: "footer-item" };
const _hoisted_16 = { class: "footer-text" };
const _hoisted_17 = { key: 0 };
const _hoisted_18 = { class: "dialog-footer" };
const _sfc_main = /* @__PURE__ */ defineComponent({
...{
name: "MyApplication",
inheritAttrs: false
},
__name: "index",
setup(__props) {
const appStore = useAppStore();
const tagsViewStore = useTagsViewStore();
const router = useRouter();
const queryFormRef = ref();
const formRef = ref();
const loading = ref(false);
const total = ref(0);
const dialogVisible = ref(false);
const dialogType = ref("create");
const currentApp = ref(null);
const isExpand = ref(false);
const isExpandable = ref(true);
const hoveredCard = ref(null);
const queryFormData = reactive({
page_no: 1,
page_size: 12,
name: void 0,
status: void 0,
created_id: void 0
});
const applicationList = ref([]);
const formData = reactive({
name: "",
access_url: "",
icon_url: "",
status: "0",
description: ""
});
const formRules = reactive({
name: [
{ required: true, message: "请输入应用名称", trigger: "blur" },
{ min: 2, max: 30, message: "长度在 2 到 30 个字符", trigger: "blur" }
],
access_url: [
{ required: true, message: "请输入访问地址", trigger: "blur" },
{ type: "url", message: "请输入正确的URL格式", trigger: "blur" }
],
icon_url: [
{ required: true, message: "请输入图标地址", trigger: "blur" },
{ type: "url", message: "请输入正确的URL格式", trigger: "blur" }
],
status: [{ required: true, message: "请选择应用状态", trigger: "change" }]
});
const drawerSize = computed(() => appStore.device === DeviceEnum.DESKTOP ? "500px" : "90%");
const dialogTitle = computed(() => dialogType.value === "create" ? "创建应用" : "编辑应用");
const formatTime = (time) => {
if (!time) return "未知";
return formatToDateTime(time, "YYYY-MM-DD HH:mm:ss");
};
async function loadApplicationList() {
loading.value = true;
try {
const response = await ApplicationAPI.listApp(queryFormData);
applicationList.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;
await loadApplicationList();
}
function handleConfirm() {
handleQuery();
}
async function handleResetQuery() {
var _a;
(_a = queryFormRef.value) == null ? void 0 : _a.resetFields();
queryFormData.page_no = 1;
await loadApplicationList();
}
function handleCreateApp() {
console.log("handleCreateApp");
dialogType.value = "create";
resetForm();
dialogVisible.value = true;
}
function handleEditApp(app) {
dialogType.value = "edit";
currentApp.value = app;
Object.assign(formData, app);
dialogVisible.value = true;
}
async function handleDeleteApp(app) {
try {
await ElMessageBox.confirm("确认删除该应用?", "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
});
await ApplicationAPI.deleteApp([app.id]);
await loadApplicationList();
} catch (error) {
if (error !== "cancel") {
console.error("删除应用失败:", error);
}
}
}
async function handleAppAction(command, app) {
switch (command) {
case "edit":
handleEditApp(app);
break;
case "delete":
await handleDeleteApp(app);
break;
}
}
function openAppInternal(app) {
if (!app.status || !app.id) {
if (!app.status) {
ElMessage.warning("应用已停用,无法打开");
} else {
ElMessage.warning("应用ID不存在无法打开");
}
return;
}
if (!app.access_url) {
ElMessage.warning("应用访问地址不存在");
return;
}
const appPath = `/internal-app/${app.id}`;
const appName = `InternalApp${app.id}`;
const appTitle = app.name || "未命名应用";
router.push({
path: appPath,
query: { url: app.access_url, appId: app.id.toString(), appName: appTitle }
}).then(() => {
nextTick(() => {
var _a;
const existingTag = tagsViewStore.visitedViews.find((tag) => tag.path === appPath);
if (existingTag) {
tagsViewStore.updateVisitedView({
...existingTag,
title: appTitle
});
} else {
tagsViewStore.addView({
name: appName,
title: appTitle,
path: appPath,
fullPath: appPath + `?url=${encodeURIComponent(app.access_url || "")}&appId=${app.id}&appName=${encodeURIComponent(appTitle)}`,
icon: "Monitor",
affix: false,
keepAlive: false,
query: { url: app.access_url, appId: (_a = app == null ? void 0 : app.id) == null ? void 0 : _a.toString(), appName: appTitle }
});
}
});
});
}
function resetForm() {
var _a;
Object.assign(formData, {
name: "",
access_url: "",
icon_url: "",
status: "0",
description: ""
});
(_a = formRef.value) == null ? void 0 : _a.resetFields();
}
function handleCloseDialog() {
dialogVisible.value = false;
resetForm();
}
async function handleSubmit() {
var _a;
try {
await ((_a = formRef.value) == null ? void 0 : _a.validate());
if (dialogType.value === "create") {
await ApplicationAPI.createApp(formData);
} else {
await ApplicationAPI.updateApp(currentApp.value.id, formData);
}
dialogVisible.value = false;
resetForm();
await loadApplicationList();
} catch (error) {
console.error("提交失败:", error);
}
}
onMounted(() => {
loadApplicationList();
});
return (_ctx, _cache) => {
const _component_el_input = ElInput;
const _component_el_form_item = ElFormItem;
const _component_el_option = ElOption;
const _component_el_select = ElSelect;
const _component_UserTableSelect = _sfc_main$1;
const _component_el_button = ElButton;
const _component_ArrowUp = resolveComponent("ArrowUp");
const _component_ArrowDown = resolveComponent("ArrowDown");
const _component_el_icon = ElIcon;
const _component_el_link = ElLink;
const _component_el_form = ElForm;
const _component_QuestionFilled = resolveComponent("QuestionFilled");
const _component_el_tooltip = ElTooltip;
const _component_el_avatar = ElAvatar;
const _component_el_tag = ElTag;
const _component_el_card = ElCard;
const _component_el_empty = ElEmpty;
const _component_pagination = __unplugin_components_19;
const _component_el_radio = ElRadio;
const _component_el_radio_group = ElRadioGroup;
const _component_el_drawer = ElDrawer;
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: "name",
label: "应用名称"
}, {
default: withCtx(() => [
createVNode(_component_el_input, {
modelValue: unref(queryFormData).name,
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(queryFormData).name = $event),
placeholder: "请输入应用名称",
clearable: ""
}, null, 8, ["modelValue"])
]),
_: 1
}),
createVNode(_component_el_form_item, {
prop: "status",
label: "状态"
}, {
default: withCtx(() => [
createVNode(_component_el_select, {
modelValue: unref(queryFormData).status,
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => unref(queryFormData).status = $event),
placeholder: "请选择状态",
clearable: "",
style: { "width": "170px" }
}, {
default: withCtx(() => [
createVNode(_component_el_option, {
label: "启用",
value: true
}),
createVNode(_component_el_option, {
label: "停用",
value: false
})
]),
_: 1
}, 8, ["modelValue"])
]),
_: 1
}),
unref(isExpand) ? (openBlock(), createBlock(_component_el_form_item, {
key: 0,
prop: "created_id",
label: "创建人"
}, {
default: withCtx(() => [
createVNode(_component_UserTableSelect, {
modelValue: unref(queryFormData).created_id,
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => unref(queryFormData).created_id = $event),
onConfirmClick: handleConfirm,
onClearClick: handleQuery
}, null, 8, ["modelValue"])
]),
_: 1
})) : createCommentVNode("", true),
unref(isExpand) ? (openBlock(), createBlock(_component_el_form_item, {
key: 1,
prop: "updated_id",
label: "更新人"
}, {
default: withCtx(() => [
createVNode(_component_UserTableSelect, {
modelValue: unref(queryFormData).updated_id,
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => unref(queryFormData).updated_id = $event),
onConfirmClick: handleConfirm,
onClearClick: handleQuery
}, null, 8, ["modelValue"])
]),
_: 1
})) : createCommentVNode("", true),
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[16] || (_cache[16] = [
createTextVNode(" 查询 ", -1)
])]),
_: 1
})), [
[_directive_hasPerm, ["module_module_application:myapp:query"]]
]),
withDirectives((openBlock(), createBlock(_component_el_button, {
icon: "refresh",
onClick: handleResetQuery
}, {
default: withCtx(() => [..._cache[17] || (_cache[17] = [
createTextVNode(" 重置 ", -1)
])]),
_: 1
})), [
[_directive_hasPerm, ["module_application:myapp:query"]]
]),
unref(isExpandable) ? (openBlock(), createBlock(_component_el_link, {
key: 0,
class: "ml-3",
type: "primary",
underline: "never",
onClick: _cache[4] || (_cache[4] = ($event) => isExpand.value = !unref(isExpand))
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(unref(isExpand) ? "收起" : "展开") + " ", 1),
createVNode(_component_el_icon, null, {
default: withCtx(() => [
unref(isExpand) ? (openBlock(), createBlock(_component_ArrowUp, { key: 0 })) : (openBlock(), createBlock(_component_ArrowDown, { key: 1 }))
]),
_: 1
})
]),
_: 1
})) : createCommentVNode("", true)
]),
_: 1
})
]),
_: 1
}, 8, ["model"])
]),
createVNode(_component_el_card, {
shadow: "hover",
class: "app-grid-card"
}, {
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[18] || (_cache[18] = createTextVNode(" 应用市场 ", -1))
]),
withDirectives((openBlock(), createBlock(_component_el_button, {
type: "primary",
icon: "plus",
onClick: handleCreateApp
}, {
default: withCtx(() => [..._cache[19] || (_cache[19] = [
createTextVNode(" 创建应用 ", -1)
])]),
_: 1
})), [
[_directive_hasPerm, ["module_application:myapp:create"]]
])
])
]),
footer: withCtx(() => [
createVNode(_component_pagination, {
total: unref(total),
"onUpdate:total": _cache[7] || (_cache[7] = ($event) => isRef(total) ? total.value = $event : null),
page: unref(queryFormData).page_no,
"onUpdate:page": _cache[8] || (_cache[8] = ($event) => unref(queryFormData).page_no = $event),
limit: unref(queryFormData).page_size,
"onUpdate:limit": _cache[9] || (_cache[9] = ($event) => unref(queryFormData).page_size = $event),
"page-sizes": [12, 24, 48],
onPagination: loadApplicationList
}, null, 8, ["total", "page", "limit"])
]),
default: withCtx(() => [
withDirectives((openBlock(), createElementBlock("div", _hoisted_4, [
createBaseVNode("div", _hoisted_5, [
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(applicationList), (app) => {
return openBlock(), createElementBlock("div", {
key: app.id,
onMouseenter: ($event) => app.id && (hoveredCard.value = app.id),
onMouseleave: _cache[6] || (_cache[6] = ($event) => hoveredCard.value = null),
onClick: ($event) => app.status && app.id && openAppInternal(app)
}, [
createVNode(_component_el_card, {
shadow: "hover",
class: normalizeClass(["app-card", { "card-disabled": !app.status }])
}, {
header: withCtx(() => [
createBaseVNode("div", _hoisted_7, [
createVNode(_component_el_avatar, {
size: 42,
src: app.icon_url,
class: "app-avatar"
}, {
default: withCtx(() => [
createVNode(_component_el_icon, { size: "20" }, {
default: withCtx(() => [
createVNode(unref(monitor_default))
]),
_: 1
})
]),
_: 1
}, 8, ["src"]),
createBaseVNode("div", _hoisted_8, [
createBaseVNode("h3", {
class: "app-name",
title: app.name
}, toDisplayString(app.name), 9, _hoisted_9),
createVNode(_component_el_tag, {
type: app.status ? "success" : "info",
size: "small",
effect: "plain",
class: "status-tag"
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(app.status ? "启用" : "停用"), 1)
]),
_: 2
}, 1032, ["type"])
]),
unref(hoveredCard) === app.id ? (openBlock(), createElementBlock("div", {
key: 0,
class: "card-actions",
onClick: _cache[5] || (_cache[5] = withModifiers(() => {
}, ["stop"]))
}, [
withDirectives(createVNode(_component_el_button, {
type: "primary",
link: "",
icon: "Edit",
onClick: ($event) => handleAppAction("edit", app)
}, null, 8, ["onClick"]), [
[_directive_hasPerm, ["module_application:myapp:update"]]
]),
withDirectives(createVNode(_component_el_button, {
type: "danger",
link: "",
icon: "Delete",
onClick: ($event) => handleAppAction("delete", app)
}, null, 8, ["onClick"]), [
[_directive_hasPerm, ["module_application:myapp:delete"]]
])
])) : createCommentVNode("", true)
])
]),
default: withCtx(() => [
createBaseVNode("div", _hoisted_10, [
createBaseVNode("p", {
class: "app-description",
title: app.description
}, toDisplayString(app.description || "暂无描述"), 9, _hoisted_11)
])
]),
footer: withCtx(() => {
var _a;
return [
createBaseVNode("div", _hoisted_12, [
createBaseVNode("div", _hoisted_13, [
createVNode(_component_el_icon, {
size: "14",
class: "footer-icon"
}, {
default: withCtx(() => [
createVNode(unref(user_default))
]),
_: 1
}),
createBaseVNode("span", _hoisted_14, toDisplayString(((_a = app.created_by) == null ? void 0 : _a.name) || "未知"), 1)
]),
createBaseVNode("div", _hoisted_15, [
createVNode(_component_el_icon, {
size: "14",
class: "footer-icon"
}, {
default: withCtx(() => [
createVNode(unref(clock_default))
]),
_: 1
}),
createBaseVNode("span", _hoisted_16, toDisplayString(formatTime(app.created_time)), 1)
])
])
];
}),
_: 2
}, 1032, ["class"])
], 40, _hoisted_6);
}), 128))
])
])), [
[_directive_loading, unref(loading)]
]),
unref(applicationList).length === 0 && !unref(loading) ? (openBlock(), createElementBlock("div", _hoisted_17, [
createVNode(_component_el_empty, {
"image-size": 80,
description: "暂无数据"
})
])) : createCommentVNode("", true)
]),
_: 1
}),
createVNode(_component_el_drawer, {
modelValue: unref(dialogVisible),
"onUpdate:modelValue": _cache[15] || (_cache[15] = ($event) => isRef(dialogVisible) ? dialogVisible.value = $event : null),
title: unref(dialogTitle),
size: unref(drawerSize),
direction: "rtl",
onClose: handleCloseDialog
}, {
footer: withCtx(() => [
createBaseVNode("div", _hoisted_18, [
createVNode(_component_el_button, { onClick: handleCloseDialog }, {
default: withCtx(() => [..._cache[22] || (_cache[22] = [
createTextVNode("取消", -1)
])]),
_: 1
}),
createVNode(_component_el_button, {
type: "primary",
onClick: handleSubmit
}, {
default: withCtx(() => [..._cache[23] || (_cache[23] = [
createTextVNode("确定", -1)
])]),
_: 1
})
])
]),
default: withCtx(() => [
createVNode(_component_el_form, {
ref_key: "formRef",
ref: formRef,
model: unref(formData),
rules: unref(formRules),
"label-width": "100px",
"label-position": "right"
}, {
default: withCtx(() => [
createVNode(_component_el_form_item, {
label: "应用名称",
prop: "name"
}, {
default: withCtx(() => [
createVNode(_component_el_input, {
modelValue: unref(formData).name,
"onUpdate:modelValue": _cache[10] || (_cache[10] = ($event) => unref(formData).name = $event),
placeholder: "请输入应用名称"
}, null, 8, ["modelValue"])
]),
_: 1
}),
createVNode(_component_el_form_item, {
label: "访问地址",
prop: "access_url"
}, {
default: withCtx(() => [
createVNode(_component_el_input, {
modelValue: unref(formData).access_url,
"onUpdate:modelValue": _cache[11] || (_cache[11] = ($event) => unref(formData).access_url = $event),
placeholder: "请输入访问地址"
}, null, 8, ["modelValue"])
]),
_: 1
}),
createVNode(_component_el_form_item, {
label: "图标地址",
prop: "icon_url"
}, {
default: withCtx(() => [
createVNode(_component_el_input, {
modelValue: unref(formData).icon_url,
"onUpdate:modelValue": _cache[12] || (_cache[12] = ($event) => unref(formData).icon_url = $event),
placeholder: "请输入图标地址"
}, null, 8, ["modelValue"])
]),
_: 1
}),
createVNode(_component_el_form_item, {
label: "应用状态",
prop: "status"
}, {
default: withCtx(() => [
createVNode(_component_el_radio_group, {
modelValue: unref(formData).status,
"onUpdate:modelValue": _cache[13] || (_cache[13] = ($event) => unref(formData).status = $event)
}, {
default: withCtx(() => [
createVNode(_component_el_radio, { value: "0" }, {
default: withCtx(() => [..._cache[20] || (_cache[20] = [
createTextVNode("启用", -1)
])]),
_: 1
}),
createVNode(_component_el_radio, { value: "1" }, {
default: withCtx(() => [..._cache[21] || (_cache[21] = [
createTextVNode("停用", -1)
])]),
_: 1
})
]),
_: 1
}, 8, ["modelValue"])
]),
_: 1
}),
createVNode(_component_el_form_item, {
label: "应用描述",
prop: "description"
}, {
default: withCtx(() => [
createVNode(_component_el_input, {
modelValue: unref(formData).description,
"onUpdate:modelValue": _cache[14] || (_cache[14] = ($event) => unref(formData).description = $event),
type: "textarea",
rows: 4,
placeholder: "请输入应用描述",
maxlength: "200",
"show-word-limit": ""
}, null, 8, ["modelValue"])
]),
_: 1
})
]),
_: 1
}, 8, ["model", "rules"])
]),
_: 1
}, 8, ["modelValue", "title", "size"])
]);
};
}
});
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-343310bd"]]);
export {
index as default
};