From 03760c754cc37ab08a57b98510375eea901ea5da Mon Sep 17 00:00:00 2001 From: Lazy <2211717435@qq.com> Date: Sat, 28 Oct 2023 10:52:28 +0800 Subject: [PATCH] Feat: get instance config list --- frontend/components.d.ts | 4 + frontend/src/hooks/useInstance.ts | 202 +++++++++++++++++- frontend/src/services/apis/instance.ts | 20 ++ frontend/src/widgets/instance/ManagerBtns.vue | 2 +- .../widgets/instance/ServerConfigOverview.vue | 126 ++++++++++- 5 files changed, 348 insertions(+), 6 deletions(-) diff --git a/frontend/components.d.ts b/frontend/components.d.ts index d336e655..00d27b71 100644 --- a/frontend/components.d.ts +++ b/frontend/components.d.ts @@ -7,6 +7,7 @@ export {} declare module 'vue' { export interface GlobalComponents { + AAvatar: typeof import('ant-design-vue/es')['Avatar'] ABreadcrumb: typeof import('ant-design-vue/es')['Breadcrumb'] ABreadcrumbItem: typeof import('ant-design-vue/es')['BreadcrumbItem'] AButton: typeof import('ant-design-vue/es')['Button'] @@ -23,6 +24,9 @@ declare module 'vue' { AInput: typeof import('ant-design-vue/es')['Input'] AInputGroup: typeof import('ant-design-vue/es')['InputGroup'] AInputPassword: typeof import('ant-design-vue/es')['InputPassword'] + AList: typeof import('ant-design-vue/es')['List'] + AListItem: typeof import('ant-design-vue/es')['ListItem'] + AListItemMeta: typeof import('ant-design-vue/es')['ListItemMeta'] AMenu: typeof import('ant-design-vue/es')['Menu'] AMenuDivider: typeof import('ant-design-vue/es')['MenuDivider'] AMenuItem: typeof import('ant-design-vue/es')['MenuItem'] diff --git a/frontend/src/hooks/useInstance.ts b/frontend/src/hooks/useInstance.ts index 5376dafd..0a216f2a 100644 --- a/frontend/src/hooks/useInstance.ts +++ b/frontend/src/hooks/useInstance.ts @@ -92,7 +92,9 @@ export function useInstanceInfo(params: Params) { const isRunning = computed(() => finalState?.value?.status === 3); const isStopped = computed(() => finalState?.value?.status === 0); const instanceTypeText = computed(() => { - return INSTANCE_TYPE_TRANSLATION[String(finalState?.value?.config.type)] || t("TXT_CODE_da7a0328"); + return ( + INSTANCE_TYPE_TRANSLATION[String(finalState?.value?.config.type)] || t("TXT_CODE_da7a0328") + ); }); const statusText = computed( () => String(INSTANCE_STATUS_TEXT[String(finalState?.value?.status)]) || t("TXT_CODE_c8333afa") @@ -136,3 +138,201 @@ export function useInstanceInfo(params: Params) { instanceTypeText }; } + +export interface InstanceConfigs { + fileName: string; + path: string; + redirect: string; + type: string; + info: string; + author: string; + github: string; + category: string[]; + conflict?: boolean; + check?: boolean; +} + +export function getInstanceConfigByType(type: string) { + let result: InstanceConfigs[] = []; + INSTANCE_CONFIGS.forEach((v) => { + if (v.category.includes(type)) result.push(v); + }); + // 返回副本以避免干扰原始数据 + return JSON.parse(JSON.stringify(result)); +} + +export const INSTANCE_CONFIGS = [ + { + // 配置文件显示名 + fileName: "[通用] server.properties", + // 配置文件对应的实际路径(相对于实例根目录) + path: "server.properties", + // 配置文件用于显示界面的组件名(参考 ProcessConfigFile.vue 的 components 属性) + redirect: "common/server.properties", + // 配置文件解析类型,支持 yml,json,txt,properties + type: "properties", + // 配置文件中文解释 + info: `Minecraft 服务端极其重要的配置文件,几乎绝大部分常用配置(端口,人数,视距等)均在此文件中进行编辑`, + // 配置文件适配模块作者名 + author: "Unitwk", + // 配置文件 Github 地址(只能放置 Github 地址) + github: "https://github.com/Unitwk", + // 在哪些服务端类型下此配置文件可见 + category: [ + TYPE_MINECRAFT_SPIGOT, + TYPE_MINECRAFT_PAPER, + TYPE_MINECRAFT_JAVA, + TYPE_MINECRAFT_BUKKIT, + TYPE_MINECRAFT_FORGE, + TYPE_MINECRAFT_FABRIC, + TYPE_MINECRAFT_SPONGE + ] + }, + { + fileName: "[通用] eula.txt", + type: "properties", + info: "软件最终用户协议,此协议必须设置同意,否则无法启用服务端软件", + path: "eula.txt", + redirect: "common/eula.txt", + author: "Lazy", + github: "https://github.com/LazyCreeper/", + category: [ + TYPE_MINECRAFT_SPIGOT, + TYPE_MINECRAFT_PAPER, + TYPE_MINECRAFT_JAVA, + TYPE_MINECRAFT_BUKKIT, + TYPE_MINECRAFT_FABRIC, + TYPE_MINECRAFT_SPONGE + ] + }, + { + fileName: "[Spigot] spigot.yml", + path: "spigot.yml", + redirect: "bukkit/spigot.yml", + type: "yml", + info: "Spigot 配置文件,能够进一步的控制服务器的行为和具体参数,一些更为高级的限制都在此配置文件中", + author: "Unitwk", + github: "https://github.com/Unitwk", + category: [ + TYPE_MINECRAFT_SPIGOT, + TYPE_MINECRAFT_PAPER, + TYPE_MINECRAFT_JAVA, + TYPE_MINECRAFT_BUKKIT + ] + }, + { + fileName: "[Bukkit] bukkit.yml", + path: "bukkit.yml", + redirect: "bukkit/bukkit.yml", + type: "yml", + info: "Bukkit 原始配置文件", + author: "AlexanderMC8533 & Lazy", + github: "https://github.com/AlexanderMC8533/", + category: [ + TYPE_MINECRAFT_SPIGOT, + TYPE_MINECRAFT_PAPER, + TYPE_MINECRAFT_JAVA, + TYPE_MINECRAFT_BUKKIT + ] + }, + { + fileName: "[Bungeecord] config.yml", + type: "yml", + info: "Bungeecord 群组服务端的重要配置文件,可以进行分布式管理,节点控制等,但此配置文件较为复杂,此处仅供简单的配置和操作", + path: "config.yml", + redirect: "bungeecord/config.yml", + author: "Lazy", + github: "https://github.com/LazyCreeper/", + category: [TYPE_MINECRAFT_JAVA, TYPE_MINECRAFT_BUNGEECORD] + }, + { + fileName: "[Velocity] velocity.toml", + type: "toml", + info: "Velocity 群组服务端的重要配置文件,可以进行分布式管理,节点控制等,但此配置文件较为复杂,此处仅供简单的配置和操作", + path: "velocity.toml", + redirect: "velocity/velocity.toml", + author: "WhitePaper233", + github: "https://github.com/WhitePaper233/", + category: [TYPE_MINECRAFT_JAVA, TYPE_MINECRAFT_VELOCITY] + }, + { + fileName: "[Bedrock] server.properties", + path: "server.properties", + redirect: "bds/server.properties", + type: "properties", + info: `Minecraft Bedrock 服务端极其重要的配置文件,几乎绝大部分常用配置(端口,人数,视距等)均在此文件中进行编辑`, + author: "Lazy", + github: "https://github.com/LazyCreeper", + category: [TYPE_MINECRAFT_BDS, TYPE_MINECRAFT_BEDROCK] + }, + { + fileName: "[Mohist] mohist.yml", + path: "mohist.yml", + redirect: "mohist/mohist.yml", + type: "yml", + info: "mohist.yml 服务端配置文件", + author: "Unitwk", + github: "https://github.com/LazyCreeper", + category: [TYPE_MINECRAFT_JAVA, TYPE_MINECRAFT_MOHIST] + }, + { + fileName: "[Paper] paper.yml", + type: "yml", + info: "PaperSpigot 服务端软件配置文件,能够进一步的配置高级参数以及更具体化的游戏设置,对整体性能有极大的决定效果", + path: "paper.yml", + redirect: "paper/paper.yml", + author: "Lazy", + github: "https://github.com/LazyCreeper", + category: [TYPE_MINECRAFT_JAVA, TYPE_MINECRAFT_PAPER] + }, + { + fileName: "[Paper] paper-global.yml", + type: "yml", + info: "PaperSpigot 服务端软件全局配置文件,能够进一步的配置高级参数以及更具体化的游戏设置,对整体性能有极大的决定效果", + path: "config/paper-global.yml", + redirect: "paper/paper-global.yml", + author: "Lazy", + github: "https://github.com/LazyCreeper", + category: [TYPE_MINECRAFT_JAVA, TYPE_MINECRAFT_PAPER] + }, + { + fileName: "[Paper] paper-world-defaults.yml", + type: "yml", + info: "PaperSpigot 服务端软件世界配置文件,能够进一步在每个世界的基础上进行配置", + path: "config/paper-world-defaults.yml", + redirect: "paper/paper-world-defaults.yml", + author: "Lazy", + github: "https://github.com/LazyCreeper", + category: [TYPE_MINECRAFT_JAVA, TYPE_MINECRAFT_PAPER] + }, + { + fileName: "[Geyser] config.yml", + type: "yml", + info: "Geyser 服务端软件配置文件,拥有基本的服务器参数设定(如端口,最大玩家数等)并且也可以设定服务端细节参数(区块缓存,线程数等)", + path: "config.yml", + redirect: "geyser/config.yml", + author: "Lazy", + github: "https://github.com/LazyCreeper", + category: [TYPE_MINECRAFT_JAVA, TYPE_MINECRAFT_GEYSER] + }, + { + fileName: "[MCDR] config.yml", + type: "yml", + info: "MCDReforged 服务端控制工具配置文件", + path: "config.yml", + redirect: "mcdr/config.yml", + author: "Huaji_MUR233", + github: "https://github.com/HuajiMUR233", + category: [TYPE_MINECRAFT_JAVA, TYPE_MINECRAFT_MCDR] + }, + { + fileName: "[MCDR] permission.yml", + type: "yml", + info: "MCDReforged 服务端控制工具权限配置文件", + path: "permission.yml", + redirect: "mcdr/permission.yml", + author: "Huaji_MUR233", + github: "https://github.com/HuajiMUR233", + category: [TYPE_MINECRAFT_JAVA, TYPE_MINECRAFT_MCDR] + } +]; diff --git a/frontend/src/services/apis/instance.ts b/frontend/src/services/apis/instance.ts index d25e89b4..0df757b3 100644 --- a/frontend/src/services/apis/instance.ts +++ b/frontend/src/services/apis/instance.ts @@ -230,3 +230,23 @@ export const queryAsyncTask = useDefineApi< url: "/api/protected_instance/query_asynchronous", method: "POST" }); + +// 获取配置文件列表 +export const getConfigFileList = useDefineApi< + { + params: { + uuid: string; + remote_uuid: string; + }; + data: { + files: string[]; + }; + }, + { + check: boolean; + file: string; + }[] +>({ + method: "POST", + url: "/api/protected_instance/process_config/list" +}); diff --git a/frontend/src/widgets/instance/ManagerBtns.vue b/frontend/src/widgets/instance/ManagerBtns.vue index ffe3b5c1..1f8e6d1b 100644 --- a/frontend/src/widgets/instance/ManagerBtns.vue +++ b/frontend/src/widgets/instance/ManagerBtns.vue @@ -52,7 +52,7 @@ const btns = arrayFilter([ toPage({ path: "/instances/terminal/serverConfig", query: { - type: "Minecraft" + type: instanceInfo.value?.config.type } }); } diff --git a/frontend/src/widgets/instance/ServerConfigOverview.vue b/frontend/src/widgets/instance/ServerConfigOverview.vue index 4fb80745..e4031a56 100644 --- a/frontend/src/widgets/instance/ServerConfigOverview.vue +++ b/frontend/src/widgets/instance/ServerConfigOverview.vue @@ -1,16 +1,134 @@