Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit 6118556

Browse files
committed
Merge branch 'main' of github.com:Suwings/MCSManager-UI into main
# Conflicts: # README.md
1 parent 7035449 commit 6118556

File tree

12 files changed

+513
-114
lines changed

12 files changed

+513
-114
lines changed

README.md

Lines changed: 18 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,29 @@
1-
```
2-
______ _______________________ ___
3-
___ |/ /_ ____/_ ___/__ |/ /_____ _____________ _______ _____________
4-
__ /|_/ /_ / _____ \__ /|_/ /_ __ /_ __ \ __ /_ __ / _ \_ ___/
5-
_ / / / / /___ ____/ /_ / / / / /_/ /_ / / / /_/ /_ /_/ // __/ /
6-
/_/ /_/ \____/ /____/ /_/ /_/ \__,_/ /_/ /_/\__,_/ _\__, / \___//_/
7-
/____/
8-
```
9-
10-
[![Status](https://img.shields.io/badge/npm-v6.9.0-blue.svg)](https://www.npmjs.com/)
11-
[![Status](https://img.shields.io/badge/node-v10.16.0-blue.svg)](https://nodejs.org/en/download/)
12-
[![Status](https://img.shields.io/badge/License-GPL-red.svg)](https://github.com/Suwings/MCSManager)
13-
14-
15-
适用于 MCSManager 未来版本的 Web 界面项目。
16-
17-
18-
[官方网站](http://mcsm.suwings.top/) | 当前正在开发中
19-
20-
<br />
21-
22-
相关项目
23-
-----------
24-
[MCSManager 守护进程项目](https://github.com/Suwings/MCSManager-Daemon)
25-
[MCSManager 前端项目](https://github.com/Suwings/MCSManager-UI)
26-
[MCSManager 8.X 版本主项目](https://github.com/Suwings/MCSManager)
27-
28-
<br />
1+
# project2104-ui
292

30-
MCSManager 简介
31-
-----------
32-
这是一款可以管理多个 Minecraft 服务端(支持群组端)的 Web 管理面板,并且可以分配多个子账号来分别管理不同的 Minecraft 服务端,支持绝大部分主流的服务端,甚至是其他非 Minecraft 的程序。
3+
## Project setup
334

34-
控制面板可运行在 Windows 与 Linux 平台,无需数据库与任何系统配置,只需安装 node 环境即可快速运行,属于轻量级的 Minecraft 服务端控制面板。
5+
```
6+
npm install
7+
```
358

9+
### Compiles and hot-reloads for development
3610

37-
预览新界面
38-
-----------
39-
```bash
40-
git clone https://github.com/Suwings/MCSManager-UI.git
41-
npm install
11+
```
4212
npm run serve
4313
```
4414

45-
部分界面可能无法查看,因为前端数据模型渲染需要 Web 端配合,Web 端的源代码还未放出,计划放在 MCSManager 主项目仓库中。
15+
### Compiles and minifies for production
4616

47-
<br />
17+
```
18+
npm run build
19+
```
20+
21+
### Lints and fixes files
4822

23+
```
24+
npm run lint
25+
```
4926

50-
开源协议
51-
-----------
52-
使用 GNU General Public License v3.0
27+
### Customize configuration
5328

54-
若您想基于本项目进行任何修改,你需要提供许可作品和修改的完整源代码,其中包括使用许可作品的较大作品。 必须保留版权和许可声明以及贡献者明确授予专利权。
29+
See [Configuration Reference](https://cli.vuejs.org/config/).

src/app/router.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @Author: Copyright(c) 2020 Suwings
33
* @Date: 2021-05-08 22:54:31
4-
* @LastEditTime: 2021-07-06 20:58:22
4+
* @LastEditTime: 2021-07-14 14:22:46
55
* @Description:
66
*/
77
import { createRouter, createWebHistory } from "vue-router";
@@ -21,6 +21,8 @@ import Setting from "./views/Setting";
2121
import Terminal from "./views/Terminal";
2222
import InstanceDetail from "./views/InstanceDetail";
2323
import NewInstance from "./views/NewInstance";
24+
import NewImage from "./views/NewImage";
25+
import FileManager from "./views/FileManager";
2426

2527
const routes = [
2628
{
@@ -73,11 +75,21 @@ const routes = [
7375
name: "设置",
7476
component: Setting
7577
},
78+
{
79+
path: "/new_image",
80+
name: "创建镜像",
81+
component: NewImage
82+
},
7683
{
7784
path: "/terminal/:serviceUuid/:instanceUuid",
7885
name: "终端",
7986
component: Terminal
8087
},
88+
{
89+
path: "/file/:serviceUuid/:instanceUuid",
90+
name: "文件管理",
91+
component: FileManager
92+
},
8193
{
8294
path: "/instance_detail/:serviceUuid/:instanceUuid",
8395
name: "实例详情",

src/app/service/common.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
/*
22
* @Author: Copyright(c) 2020 Suwings
33
* @Date: 2021-05-18 10:00:35
4-
* @LastEditTime: 2021-05-19 14:41:20
4+
* @LastEditTime: 2021-07-14 14:25:44
55
* @Description:
66
*/
77

88
export const API_URL = "http://127.0.0.1:23333";
99

1010
export const API_SERVICE = `${API_URL}/api/service/remote_services`;
11+
export const API_SERVICE_CURD = `${API_URL}/api/service/remote_service`;
12+
export const API_SERVICE_URL = `${API_URL}/api/service`;
13+
14+
export const API_FILE_URL = `${API_URL}/api/files`;
1115

1216
// export const API_FORWARD = `${API_URL}/api/service/remote_services`

src/app/service/protocol.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* @Author: Copyright 2021 Suwings
3+
* @Date: 2021-07-13 19:19:54
4+
* @LastEditTime: 2021-07-13 19:26:54
5+
* @Description: Ajax 请求封装层
6+
*/
7+
import axios from "axios";
8+
export function request(self, ...p) {
9+
try {
10+
return axios.request(...p);
11+
} catch (error) {
12+
self.$message({ type: "error", message: `操作错误: ${error.message}` });
13+
}
14+
}

src/app/service/text.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* @Author: Copyright 2021 Suwings
3+
* @Date: 2021-07-13 19:30:44
4+
* @LastEditTime: 2021-07-13 19:35:08
5+
* @Description:
6+
*/
7+
8+
export const ERROR_TEXT = "操作错误,请稍后再试";
9+
10+
export const OK_TEXT = "操作成功";

src/app/views/Container.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
* @Author: Copyright(c) 2020 Suwings
33
* @Date: 2021-05-08 11:53:54
4-
* @LastEditTime: 2021-07-05 17:15:29
4+
* @LastEditTime: 2021-07-07 17:20:20
55
* @Description:
66
-->
77

@@ -11,7 +11,7 @@
1111
<template #default>
1212
<div class="flex flex-space-between flex-align-items-center">
1313
<div>
14-
<el-button type="success" size="mini">新建镜像</el-button>
14+
<el-button type="success" size="mini" @click="newImage">新建镜像</el-button>
1515
<el-button type="" size="mini">刷新</el-button>
1616
</div>
1717
<span class="color-gray">新建镜像可能需要一定时间。&nbsp;&nbsp;</span>
@@ -39,6 +39,7 @@
3939
</template>
4040

4141
<script>
42+
import router from "../router";
4243
import Panel from "../../components/Panel";
4344
// import LineLabel from "../../components/LineLabel";
4445
@@ -85,7 +86,11 @@ export default {
8586
]
8687
};
8788
},
88-
methods: {}
89+
methods: {
90+
newImage() {
91+
router.push({ path: `/new_image` });
92+
}
93+
}
8994
};
9095
</script>
9196

src/app/views/FileManager.vue

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
<!--
2+
* @Author: Copyright(c) 2020 Suwings
3+
* @Date: 2021-05-08 11:53:54
4+
* @LastEditTime: 2021-07-14 15:25:18
5+
* @Description:
6+
-->
7+
8+
<template>
9+
<Panel>
10+
<template #title>文件管理</template>
11+
<template #default>
12+
<div class="instance-table-warpper">
13+
<div>
14+
<el-button size="small" type="success"> <i class="el-icon-plus"></i> 上传文件 </el-button>
15+
<el-button size="small" type="primary"> <i class="el-icon-refresh"></i> 刷新 </el-button>
16+
</div>
17+
<div>
18+
<el-button size="small" type="primary">
19+
<i class="el-icon-video-play"></i> 压缩
20+
</el-button>
21+
<el-button size="small" type="primary">
22+
<i class="el-icon-video-pause"></i> 解压
23+
</el-button>
24+
<el-button size="small" type="primary">
25+
<i class="el-icon-video-pause"></i> 移动
26+
</el-button>
27+
<el-button size="small" type="danger"> <i class="el-icon-delete"></i> 删除 </el-button>
28+
</div>
29+
</div>
30+
31+
<p>当前目录: {{ this.currentDir }}</p>
32+
33+
<el-table
34+
:data="files"
35+
stripe
36+
style="width: 100%"
37+
size="mini"
38+
ref="multipleTable"
39+
@selection-change="selectionChange"
40+
>
41+
<el-table-column type="selection" width="55"> </el-table-column>
42+
<el-table-column prop="name" label="文件命令" min-width="240">
43+
<template #default="scope">
44+
<div
45+
v-if="scope.row.type == 0"
46+
class="filemanager-item-dir"
47+
@click="toDir(scope.row.name)"
48+
>
49+
<i class="el-icon-folder"></i>
50+
<span>{{ scope.row.name }}</span>
51+
</div>
52+
<div v-if="scope.row.type == 1" class="filemanager-item-file">
53+
<i class="el-icon-tickets"></i>
54+
<span>{{ scope.row.name }}</span>
55+
</div>
56+
</template>
57+
</el-table-column>
58+
<el-table-column prop="typeText" label="文件类型" width="120"></el-table-column>
59+
<el-table-column prop="size" label="文件大小" width="140"></el-table-column>
60+
<el-table-column prop="timeText" label="最后修改" width="160"></el-table-column>
61+
<el-table-column label="操作" style="text-align: center" width="180">
62+
<template #default="scope">
63+
<el-button size="mini" :disabled="scope.row.type != 1"> 编辑 </el-button>
64+
</template>
65+
</el-table-column>
66+
</el-table>
67+
</template>
68+
</Panel>
69+
</template>
70+
71+
<script>
72+
import Panel from "../../components/Panel";
73+
import axios from "axios";
74+
import { API_FILE_URL } from "../service/common";
75+
import path from "path";
76+
// import qs from "qs";
77+
78+
export default {
79+
data() {
80+
return {
81+
serviceUuid: this.$route.params.serviceUuid,
82+
instanceUuid: this.$route.params.instanceUuid,
83+
multipleSelection: [],
84+
files: [],
85+
currentDir: "./"
86+
};
87+
},
88+
async mounted() {
89+
await this.render();
90+
},
91+
unmounted() {},
92+
methods: {
93+
async refresh() {
94+
await this.render();
95+
this.$message({ message: "已刷新", type: "success" });
96+
},
97+
async render() {
98+
await this.cd(".");
99+
const result = await this.list();
100+
console.log("响应:", result.data.data);
101+
},
102+
103+
// 进入某目录
104+
async toDir(name) {
105+
try {
106+
let p = ".";
107+
if (name == "返回上层") p = path.normalize(path.join(this.currentDir, "../"));
108+
else p = path.normalize(path.join(this.currentDir, name));
109+
await this.cd(p);
110+
await this.list();
111+
} catch (error) {
112+
this.$message({ message: "错误,无法查看此目录或文件", type: "error" });
113+
}
114+
},
115+
116+
// 目录 CD 功能
117+
async cd(cwd = ".") {
118+
const res = await axios.get(`${API_FILE_URL}/cd/${this.serviceUuid}/`, {
119+
params: {
120+
uuid: this.instanceUuid,
121+
cd: cwd
122+
}
123+
});
124+
this.currentDir = path.normalize(cwd);
125+
console.log("cd", res, cwd);
126+
},
127+
// 目录 List 功能
128+
async list() {
129+
const res = await axios.get(`${API_FILE_URL}/list/${this.serviceUuid}/`, {
130+
params: {
131+
uuid: this.instanceUuid
132+
}
133+
});
134+
this.tableFilter(res.data.data);
135+
},
136+
137+
// 表格数据处理
138+
tableFilter(filesData) {
139+
this.files = [];
140+
// 存放返回上层目录
141+
this.files.push({
142+
name: "返回上层",
143+
type: 0,
144+
size: 0,
145+
typeText: "目录",
146+
timeText: "--"
147+
});
148+
149+
for (const iterator of filesData) {
150+
const typeText = iterator.type == 1 ? "文件" : "目录";
151+
const timeText =
152+
new Date(iterator.time).toLocaleDateString() +
153+
" " +
154+
new Date(iterator.time).toLocaleTimeString();
155+
this.files.push({
156+
name: iterator.name,
157+
type: iterator.type,
158+
size: iterator.size,
159+
typeText: typeText,
160+
timeText: timeText
161+
});
162+
}
163+
},
164+
165+
// 表格多选函数
166+
selectionChange(v) {
167+
this.multipleSelection = v;
168+
}
169+
},
170+
components: { Panel }
171+
};
172+
</script>
173+
174+
<style>
175+
.filemanager-item-dir {
176+
font-size: 14px;
177+
text-decoration: underline;
178+
cursor: pointer;
179+
}
180+
.filemanager-item-file {
181+
font-size: 14px;
182+
}
183+
.filemanager-item-dir span {
184+
margin-left: 4px;
185+
}
186+
.filemanager-item-file span {
187+
margin-left: 4px;
188+
}
189+
</style>

0 commit comments

Comments
 (0)