mirror of
https://github.com/MCSManager/MCSManager.git
synced 2024-11-27 06:59:54 +08:00
Feat: get instance config list
This commit is contained in:
parent
a7f87f59c4
commit
03760c754c
4
frontend/components.d.ts
vendored
4
frontend/components.d.ts
vendored
@ -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']
|
||||
|
@ -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]
|
||||
}
|
||||
];
|
||||
|
@ -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"
|
||||
});
|
||||
|
@ -52,7 +52,7 @@ const btns = arrayFilter([
|
||||
toPage({
|
||||
path: "/instances/terminal/serverConfig",
|
||||
query: {
|
||||
type: "Minecraft"
|
||||
type: instanceInfo.value?.config.type
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,16 +1,134 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from "vue";
|
||||
import { t } from "@/lang/i18n";
|
||||
import CardPanel from "@/components/CardPanel.vue";
|
||||
import type { LayoutCard } from "@/types";
|
||||
import { getConfigFileList } from "@/services/apis/instance";
|
||||
import { message } from "ant-design-vue";
|
||||
import { useLayoutCardTools } from "@/hooks/useCardTools";
|
||||
import { getInstanceConfigByType, type InstanceConfigs } from "@/hooks/useInstance";
|
||||
import { useAppRouters } from "@/hooks/useAppRouters";
|
||||
|
||||
const props = defineProps<{
|
||||
card: LayoutCard;
|
||||
}>();
|
||||
const { getMetaOrRouteValue } = useLayoutCardTools(props.card);
|
||||
const instanceId = getMetaOrRouteValue("instanceId");
|
||||
const daemonId = getMetaOrRouteValue("daemonId");
|
||||
const type = getMetaOrRouteValue("type");
|
||||
|
||||
const { toPage } = useAppRouters();
|
||||
const toConsole = () => {
|
||||
toPage({
|
||||
path: "/instances/terminal",
|
||||
query: {
|
||||
daemonId,
|
||||
instanceId
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const InstanceConfigsList = ref<InstanceConfigs[]>([]);
|
||||
|
||||
const { execute, state: realFiles, isLoading } = getConfigFileList();
|
||||
const render = async () => {
|
||||
try {
|
||||
const configFiles: InstanceConfigs[] = getInstanceConfigByType(type ?? "");
|
||||
const files: string[] = [];
|
||||
configFiles.forEach((v: InstanceConfigs) => {
|
||||
files.push(v.path);
|
||||
});
|
||||
await execute({
|
||||
params: {
|
||||
uuid: instanceId ?? "",
|
||||
remote_uuid: daemonId ?? ""
|
||||
},
|
||||
data: {
|
||||
files: files
|
||||
}
|
||||
});
|
||||
if (!realFiles.value) return message.error(t("获取配置文件列表失败"));
|
||||
realFiles.value.forEach((v) => {
|
||||
configFiles.forEach((z) => {
|
||||
if (z.path === v.file) {
|
||||
configFiles.forEach((p) => {
|
||||
if (p.path == z.path && p.check) z.conflict = true;
|
||||
});
|
||||
z.check = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
InstanceConfigsList.value = configFiles;
|
||||
} catch (err: any) {
|
||||
console.error(err);
|
||||
return message.error(err.message);
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
await render();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<CardPanel class="ServerConfigOverview" style="height: 100%">
|
||||
<template #title>{{ card.title }}</template>
|
||||
<template #body> ServerConfigOverview </template>
|
||||
</CardPanel>
|
||||
<div style="height: 100%" class="container">
|
||||
<a-row :gutter="[24, 24]" style="height: 100%">
|
||||
<a-col :span="24">
|
||||
<BetweenMenus>
|
||||
<template #left>
|
||||
<a-typography-title class="mb-0" :level="4">
|
||||
{{ card.title }}
|
||||
</a-typography-title>
|
||||
</template>
|
||||
<template #right>
|
||||
<a-button class="mr-8" :loading="isLoading" @click="render">
|
||||
{{ t("刷新") }}
|
||||
</a-button>
|
||||
<a-button @click="toConsole">
|
||||
{{ t("回到控制台") }}
|
||||
</a-button>
|
||||
</template>
|
||||
</BetweenMenus>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="24">
|
||||
<a-typography-paragraph>
|
||||
<a-typography-text>
|
||||
{{
|
||||
t(
|
||||
"配置文件适配工作由开发团队与开源社区开发者共同开发。如果没有看见您需要的配置文件,请前往实例配置界面手动选择服务端/或衍生类服务端类型。"
|
||||
)
|
||||
}}
|
||||
</a-typography-text>
|
||||
</a-typography-paragraph>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="24">
|
||||
<CardPanel style="height: 100%">
|
||||
<template #body>
|
||||
<a-list
|
||||
item-layout="horizontal"
|
||||
:data-source="InstanceConfigsList"
|
||||
:loading="isLoading"
|
||||
>
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item v-if="item.check">
|
||||
<a-list-item-meta :description="item.info">
|
||||
<template #title>
|
||||
<a href="javascript:;">{{ item.fileName }}</a>
|
||||
</template>
|
||||
</a-list-item-meta>
|
||||
<template #actions>
|
||||
<a-button size="">{{ t("编辑") }}</a-button>
|
||||
</template>
|
||||
</a-list-item>
|
||||
</template>
|
||||
</a-list>
|
||||
</template>
|
||||
</CardPanel>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
|
Loading…
Reference in New Issue
Block a user