749 lines
38 KiB
JavaScript
749 lines
38 KiB
JavaScript
import { a5 as ElTabs, a6 as ElTabPane, w as ElForm, s as ElDivider, x as ElFormItem, y as ElInput, E as ElMessage, h as ElButton, M as ElSwitch, L as ElDrawer, D as ElMessageBox } from "./element-plus.CkEW9frc.js";
|
||
import { u as useAppStore, c as useConfigStore, P as ParamsAPI, D as DeviceEnum } from "./index.CMd5bD1r.js";
|
||
import { J as defineComponent, e9 as useI18n, t as onMounted, aP as resolveDirective, S as openBlock, T as createBlock, a0 as withCtx, $ as createVNode, a9 as createTextVNode, _ as createElementBlock, H as Fragment, ay as renderList, a1 as createBaseVNode, o as unref, a6 as withDirectives, j as computed, r as ref, ak as reactive } from "./.pnpm.BW3P1y8f.js";
|
||
import { S as SingleImageUpload } from "./SingleImageUpload.CngBsWfh.js";
|
||
import { _ as _export_sfc } from "./_plugin-vue_export-helper.1tPrXgE0.js";
|
||
import "./codemirror.CvJAcn2d.js";
|
||
const _hoisted_1 = { class: "flex items-center gap-2 w-full" };
|
||
const _hoisted_2 = { class: "flex items-center gap-2 w-full" };
|
||
const _hoisted_3 = { class: "flex items-center gap-2 w-full" };
|
||
const _hoisted_4 = { class: "flex items-center gap-2 w-full" };
|
||
const _hoisted_5 = { class: "space-y-2" };
|
||
const _hoisted_6 = { class: "space-y-2" };
|
||
const _hoisted_7 = {
|
||
key: 1,
|
||
class: "space-y-2"
|
||
};
|
||
const _sfc_main = /* @__PURE__ */ defineComponent({
|
||
__name: "ConfigInfoDrawer",
|
||
props: {
|
||
modelValue: { type: Boolean }
|
||
},
|
||
emits: ["update:modelValue"],
|
||
setup(__props, { emit: __emit }) {
|
||
const generateId = () => {
|
||
return Math.random().toString(36).substr(2, 9);
|
||
};
|
||
const isValidIp = (ip) => {
|
||
const ipRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
||
return ipRegex.test(ip);
|
||
};
|
||
const isValidApiPath = (path) => {
|
||
const pathRegex = /^\/[\w\-/]+$/;
|
||
return pathRegex.test(path);
|
||
};
|
||
const appStore = useAppStore();
|
||
const drawerSize = computed(() => appStore.device === DeviceEnum.DESKTOP ? "60%" : "60%");
|
||
const t = useI18n().t;
|
||
const configStore = useConfigStore();
|
||
const activeTabRef = ref("website");
|
||
const props = __props;
|
||
const emit = __emit;
|
||
const drawerVisible = computed({
|
||
get: () => props.modelValue,
|
||
set: (val) => emit("update:modelValue", val)
|
||
});
|
||
const configState = reactive({
|
||
id: void 0,
|
||
config_name: "",
|
||
config_key: "",
|
||
config_value: "",
|
||
config_type: void 0,
|
||
description: ""
|
||
});
|
||
const modifiedFields = reactive({});
|
||
const markModified = (key) => {
|
||
modifiedFields[key] = true;
|
||
};
|
||
const hasChanges = computed(() => Object.keys(modifiedFields).length > 0);
|
||
const submitChanges = async () => {
|
||
var _a, _b, _c;
|
||
const keysToSubmit = Object.keys(modifiedFields);
|
||
if (keysToSubmit.length === 0) return;
|
||
try {
|
||
if ("white_api_list_path" in modifiedFields && ((_a = apiWhitelistConfigs.value.white_api_list_path) == null ? void 0 : _a.id)) {
|
||
const apiWhitelistArray = apiWhitelistItems.value.map((item) => item.value.trim()).filter(Boolean);
|
||
const apiWhitelistJson = JSON.stringify(apiWhitelistArray);
|
||
await ParamsAPI.updateParams(apiWhitelistConfigs.value.white_api_list_path.id, {
|
||
...apiWhitelistConfigs.value.white_api_list_path,
|
||
config_value: apiWhitelistJson
|
||
});
|
||
}
|
||
if ("ip_black_list" in modifiedFields && ((_b = ipBlacklistConfigs.value.ip_black_list) == null ? void 0 : _b.id)) {
|
||
const ipBlacklistArray = ipBlacklistItems.value.map((item) => item.value.trim()).filter(Boolean);
|
||
const ipBlacklistJson = JSON.stringify(ipBlacklistArray);
|
||
await ParamsAPI.updateParams(ipBlacklistConfigs.value.ip_black_list.id, {
|
||
...ipBlacklistConfigs.value.ip_black_list,
|
||
config_value: ipBlacklistJson
|
||
});
|
||
}
|
||
if ("ip_white_list" in modifiedFields && ((_c = demoConfigs.value.ip_white_list) == null ? void 0 : _c.id)) {
|
||
const demoIpWhitelistArray = demoIpWhitelistItems.value.map((item) => item.value.trim()).filter(Boolean);
|
||
const demoIpWhitelistJson = JSON.stringify(demoIpWhitelistArray);
|
||
await ParamsAPI.updateParams(demoConfigs.value.ip_white_list.id, {
|
||
...demoConfigs.value.ip_white_list,
|
||
config_value: demoIpWhitelistJson
|
||
});
|
||
}
|
||
const otherKeys = keysToSubmit.filter(
|
||
(key) => !["white_api_list_path", "ip_black_list", "ip_white_list"].includes(key)
|
||
);
|
||
const otherUpdatePromises = otherKeys.map((key) => {
|
||
const item = systemConfigs.value[key] || logoConfigs.value[key] || securityPrivacyConfigs.value[key] || userAgreementConfigs.value[key] || demoConfigs.value[key];
|
||
return item && item.id ? ParamsAPI.updateParams(item.id, { ...item }) : Promise.resolve();
|
||
});
|
||
await Promise.all(otherUpdatePromises);
|
||
keysToSubmit.forEach((key) => {
|
||
delete modifiedFields[key];
|
||
});
|
||
await configStore.getConfig();
|
||
initializeLists();
|
||
} catch (error) {
|
||
console.error("保存失败:", error);
|
||
}
|
||
};
|
||
const resetForm = () => {
|
||
var _a, _b, _c, _d, _e;
|
||
initializeLists();
|
||
const keysToReset = Object.keys(modifiedFields);
|
||
for (const key of keysToReset) {
|
||
if (systemConfigs.value[key]) {
|
||
systemConfigs.value[key].config_value = ((_a = configStore.configData[key]) == null ? void 0 : _a.config_value) || "";
|
||
} else if (logoConfigs.value[key]) {
|
||
logoConfigs.value[key].config_value = ((_b = configStore.configData[key]) == null ? void 0 : _b.config_value) || "";
|
||
} else if (securityPrivacyConfigs.value[key]) {
|
||
securityPrivacyConfigs.value[key].config_value = ((_c = configStore.configData[key]) == null ? void 0 : _c.config_value) || "";
|
||
} else if (userAgreementConfigs.value[key]) {
|
||
userAgreementConfigs.value[key].config_value = ((_d = configStore.configData[key]) == null ? void 0 : _d.config_value) || "";
|
||
} else if (demoConfigs.value[key]) {
|
||
if (key !== "ip_white_list") {
|
||
demoConfigs.value[key].config_value = ((_e = configStore.configData[key]) == null ? void 0 : _e.config_value) || "";
|
||
}
|
||
}
|
||
delete modifiedFields[key];
|
||
}
|
||
ElMessageBox.close();
|
||
};
|
||
async function handleCloseDialog() {
|
||
drawerVisible.value = false;
|
||
}
|
||
function onDrawerClosed() {
|
||
resetForm();
|
||
}
|
||
const systemConfigs = computed(() => ({
|
||
sys_web_title: configStore.configData.sys_web_title,
|
||
sys_web_version: configStore.configData.sys_web_version,
|
||
sys_web_description: configStore.configData.sys_web_description
|
||
}));
|
||
const securityPrivacyConfigs = computed(() => ({
|
||
sys_help_doc: configStore.configData.sys_help_doc,
|
||
sys_git_code: configStore.configData.sys_git_code,
|
||
sys_keep_record: configStore.configData.sys_keep_record,
|
||
sys_web_copyright: configStore.configData.sys_web_copyright,
|
||
sys_web_privacy: configStore.configData.sys_web_privacy
|
||
}));
|
||
const userAgreementConfigs = computed(() => ({
|
||
sys_web_clause: configStore.configData.sys_web_clause
|
||
}));
|
||
const apiWhitelistItems = ref([]);
|
||
const ipBlacklistItems = ref([]);
|
||
const demoIpWhitelistItems = ref([]);
|
||
const initializeLists = () => {
|
||
var _a, _b, _c;
|
||
const apiWhitelistStr = ((_a = configStore.configData.white_api_list_path) == null ? void 0 : _a.config_value) || "";
|
||
try {
|
||
const apiWhitelistArray = JSON.parse(apiWhitelistStr);
|
||
if (Array.isArray(apiWhitelistArray)) {
|
||
apiWhitelistItems.value = apiWhitelistArray.filter((item) => typeof item === "string" && item.trim()).map((item) => ({ id: generateId(), value: item.trim() }));
|
||
} else {
|
||
apiWhitelistItems.value = apiWhitelistStr ? apiWhitelistStr.split("\n").filter((item) => item.trim()).map((item) => ({ id: generateId(), value: item.trim() })) : [{ id: generateId(), value: "" }];
|
||
}
|
||
} catch {
|
||
apiWhitelistItems.value = apiWhitelistStr ? apiWhitelistStr.split("\n").filter((item) => item.trim()).map((item) => ({ id: generateId(), value: item.trim() })) : [{ id: generateId(), value: "" }];
|
||
}
|
||
const ipBlacklistStr = ((_b = configStore.configData.ip_black_list) == null ? void 0 : _b.config_value) || "";
|
||
try {
|
||
const ipBlacklistArray = JSON.parse(ipBlacklistStr);
|
||
if (Array.isArray(ipBlacklistArray)) {
|
||
ipBlacklistItems.value = ipBlacklistArray.filter((item) => typeof item === "string" && item.trim()).map((item) => ({ id: generateId(), value: item.trim() }));
|
||
} else {
|
||
ipBlacklistItems.value = ipBlacklistStr ? ipBlacklistStr.split("\n").filter((item) => item.trim()).map((item) => ({ id: generateId(), value: item.trim() })) : [{ id: generateId(), value: "" }];
|
||
}
|
||
} catch {
|
||
ipBlacklistItems.value = ipBlacklistStr ? ipBlacklistStr.split("\n").filter((item) => item.trim()).map((item) => ({ id: generateId(), value: item.trim() })) : [{ id: generateId(), value: "" }];
|
||
}
|
||
const demoIpWhitelistStr = ((_c = configStore.configData.ip_white_list) == null ? void 0 : _c.config_value) || "";
|
||
try {
|
||
const demoIpWhitelistArray = JSON.parse(demoIpWhitelistStr);
|
||
if (Array.isArray(demoIpWhitelistArray)) {
|
||
demoIpWhitelistItems.value = demoIpWhitelistArray.filter((item) => typeof item === "string" && item.trim()).map((item) => ({ id: generateId(), value: item.trim() }));
|
||
} else {
|
||
demoIpWhitelistItems.value = demoIpWhitelistStr ? demoIpWhitelistStr.split("\n").filter((item) => item.trim()).map((item) => ({ id: generateId(), value: item.trim() })) : [{ id: generateId(), value: "" }];
|
||
}
|
||
} catch {
|
||
demoIpWhitelistItems.value = demoIpWhitelistStr ? demoIpWhitelistStr.split("\n").filter((item) => item.trim()).map((item) => ({ id: generateId(), value: item.trim() })) : [{ id: generateId(), value: "" }];
|
||
}
|
||
};
|
||
const addApiWhitelistItem = () => {
|
||
apiWhitelistItems.value.push({ id: generateId(), value: "" });
|
||
markModified("white_api_list_path");
|
||
};
|
||
const removeApiWhitelistItem = (id) => {
|
||
if (apiWhitelistItems.value.length <= 1) {
|
||
ElMessage.warning("至少需要保留一个接口白名单配置");
|
||
return;
|
||
}
|
||
apiWhitelistItems.value = apiWhitelistItems.value.filter((item) => item.id !== id);
|
||
markModified("white_api_list_path");
|
||
};
|
||
const addIpBlacklistItem = () => {
|
||
ipBlacklistItems.value.push({ id: generateId(), value: "" });
|
||
markModified("ip_black_list");
|
||
};
|
||
const removeIpBlacklistItem = (id) => {
|
||
if (ipBlacklistItems.value.length <= 1) {
|
||
ElMessage.warning("至少需要保留一个IP黑名单配置");
|
||
return;
|
||
}
|
||
ipBlacklistItems.value = ipBlacklistItems.value.filter((item) => item.id !== id);
|
||
markModified("ip_black_list");
|
||
};
|
||
const addDemoIpWhitelistItem = () => {
|
||
demoIpWhitelistItems.value.push({ id: generateId(), value: "" });
|
||
markModified("ip_white_list");
|
||
};
|
||
const removeDemoIpWhitelistItem = (id) => {
|
||
if (demoIpWhitelistItems.value.length <= 1) {
|
||
ElMessage.warning("至少需要保留一个IP白名单配置");
|
||
return;
|
||
}
|
||
demoIpWhitelistItems.value = demoIpWhitelistItems.value.filter((item) => item.id !== id);
|
||
markModified("ip_white_list");
|
||
};
|
||
const apiWhitelistConfigs = computed(() => ({
|
||
white_api_list_path: configStore.configData.white_api_list_path
|
||
}));
|
||
const ipBlacklistConfigs = computed(() => ({
|
||
ip_black_list: configStore.configData.ip_black_list
|
||
}));
|
||
const demoConfigs = computed(() => ({
|
||
demo_enable: configStore.configData.demo_enable,
|
||
ip_white_list: configStore.configData.ip_white_list
|
||
}));
|
||
onMounted(() => {
|
||
initializeLists();
|
||
});
|
||
const logoConfigs = computed(() => ({
|
||
sys_web_logo: {
|
||
...configStore.configData.sys_web_logo,
|
||
maxFileSize: 5
|
||
},
|
||
sys_web_favicon: {
|
||
...configStore.configData.sys_web_favicon,
|
||
maxFileSize: 5
|
||
},
|
||
sys_login_background: {
|
||
...configStore.configData.sys_login_background,
|
||
maxFileSize: 10
|
||
}
|
||
}));
|
||
const handleUploadSuccess = (fileInfo, type) => {
|
||
const fileUrl = fileInfo.file_url;
|
||
if (type in configStore.configData) {
|
||
configStore.configData[type].config_value = fileUrl;
|
||
}
|
||
if (type in systemConfigs.value) {
|
||
systemConfigs.value[type].config_value = fileUrl;
|
||
} else if (type in logoConfigs.value) {
|
||
logoConfigs.value[type].config_value = fileUrl;
|
||
}
|
||
markModified(type);
|
||
};
|
||
const handleUploadError = (error) => {
|
||
console.error("上传失败:", error.message || "未知错误");
|
||
ElMessage.error(`上传失败:${error.message || "请稍后重试"}`);
|
||
};
|
||
onMounted(() => {
|
||
configStore.getConfig();
|
||
});
|
||
return (_ctx, _cache) => {
|
||
const _component_el_divider = ElDivider;
|
||
const _component_el_input = ElInput;
|
||
const _component_el_form_item = ElFormItem;
|
||
const _component_el_form = ElForm;
|
||
const _component_el_tab_pane = ElTabPane;
|
||
const _component_el_button = ElButton;
|
||
const _component_el_switch = ElSwitch;
|
||
const _component_el_tabs = ElTabs;
|
||
const _component_el_drawer = ElDrawer;
|
||
const _directive_hasPerm = resolveDirective("hasPerm");
|
||
return openBlock(), createBlock(_component_el_drawer, {
|
||
modelValue: drawerVisible.value,
|
||
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => drawerVisible.value = $event),
|
||
title: "配置中心",
|
||
size: drawerSize.value,
|
||
"destroy-on-close": "",
|
||
onClosed: onDrawerClosed
|
||
}, {
|
||
footer: withCtx(() => [
|
||
createVNode(_component_el_button, { onClick: handleCloseDialog }, {
|
||
default: withCtx(() => [..._cache[16] || (_cache[16] = [
|
||
createTextVNode("取消", -1)
|
||
])]),
|
||
_: 1
|
||
}),
|
||
withDirectives((openBlock(), createBlock(_component_el_button, {
|
||
type: "primary",
|
||
disabled: !hasChanges.value,
|
||
onClick: submitChanges
|
||
}, {
|
||
default: withCtx(() => [..._cache[17] || (_cache[17] = [
|
||
createTextVNode(" 保存 ", -1)
|
||
])]),
|
||
_: 1
|
||
}, 8, ["disabled"])), [
|
||
[_directive_hasPerm, ["module_system:config:update"]]
|
||
])
|
||
]),
|
||
default: withCtx(() => [
|
||
createVNode(_component_el_tabs, {
|
||
modelValue: activeTabRef.value,
|
||
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => activeTabRef.value = $event),
|
||
type: "border-card"
|
||
}, {
|
||
default: withCtx(() => [
|
||
createVNode(_component_el_tab_pane, {
|
||
label: "网站配置",
|
||
name: "website"
|
||
}, {
|
||
default: withCtx(() => [
|
||
createVNode(_component_el_form, {
|
||
model: configState,
|
||
"label-suffix": ":",
|
||
"label-width": "auto",
|
||
"label-position": "right"
|
||
}, {
|
||
default: withCtx(() => [
|
||
createVNode(_component_el_divider, null, {
|
||
default: withCtx(() => [..._cache[2] || (_cache[2] = [
|
||
createTextVNode("网站配置", -1)
|
||
])]),
|
||
_: 1
|
||
}),
|
||
(openBlock(true), createElementBlock(Fragment, null, renderList(systemConfigs.value, (item, key) => {
|
||
return openBlock(), createElementBlock("div", { key }, [
|
||
createVNode(_component_el_form_item, {
|
||
label: item.config_name
|
||
}, {
|
||
default: withCtx(() => [
|
||
createBaseVNode("span", _hoisted_1, [
|
||
createVNode(_component_el_input, {
|
||
modelValue: item.config_value,
|
||
"onUpdate:modelValue": ($event) => item.config_value = $event,
|
||
placeholder: unref(t)("common.inputText"),
|
||
clearable: "",
|
||
style: { "width": "100%" },
|
||
onInput: ($event) => markModified(key)
|
||
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder", "onInput"])
|
||
])
|
||
]),
|
||
_: 2
|
||
}, 1032, ["label"])
|
||
]);
|
||
}), 128)),
|
||
createVNode(_component_el_divider, null, {
|
||
default: withCtx(() => [..._cache[3] || (_cache[3] = [
|
||
createTextVNode("网站图标", -1)
|
||
])]),
|
||
_: 1
|
||
}),
|
||
(openBlock(true), createElementBlock(Fragment, null, renderList(logoConfigs.value, (item, key) => {
|
||
return openBlock(), createElementBlock("div", { key }, [
|
||
createVNode(_component_el_form_item, {
|
||
label: item.config_name
|
||
}, {
|
||
default: withCtx(() => [
|
||
createBaseVNode("div", _hoisted_2, [
|
||
createVNode(SingleImageUpload, {
|
||
modelValue: item.config_value,
|
||
"onUpdate:modelValue": ($event) => item.config_value = $event,
|
||
data: { type: key },
|
||
name: "file",
|
||
"max-file-size": item.maxFileSize,
|
||
"show-tip": true,
|
||
"enable-preview": true,
|
||
onSuccess: (fileInfo) => handleUploadSuccess(fileInfo, key),
|
||
onError: handleUploadError
|
||
}, null, 8, ["modelValue", "onUpdate:modelValue", "data", "max-file-size", "onSuccess"])
|
||
])
|
||
]),
|
||
_: 2
|
||
}, 1032, ["label"])
|
||
]);
|
||
}), 128))
|
||
]),
|
||
_: 1
|
||
}, 8, ["model"])
|
||
]),
|
||
_: 1
|
||
}),
|
||
createVNode(_component_el_tab_pane, {
|
||
label: "安全隐私",
|
||
name: "securityPrivacy"
|
||
}, {
|
||
default: withCtx(() => [
|
||
createVNode(_component_el_form, {
|
||
model: configState,
|
||
"label-suffix": ":",
|
||
"label-width": "auto",
|
||
"label-position": "right"
|
||
}, {
|
||
default: withCtx(() => [
|
||
createVNode(_component_el_divider, null, {
|
||
default: withCtx(() => [..._cache[4] || (_cache[4] = [
|
||
createTextVNode("安全隐私", -1)
|
||
])]),
|
||
_: 1
|
||
}),
|
||
(openBlock(true), createElementBlock(Fragment, null, renderList(securityPrivacyConfigs.value, (item, key) => {
|
||
return openBlock(), createElementBlock("div", { key }, [
|
||
createVNode(_component_el_form_item, {
|
||
label: item.config_name
|
||
}, {
|
||
default: withCtx(() => [
|
||
createBaseVNode("span", _hoisted_3, [
|
||
createVNode(_component_el_input, {
|
||
modelValue: item.config_value,
|
||
"onUpdate:modelValue": ($event) => item.config_value = $event,
|
||
placeholder: unref(t)("common.inputText"),
|
||
clearable: "",
|
||
style: { "width": "100%" },
|
||
onInput: ($event) => markModified(key)
|
||
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder", "onInput"])
|
||
])
|
||
]),
|
||
_: 2
|
||
}, 1032, ["label"])
|
||
]);
|
||
}), 128))
|
||
]),
|
||
_: 1
|
||
}, 8, ["model"])
|
||
]),
|
||
_: 1
|
||
}),
|
||
createVNode(_component_el_tab_pane, {
|
||
label: "用户协议",
|
||
name: "userAgreement"
|
||
}, {
|
||
default: withCtx(() => [
|
||
createVNode(_component_el_form, {
|
||
model: configState,
|
||
"label-suffix": ":",
|
||
"label-width": "auto",
|
||
"label-position": "right"
|
||
}, {
|
||
default: withCtx(() => [
|
||
createVNode(_component_el_divider, null, {
|
||
default: withCtx(() => [..._cache[5] || (_cache[5] = [
|
||
createTextVNode("用户协议", -1)
|
||
])]),
|
||
_: 1
|
||
}),
|
||
(openBlock(true), createElementBlock(Fragment, null, renderList(userAgreementConfigs.value, (item, key) => {
|
||
return openBlock(), createElementBlock("div", { key }, [
|
||
createVNode(_component_el_form_item, {
|
||
label: item.config_name
|
||
}, {
|
||
default: withCtx(() => [
|
||
createBaseVNode("span", _hoisted_4, [
|
||
createVNode(_component_el_input, {
|
||
modelValue: item.config_value,
|
||
"onUpdate:modelValue": ($event) => item.config_value = $event,
|
||
placeholder: unref(t)("common.inputText"),
|
||
clearable: "",
|
||
style: { "width": "100%" },
|
||
onInput: ($event) => markModified(key)
|
||
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder", "onInput"])
|
||
])
|
||
]),
|
||
_: 2
|
||
}, 1032, ["label"])
|
||
]);
|
||
}), 128))
|
||
]),
|
||
_: 1
|
||
}, 8, ["model"])
|
||
]),
|
||
_: 1
|
||
}),
|
||
createVNode(_component_el_tab_pane, {
|
||
label: "接口白名单",
|
||
name: "apiWhitelist"
|
||
}, {
|
||
default: withCtx(() => [
|
||
createVNode(_component_el_form, {
|
||
model: configState,
|
||
"label-suffix": ":",
|
||
"label-width": "auto",
|
||
"label-position": "right"
|
||
}, {
|
||
default: withCtx(() => [
|
||
createVNode(_component_el_divider, null, {
|
||
default: withCtx(() => [..._cache[6] || (_cache[6] = [
|
||
createTextVNode("接口白名单", -1)
|
||
])]),
|
||
_: 1
|
||
}),
|
||
(openBlock(true), createElementBlock(Fragment, null, renderList(apiWhitelistConfigs.value, (item, key) => {
|
||
return openBlock(), createElementBlock("div", { key }, [
|
||
createVNode(_component_el_form_item, {
|
||
label: item.config_name
|
||
}, {
|
||
default: withCtx(() => [
|
||
createBaseVNode("div", _hoisted_5, [
|
||
(openBlock(true), createElementBlock(Fragment, null, renderList(apiWhitelistItems.value, (listItem) => {
|
||
return openBlock(), createElementBlock("div", {
|
||
key: listItem.id,
|
||
class: "flex items-center gap-2"
|
||
}, [
|
||
createVNode(_component_el_input, {
|
||
modelValue: listItem.value,
|
||
"onUpdate:modelValue": ($event) => listItem.value = $event,
|
||
placeholder: "/api/v1/users/get",
|
||
clearable: "",
|
||
onInput: ($event) => markModified(key),
|
||
onBlur: ($event) => {
|
||
{
|
||
if (!isValidApiPath(listItem.value) && listItem.value.trim()) {
|
||
unref(ElMessage).warning("请输入有效的接口路径格式(以/开头)");
|
||
}
|
||
}
|
||
}
|
||
}, null, 8, ["modelValue", "onUpdate:modelValue", "onInput", "onBlur"]),
|
||
createVNode(_component_el_button, {
|
||
type: "danger",
|
||
icon: "minus",
|
||
circle: "",
|
||
size: "small",
|
||
onClick: ($event) => removeApiWhitelistItem(listItem.id)
|
||
}, null, 8, ["onClick"])
|
||
]);
|
||
}), 128)),
|
||
createVNode(_component_el_button, {
|
||
type: "primary",
|
||
icon: "plus",
|
||
size: "small",
|
||
style: { "margin-top": "10px" },
|
||
onClick: addApiWhitelistItem
|
||
}, {
|
||
default: withCtx(() => [..._cache[7] || (_cache[7] = [
|
||
createTextVNode(" 添加接口路径 ", -1)
|
||
])]),
|
||
_: 1
|
||
}),
|
||
_cache[8] || (_cache[8] = createBaseVNode("div", { class: "text-xs text-gray-500 mt-2" }, " 配置说明:添加到白名单的接口路径无需登录即可访问,支持完整路径配置。 ", -1))
|
||
])
|
||
]),
|
||
_: 2
|
||
}, 1032, ["label"])
|
||
]);
|
||
}), 128))
|
||
]),
|
||
_: 1
|
||
}, 8, ["model"])
|
||
]),
|
||
_: 1
|
||
}),
|
||
createVNode(_component_el_tab_pane, {
|
||
label: "IP黑名单",
|
||
name: "ipBlacklist"
|
||
}, {
|
||
default: withCtx(() => [
|
||
createVNode(_component_el_form, {
|
||
model: configState,
|
||
"label-suffix": ":",
|
||
"label-width": "auto",
|
||
"label-position": "right"
|
||
}, {
|
||
default: withCtx(() => [
|
||
createVNode(_component_el_divider, null, {
|
||
default: withCtx(() => [..._cache[9] || (_cache[9] = [
|
||
createTextVNode("IP黑名单", -1)
|
||
])]),
|
||
_: 1
|
||
}),
|
||
(openBlock(true), createElementBlock(Fragment, null, renderList(ipBlacklistConfigs.value, (item, key) => {
|
||
return openBlock(), createElementBlock("div", { key }, [
|
||
createVNode(_component_el_form_item, {
|
||
label: item.config_name
|
||
}, {
|
||
default: withCtx(() => [
|
||
createBaseVNode("div", _hoisted_6, [
|
||
(openBlock(true), createElementBlock(Fragment, null, renderList(ipBlacklistItems.value, (listItem) => {
|
||
return openBlock(), createElementBlock("div", {
|
||
key: listItem.id,
|
||
class: "flex items-center gap-2"
|
||
}, [
|
||
createVNode(_component_el_input, {
|
||
modelValue: listItem.value,
|
||
"onUpdate:modelValue": ($event) => listItem.value = $event,
|
||
placeholder: "192.168.1.1",
|
||
clearable: "",
|
||
style: { "flex": "1" },
|
||
onInput: ($event) => markModified(key),
|
||
onBlur: ($event) => {
|
||
{
|
||
if (!isValidIp(listItem.value) && listItem.value.trim()) {
|
||
unref(ElMessage).warning("请输入有效的IP地址格式");
|
||
}
|
||
}
|
||
}
|
||
}, null, 8, ["modelValue", "onUpdate:modelValue", "onInput", "onBlur"]),
|
||
createVNode(_component_el_button, {
|
||
type: "danger",
|
||
icon: "minus",
|
||
circle: "",
|
||
size: "small",
|
||
onClick: ($event) => removeIpBlacklistItem(listItem.id)
|
||
}, null, 8, ["onClick"])
|
||
]);
|
||
}), 128)),
|
||
createVNode(_component_el_button, {
|
||
type: "primary",
|
||
icon: "plus",
|
||
size: "small",
|
||
style: { "margin-top": "10px" },
|
||
onClick: addIpBlacklistItem
|
||
}, {
|
||
default: withCtx(() => [..._cache[10] || (_cache[10] = [
|
||
createTextVNode(" 添加IP地址 ", -1)
|
||
])]),
|
||
_: 1
|
||
}),
|
||
_cache[11] || (_cache[11] = createBaseVNode("div", { class: "text-xs text-gray-500 mt-2" }, " 配置说明:添加到黑名单的IP地址将无法访问系统,支持单个IP配置。 ", -1))
|
||
])
|
||
]),
|
||
_: 2
|
||
}, 1032, ["label"])
|
||
]);
|
||
}), 128))
|
||
]),
|
||
_: 1
|
||
}, 8, ["model"])
|
||
]),
|
||
_: 1
|
||
}),
|
||
createVNode(_component_el_tab_pane, {
|
||
label: "演示环境配置",
|
||
name: "demo"
|
||
}, {
|
||
default: withCtx(() => [
|
||
createVNode(_component_el_form, {
|
||
model: configState,
|
||
"label-suffix": ":",
|
||
"label-width": "auto",
|
||
"label-position": "right"
|
||
}, {
|
||
default: withCtx(() => [
|
||
createVNode(_component_el_divider, null, {
|
||
default: withCtx(() => [..._cache[12] || (_cache[12] = [
|
||
createTextVNode("演示环境配置", -1)
|
||
])]),
|
||
_: 1
|
||
}),
|
||
(openBlock(true), createElementBlock(Fragment, null, renderList(demoConfigs.value, (item, key) => {
|
||
return openBlock(), createElementBlock("div", { key }, [
|
||
createVNode(_component_el_form_item, {
|
||
label: item.config_name
|
||
}, {
|
||
default: withCtx(() => [
|
||
key === "demo_enable" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
||
createVNode(_component_el_switch, {
|
||
"inline-prompt": "",
|
||
"active-text": "启用",
|
||
"inactive-text": "禁用",
|
||
"model-value": item.config_value === "true",
|
||
"onUpdate:modelValue": (value) => {
|
||
item.config_value = value ? "true" : "false";
|
||
markModified(key);
|
||
}
|
||
}, null, 8, ["model-value", "onUpdate:modelValue"]),
|
||
_cache[13] || (_cache[13] = createBaseVNode("div", { class: "text-xs text-gray-500 mt-1" }, " 配置说明:启用后系统将进入演示模式,部分功能可能受限。 ", -1))
|
||
], 64)) : key === "ip_white_list" ? (openBlock(), createElementBlock("div", _hoisted_7, [
|
||
(openBlock(true), createElementBlock(Fragment, null, renderList(demoIpWhitelistItems.value, (listItem) => {
|
||
return openBlock(), createElementBlock("div", {
|
||
key: listItem.id,
|
||
class: "flex items-center gap-2"
|
||
}, [
|
||
createVNode(_component_el_input, {
|
||
modelValue: listItem.value,
|
||
"onUpdate:modelValue": ($event) => listItem.value = $event,
|
||
placeholder: "192.168.1.1",
|
||
clearable: "",
|
||
style: { "flex": "1" },
|
||
onInput: ($event) => markModified(key),
|
||
onBlur: ($event) => {
|
||
{
|
||
if (!isValidIp(listItem.value) && listItem.value.trim()) {
|
||
unref(ElMessage).warning("请输入有效的IP地址格式");
|
||
}
|
||
}
|
||
}
|
||
}, null, 8, ["modelValue", "onUpdate:modelValue", "onInput", "onBlur"]),
|
||
createVNode(_component_el_button, {
|
||
type: "danger",
|
||
icon: "minus",
|
||
circle: "",
|
||
size: "small",
|
||
onClick: ($event) => removeDemoIpWhitelistItem(listItem.id)
|
||
}, null, 8, ["onClick"])
|
||
]);
|
||
}), 128)),
|
||
createVNode(_component_el_button, {
|
||
type: "primary",
|
||
icon: "plus",
|
||
size: "small",
|
||
style: { "margin-top": "10px" },
|
||
onClick: addDemoIpWhitelistItem
|
||
}, {
|
||
default: withCtx(() => [..._cache[14] || (_cache[14] = [
|
||
createTextVNode(" 添加IP地址 ", -1)
|
||
])]),
|
||
_: 1
|
||
}),
|
||
_cache[15] || (_cache[15] = createBaseVNode("div", { class: "text-xs text-gray-500 mt-2" }, " 配置说明:演示模式下,只有白名单中的IP地址可以访问系统,支持单个IP配置。 ", -1))
|
||
])) : (openBlock(), createBlock(_component_el_input, {
|
||
key: 2,
|
||
modelValue: item.config_value,
|
||
"onUpdate:modelValue": ($event) => item.config_value = $event,
|
||
placeholder: unref(t)("common.inputText"),
|
||
clearable: "",
|
||
style: { "width": "100%" },
|
||
onInput: ($event) => markModified(key)
|
||
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder", "onInput"]))
|
||
]),
|
||
_: 2
|
||
}, 1032, ["label"])
|
||
]);
|
||
}), 128))
|
||
]),
|
||
_: 1
|
||
}, 8, ["model"])
|
||
]),
|
||
_: 1
|
||
})
|
||
]),
|
||
_: 1
|
||
}, 8, ["modelValue"])
|
||
]),
|
||
_: 1
|
||
}, 8, ["modelValue", "size"]);
|
||
};
|
||
}
|
||
});
|
||
const ConfigInfoDrawer = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-2de5db6a"]]);
|
||
export {
|
||
ConfigInfoDrawer as default
|
||
};
|