Skip to content

Commit 2e42011

Browse files
committed
feat: 完善ECS转换器的UI
del: 删掉了vuetify的示例代码
1 parent 3756ac9 commit 2e42011

File tree

2 files changed

+93
-173
lines changed

2 files changed

+93
-173
lines changed

src/components/HelloWorld.vue

-157
This file was deleted.

src/pages/ecs.vue

+93-16
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,91 @@
11
<template>
22
<h1 class="text-h3 text-sm-h3">从Electron Class Schedule迁移</h1>
33

4-
<v-file-input
5-
v-model="file"
6-
label="上传配置文件"
7-
@multiple="false"
8-
@change="loadFile()"
9-
></v-file-input>
104
<br />
115

12-
<v-btn v-if="isFileLoaded" @click="convert()">开始转换</v-btn>
6+
<v-stepper :items="['说明', '上传ECS配置', '转换']">
7+
<template v-slot:item.1>
8+
<v-card flat>
9+
<v-card-item>
10+
<v-card-title>转换说明</v-card-title>
11+
</v-card-item>
12+
13+
<v-card-text>
14+
本转换向导将提供将Electron Class Schedule基于JS的配置文件
15+
(scheduleConfig.js) 转换为ClassIsland档案文件的服务。
16+
<br />
17+
上传您的ECS配置文件 (基于JS),然后点击开始转换。
18+
<br />
19+
转换完成后,ClassIsland档案文件将会自动下载,您可以将其导入到ClassIsland中
20+
(直接放入Profiles文件夹)。
21+
</v-card-text>
22+
</v-card>
23+
</template>
24+
25+
<template v-slot:item.2>
26+
<v-card flat>
27+
<v-card-item>
28+
<v-card-title>上传ECS配置</v-card-title>
29+
</v-card-item>
30+
31+
<v-card-text>
32+
请上传您的ECS配置文件 (scheduleConfig.js)。
33+
<br />
34+
<br />
35+
<v-file-input
36+
v-model="file"
37+
label="上传配置文件"
38+
@multiple="false"
39+
@change="loadFile()"
40+
></v-file-input>
41+
</v-card-text>
42+
</v-card>
43+
</template>
44+
45+
<template v-slot:item.3>
46+
<v-card flat>
47+
<v-card-item>
48+
<v-card-title>转换</v-card-title>
49+
</v-card-item>
50+
51+
<v-card-text>
52+
确认上传文件无误后,请点击“开始转换”。
53+
54+
<br />
55+
<br />
56+
<v-btn v-show="isFileLoaded" @click="convert()">开始转换</v-btn>
57+
58+
<br />
59+
<br />
60+
61+
<v-expand-transition>
62+
<v-alert
63+
v-show="isConverted"
64+
title="转换完成"
65+
text="ClassIsland档案文件将会自动下载,您可以将其导入到ClassIsland中(直接放入Profiles文件夹)。"
66+
type="success"
67+
></v-alert>
68+
</v-expand-transition>
69+
<v-expand-transition>
70+
<v-alert
71+
v-show="!isFileLoaded"
72+
title="请先上传文件"
73+
text="请先上传您的ECS配置文件 (scheduleConfig.js)。"
74+
type="warning"
75+
></v-alert>
76+
</v-expand-transition>
77+
<v-expand-transition>
78+
<v-alert
79+
v-show="convertingError"
80+
title="转换失败"
81+
:text="'转换过程中发生错误,请检查您的配置文件。'+convertingError"
82+
type="error"
83+
></v-alert>
84+
</v-expand-transition>
85+
</v-card-text>
86+
</v-card>
87+
</template>
88+
</v-stepper>
1389
</template>
1490

1591
<script lang="ts" setup>
@@ -25,6 +101,8 @@ const isFileLoaded = ref(false);
25101
const convertingError = ref(null);
26102
27103
function loadFile() {
104+
isConverted.value = false;
105+
convertingError.value = null;
28106
// console.log(file.value);
29107
if (file.value) {
30108
const reader = new FileReader();
@@ -37,16 +115,15 @@ function loadFile() {
37115
}
38116
39117
function downloadJson(fileName, json) {
40-
const jsonStr = (json instanceof Object) ? JSON.stringify(json, null, 4) : json;
41-
42-
const url = window.URL || window.webkitURL || window;
43-
const blob = new Blob([jsonStr]);
44-
const saveLink = document.createElement('a');
45-
saveLink.href = url.createObjectURL(blob);
46-
saveLink.download = fileName;
47-
saveLink.click();
48-
}
118+
const jsonStr = json instanceof Object ? JSON.stringify(json, null, 4) : json;
49119
120+
const url = window.URL || window.webkitURL || window;
121+
const blob = new Blob([jsonStr]);
122+
const saveLink = document.createElement("a");
123+
saveLink.href = url.createObjectURL(blob);
124+
saveLink.download = fileName;
125+
saveLink.click();
126+
}
50127
51128
function convert() {
52129
try {

0 commit comments

Comments
 (0)