mirror of
https://github.com/MCSManager/MCSManager.git
synced 2025-01-30 15:19:32 +08:00
Merge branch 'main' of github.com:unitwk/MCSManager-v10-Dev
This commit is contained in:
commit
2760578f96
@ -24,6 +24,7 @@ const operationForm = ref({
|
||||
const ALL = "all";
|
||||
const currentStatus = ref<boolean | string>(ALL);
|
||||
const { state, refresh: refreshOverviewInfo } = useOverviewInfo();
|
||||
const refreshLoading = ref(false);
|
||||
|
||||
const remotes = computed(() => {
|
||||
const filterByName = (node: ComputedNodeInfo) =>
|
||||
@ -97,6 +98,18 @@ const editNode = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const refresh = async () => {
|
||||
try {
|
||||
refreshLoading.value = true;
|
||||
await refreshOverviewInfo(true);
|
||||
message.success(t("TXT_CODE_fbde647e"));
|
||||
} catch (error: any) {
|
||||
message.error(error.message);
|
||||
} finally {
|
||||
refreshLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const editMode = ref(false);
|
||||
const editDialog = ref({
|
||||
status: false,
|
||||
@ -166,6 +179,9 @@ const editDialog = ref({
|
||||
</a-typography-title>
|
||||
</template>
|
||||
<template #right>
|
||||
<a-button class="mr-12" :loading="refreshLoading" @click="refresh">
|
||||
{{ t("TXT_CODE_b76d94e0") }}
|
||||
</a-button>
|
||||
<a-button class="mr-12" type="primary" @click="editDialog.show">
|
||||
{{ t("TXT_CODE_15a381d5") }}
|
||||
</a-button>
|
||||
@ -176,7 +192,7 @@ const editDialog = ref({
|
||||
<template #center>
|
||||
<div class="search-input">
|
||||
<a-input-group compact>
|
||||
<a-select v-model:value="currentStatus" style="width: 100px">
|
||||
<a-select v-model:value="currentStatus" style="width: 80px">
|
||||
<a-select-option value="all">
|
||||
{{ t("TXT_CODE_c48f6f64") }}
|
||||
</a-select-option>
|
||||
@ -190,7 +206,7 @@ const editDialog = ref({
|
||||
<a-input
|
||||
v-model:value.trim="operationForm.name"
|
||||
:placeholder="t('TXT_CODE_461d1a01')"
|
||||
style="width: 50%"
|
||||
style="width: calc(100% - 80px)"
|
||||
>
|
||||
<template #suffix>
|
||||
<search-outlined />
|
||||
@ -304,8 +320,6 @@ const editDialog = ref({
|
||||
|
||||
@media (max-width: 992px) {
|
||||
.search-input {
|
||||
transition: all 0.4s;
|
||||
text-align: center;
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import { t } from "@/lang/i18n";
|
||||
import { useOverviewInfo } from "@/hooks/useOverviewInfo";
|
||||
import type { LayoutCard } from "@/types";
|
||||
import { computed } from "vue";
|
||||
import { arrayFilter } from "@/tools/array";
|
||||
|
||||
defineProps<{
|
||||
card: LayoutCard;
|
||||
@ -25,7 +26,7 @@ const overviewList = computed(() => {
|
||||
const total = Number((system.totalmem / 1024 / 1024 / 1024).toFixed(1));
|
||||
const used = Number(total - free).toFixed(1);
|
||||
|
||||
return [
|
||||
return arrayFilter([
|
||||
{
|
||||
title: t("TXT_CODE_413b9c01"),
|
||||
value: system.node
|
||||
@ -64,7 +65,8 @@ const overviewList = computed(() => {
|
||||
},
|
||||
{
|
||||
title: t("TXT_CODE_190ecd56"),
|
||||
value: system.loadavg.map((v) => Number(v).toFixed(2)).join("-")
|
||||
value: system.loadavg.map((v) => Number(v).toFixed(2)).join("-"),
|
||||
condition: () => !system.type.toLowerCase().includes("windows")
|
||||
},
|
||||
{
|
||||
title: t("TXT_CODE_77d038f7"),
|
||||
@ -82,7 +84,7 @@ const overviewList = computed(() => {
|
||||
title: t("TXT_CODE_edf84830"),
|
||||
value: `${system.type} ${system.platform}`
|
||||
}
|
||||
];
|
||||
]);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@ -50,6 +50,13 @@ const permissionList = {
|
||||
|
||||
const columns = computed(() => {
|
||||
return arrayFilter([
|
||||
{
|
||||
align: "center",
|
||||
title: "UUID",
|
||||
dataIndex: "uuid",
|
||||
key: "uuid",
|
||||
condition: () => !screen.isPhone.value
|
||||
},
|
||||
{
|
||||
align: "center",
|
||||
title: t("TXT_CODE_eb9fcdad"),
|
||||
@ -391,7 +398,7 @@ onMounted(async () => {
|
||||
<a-input
|
||||
v-model:value.trim="operationForm.name"
|
||||
:placeholder="t('TXT_CODE_2471b9c')"
|
||||
style="width: 50%"
|
||||
style="width: calc(100% - 100px)"
|
||||
@change="reload()"
|
||||
>
|
||||
<template #suffix>
|
||||
@ -438,9 +445,14 @@ onMounted(async () => {
|
||||
<a-menu-item key="2" @click="handleToUserResources(record)">
|
||||
{{ t("TXT_CODE_4d934e3a") }}
|
||||
</a-menu-item>
|
||||
<a-menu-item key="3" @click="handleDeleteUser(record)">
|
||||
<a-popconfirm
|
||||
:title="t('你确定要删除这个用户吗?')"
|
||||
@confirm="handleDeleteUser(record)"
|
||||
>
|
||||
<a-menu-item key="3">
|
||||
{{ t("TXT_CODE_760f00f5") }}
|
||||
</a-menu-item>
|
||||
</a-popconfirm>
|
||||
</a-menu>
|
||||
</template>
|
||||
<a-button size="">
|
||||
|
@ -11,6 +11,7 @@ import { toUnicode } from "@/tools/common";
|
||||
import Loading from "@/components/Loading.vue";
|
||||
import configComponent from "@/components/InstanceConfigEditor.vue";
|
||||
import { DownOutlined } from "@ant-design/icons-vue";
|
||||
import FileEditor from "./dialogs/FileEditor.vue";
|
||||
|
||||
const props = defineProps<{
|
||||
card: LayoutCard;
|
||||
@ -92,6 +93,11 @@ const save = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const FileEditorDialog = ref<InstanceType<typeof FileEditor>>();
|
||||
const toEditRawFile = () => {
|
||||
FileEditorDialog.value?.openDialog(configPath ?? "", configName ?? "");
|
||||
};
|
||||
|
||||
const refresh = async () => {
|
||||
await render();
|
||||
message.success(t("TXT_CODE_7863f28d"));
|
||||
@ -119,16 +125,16 @@ onMounted(async () => {
|
||||
<a-button v-if="!isPhone" :loading="getConfigFileLoading" class="mr-8" @click="refresh">
|
||||
{{ t("TXT_CODE_d080f2d7") }}
|
||||
</a-button>
|
||||
<a-button v-if="!isPhone" type="dashed">
|
||||
<a-button v-if="!isPhone" type="dashed" @click="toEditRawFile">
|
||||
{{ t("TXT_CODE_1f61e5a3") }}
|
||||
</a-button>
|
||||
<a-dropdown v-if="isPhone">
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item key="2" @click="refresh">
|
||||
<a-menu-item key="1" @click="refresh">
|
||||
{{ t("TXT_CODE_d080f2d7") }}
|
||||
</a-menu-item>
|
||||
<a-menu-item key="3">
|
||||
<a-menu-item key="2" @click="toEditRawFile">
|
||||
{{ t("TXT_CODE_1f61e5a3") }}
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
@ -159,6 +165,13 @@ onMounted(async () => {
|
||||
</a-col>
|
||||
</a-row>
|
||||
</div>
|
||||
|
||||
<FileEditor
|
||||
v-if="daemonId && instanceId"
|
||||
ref="FileEditorDialog"
|
||||
:daemon-id="daemonId"
|
||||
:instance-id="instanceId"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
|
@ -7,7 +7,8 @@ import {
|
||||
SettingOutlined,
|
||||
CodeOutlined,
|
||||
BlockOutlined,
|
||||
FolderOpenOutlined
|
||||
FolderOpenOutlined,
|
||||
ReloadOutlined
|
||||
} from "@ant-design/icons-vue";
|
||||
import { useOverviewInfo, type ComputedNodeInfo } from "@/hooks/useOverviewInfo";
|
||||
import IconBtn from "@/components/IconBtn.vue";
|
||||
@ -19,6 +20,7 @@ import { useLayoutCardTools } from "@/hooks/useCardTools";
|
||||
import type { LayoutCard } from "@/types";
|
||||
import { arrayFilter } from "@/tools/array";
|
||||
import { GLOBAL_INSTANCE_UUID } from "@/config/const";
|
||||
import CopyButton from "@/components/CopyButton.vue";
|
||||
|
||||
const props = defineProps<{
|
||||
item?: ComputedNodeInfo;
|
||||
@ -45,8 +47,7 @@ if (props.card) {
|
||||
|
||||
const { toPage } = useAppRouters();
|
||||
|
||||
const detailList = (node: ComputedNodeInfo) => {
|
||||
return [
|
||||
const detailList = (node: ComputedNodeInfo) => [
|
||||
{
|
||||
title: t("TXT_CODE_f52079a0"),
|
||||
value: `${node.ip}:${node.port}`
|
||||
@ -74,10 +75,13 @@ const detailList = (node: ComputedNodeInfo) => {
|
||||
{
|
||||
title: t("TXT_CODE_81634069"),
|
||||
value: node.version
|
||||
},
|
||||
{
|
||||
title: "Daemon ID",
|
||||
value: node.uuid,
|
||||
onlyCopy: true
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
];
|
||||
const nodeOperations = computed(() =>
|
||||
arrayFilter([
|
||||
{
|
||||
@ -126,6 +130,14 @@ const nodeOperations = computed(() =>
|
||||
},
|
||||
condition: () => item.value!.available
|
||||
},
|
||||
{
|
||||
title: t("重新连接"),
|
||||
icon: ReloadOutlined,
|
||||
click: async (node: ComputedNodeInfo) => {
|
||||
await tryConnectNode(node.uuid);
|
||||
},
|
||||
condition: () => !item.value!.available
|
||||
},
|
||||
{
|
||||
title: t("TXT_CODE_b5c7b82d"),
|
||||
icon: SettingOutlined,
|
||||
@ -156,11 +168,24 @@ const deleteNode = async () => {
|
||||
editDialog.value.loading = false;
|
||||
};
|
||||
|
||||
const tryConnectNode = async (uuid: string, showMsg = true) => {
|
||||
const { execute } = connectNode();
|
||||
try {
|
||||
await execute({
|
||||
params: {
|
||||
uuid: uuid
|
||||
}
|
||||
});
|
||||
if (showMsg) message.success(t("操作成功"));
|
||||
} catch (error) {
|
||||
message.error(t("操作失败"));
|
||||
}
|
||||
};
|
||||
|
||||
const editNode = async () => {
|
||||
const { apiKey, ...outherData } = editDialog.value.data;
|
||||
const updatedData = apiKey == "" ? { ...outherData } : editDialog.value.data;
|
||||
const { execute } = editNodeApi();
|
||||
const { execute: tryConnectNode } = connectNode();
|
||||
try {
|
||||
await execute({
|
||||
params: {
|
||||
@ -170,11 +195,7 @@ const editNode = async () => {
|
||||
...updatedData
|
||||
}
|
||||
});
|
||||
await tryConnectNode({
|
||||
params: {
|
||||
uuid: editDialog.value.uuid
|
||||
}
|
||||
});
|
||||
await tryConnectNode(editDialog.value.uuid, false);
|
||||
message.success(t("TXT_CODE_a7907771"));
|
||||
editDialog.value.loading = false;
|
||||
editDialog.value.hidden();
|
||||
@ -265,7 +286,10 @@ const editDialog = ref({
|
||||
<div>
|
||||
{{ detail.title }}
|
||||
</div>
|
||||
<div>
|
||||
<div v-if="detail.onlyCopy">
|
||||
<CopyButton type="link" size="small" :value="detail.value ?? ''" />
|
||||
</div>
|
||||
<div v-else>
|
||||
{{ detail.value }}
|
||||
</div>
|
||||
</a-typography-paragraph>
|
||||
|
@ -13,7 +13,7 @@ import koaBody from "koa-body";
|
||||
import session from "koa-session";
|
||||
import koaStatic from "koa-static";
|
||||
import http from "http";
|
||||
// import open from "open";
|
||||
import open from "open";
|
||||
import { fileLogger, logger } from "./app/service/log";
|
||||
import { middleware as protocolMiddleware } from "./app/middleware/protocol";
|
||||
import { mountRouters } from "./app/index";
|
||||
|
Loading…
Reference in New Issue
Block a user