-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
331 lines (329 loc) · 14.6 KB
/
index.html
File metadata and controls
331 lines (329 loc) · 14.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
<!DOCTYPE html>
<html lang="zh-CN" class="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>丝之歌计时器生成器网页版</title>
<link rel="stylesheet" href="http://127.0.0.1:12333/x/static/css-vars.css" />
<link rel="stylesheet" href="http://127.0.0.1:12333/x/static/index.css" />
<script src="http://127.0.0.1:12333/x/static/vue.global.prod.js"></script>
<script src="http://127.0.0.1:12333/x/static/index.full.min.js"></script>
<script src="http://127.0.0.1:12333/x/static/index.iife.min.js"></script>
<script src="http://127.0.0.1:12333/x/static/axios.min.js"></script>
</head>
<body>
<div id="app" style="display: flex; flex-direction: column;">
<el-select v-model="currentTemplate" filterable placeholder="你可以选择现有模板" style="width: 500px" @change="selectTemplate">
<el-option v-for="item in templates" :key="item.value" :label="item.label" :value="item.value"></el-option>
</el-select>
<el-upload v-model:file-list="fileList" drag action="/upload" accept=".lss" :on-success="uploadTableData" :on-error="uploadFailed" :on-change="handleChange" style="max-width: 960px">
<el-icon class="el-icon--upload"><upload-filled></upload-filled></el-icon>
<div class="el-upload__text">
你也可以将文件拖拽到这里或者 <em>点击上传</em>
</div>
<template #tip>
<div class="el-upload__tip">
只支持 *.lss 文件
</div>
</template>
</el-upload>
<el-alert title="使用网页版期间请勿关闭计时器生成器!" type="error" style="max-width: 960px"></el-alert>
<el-alert title="由于翻译水平有限,翻译可能不准确,请检查翻译对照表是否正确后使用。" type="warning" :show-icon="true" close-text="打开翻译对照表" @close="openTranslate" style="max-width: 960px"></el-alert>
<div style="align-self: flex-start; display: flex; gap: 8px;">
<el-button type="success" @click="fillIcons">一键填充所有未填充的图标</el-button>
<el-button type="danger" @click="resetIcons">一键清空所有图标</el-button>
<el-button type="primary" @click="downloadIcons">下载所有图标</el-button>
</div>
<div>
<el-switch
v-model="skipStartAnimation"
size="large"
active-text="跳过开场动画"
inactive-text="不跳过"
@change="onSkipStartAnimationChange"
:disabled="disableStartAnimation"
></el-switch>
<a href="https://cutereimu.cn/daily/silksong/speedrun-submit.html#%E6%96%B0%E8%A7%84%E5%88%99-%E5%85%81%E8%AE%B8%E8%B7%B3%E8%BF%87%E5%BC%80%E5%9C%BA%E5%8A%A8%E7%94%BB" target="_blank" rel="noopener noreferrer">
<el-text size="large" style="margin-left: 12px;">这是什么意思?</el-text>
</a>
</div>
<el-table :data="tableData" style="max-width: 960px" v-loading="loading" element-loading-text="正在加载数据...">
<el-table-column label="图标" width="60px">
<template #default="scope">
<el-image v-if="scope.row.icon.length>0" style="width: 25px; height: 25px" :src="scope.row.icon" fit="contain"></el-image>
</template>
</el-table-column>
<el-table-column label="节点名称">
<template #default="scope">
<el-input v-if="scope.$index>0 && scope.$index<tableData.length-1" v-model="scope.row.name" filterable placeholder="节点名称" style="width: 300px"></el-input>
</template>
</el-table-column>
<el-table-column label="触发事件">
<template #default="scope">
<el-select v-if="scope.$index<tableData.length-1" v-model="scope.row.event"
@change="onEventChange(scope.$index)" filterable placeholder="触发事件" style="width: 300px">
<el-option v-for="item in options" :key="item.value" :label="item.label"
:value="item.value"></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="操作" :width="220">
<template #default="scope">
<el-button v-if="scope.$index>0" :icon="Plus" circle @click="addLine(scope.$index)"></el-button>
<el-button :disabled="tableData.length<=3" v-if="scope.$index>0 && scope.$index<tableData.length-1" :icon="Minus" circle @click="removeLine(scope.$index)"></el-button>
<el-button :disabled="scope.$index<=1" v-if="scope.$index>0 && scope.$index<tableData.length-1" :icon="Top" circle @click="swapLine(scope.$index-1, scope.$index)"></el-button>
<el-button :disabled="scope.$index>=tableData.length-2" v-if="scope.$index>0 && scope.$index<tableData.length-1" :icon="Bottom" @click="swapLine(scope.$index, scope.$index+1)" circle></el-button>
</template>
</el-table-column>
</el-table>
<el-checkbox v-model="includeTimeRecords" size="large">保留*.lss文件中原本的时间记录(如果有)</el-checkbox>
<el-button type="primary" @click="submit" style="align-self: flex-start;" :disabled="disableSubmit">另存为</el-button>
</div>
<script>
// 导入需要的图标
const { Plus, Minus, Top, Bottom, UploadFilled } = ElementPlusIconsVue;
const { ElMessage } = ElementPlus;
const { createApp } = Vue;
const app = createApp({
data() {
return {
includeTimeRecords: true,
disableSubmit: false,
skipStartAnimation: false,
disableStartAnimation: false,
options: {{.options}},
currentTemplate: '',
templates: [],
loading: false,
tableData: [
{
name: '',
event: 'StartNewGame',
icon: '',
},
{
name: '任意结束',
event: 'EndingSplit',
icon: '',
},
{
name: '',
event: 'ManualSplit',
icon: '',
},
],
fileList: [],
};
},
setup() {
return {
Plus,
Minus,
Top,
Bottom,
UploadFilled,
};
},
mounted() {
axios.get('/get-templates')
.then(response => {
this.templates = response.data;
})
.catch(error => {
console.log(error);
})
},
methods: {
onSkipStartAnimationChange(value) {
if (value) {
if (this.tableData[0].event !== "Act1Start") {
this.tableData[0].event = "Act1Start";
}
} else {
if (this.tableData[0].event !== "StartNewGame") {
this.tableData[0].event = "StartNewGame";
}
}
},
refreshStartAnimationChange(eventValue) {
switch (eventValue) {
case "StartNewGame":
this.skipStartAnimation = false;
this.disableStartAnimation = false;
break;
case "Act1Start":
this.skipStartAnimation = true;
this.disableStartAnimation = false;
break;
default:
this.disableStartAnimation = true;
}
},
addLine(index) {
this.tableData.splice(index, 0,
{
name: '手动分割',
event: 'ManualSplit',
icon: '',
},
);
},
removeLine(index) {
this.tableData.splice(index, 1);
},
swapLine(index1, index2) {
const temp = this.tableData[index1];
this.tableData[index1] = this.tableData[index2];
this.tableData[index2] = temp;
},
submit() {
axios.post('/build-splits',
{ data: this.tableData.slice(0, -1), includeTimeRecords: this.includeTimeRecords },
{
responseType: 'blob',
headers: { 'Content-Type': 'application/json' },
})
.then(response => {
this.disableSubmit = true;
const blob = new Blob([response.data], { type: 'application/octet-stream' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = 'splits.lss';
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
setTimeout(() => {
URL.revokeObjectURL(url);
this.disableSubmit = false;
}, 2000);
})
.catch(error => {
console.error(error);
ElMessage({ message: '导出失败', type: 'error', plain: true });
});
},
downloadIcons() {
axios.get('/download/icons',
{
responseType: 'blob',
})
.then(response => {
this.disableSubmit = true;
const blob = new Blob([response.data], { type: 'application/zip' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = 'icons.zip';
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
setTimeout(() => {
URL.revokeObjectURL(url);
this.disableSubmit = false;
}, 2000);
})
.catch(error => {
console.error(error);
ElMessage({ message: '导出失败', type: 'error', plain: true });
});
},
uploadTableData(newData) {
this.loading = true;
this.tableData = newData;
this.$nextTick(() => {
this.loading = false;
});
},
uploadFailed(err) {
console.log(err);
ElMessage({
message: err,
type: 'error',
plain: true,
});
},
selectTemplate(value) {
this.loading = true;
axios.post('/get-splits', {name: value}, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
})
.then(response => {
this.tableData = [...response.data.splits, {
name: '',
event: 'ManualSplit',
icon: '',
}];
this.refreshStartAnimationChange(this.tableData[0].event)
this.$nextTick(() => {
this.loading = false;
});
})
.catch(error => {
console.log(error);
this.loading = false;
});
},
handleChange(file, fileList) {
const latest = fileList.slice(-1);
this.fileList.splice(0, this.fileList.length, ...latest);
},
openTranslate() {
window.open('/translate', '_blank', 'noopener,noreferrer');
},
onEventChange(idx) {
const eventValue = this.tableData[idx].event;
if (idx === 0) {
this.refreshStartAnimationChange(eventValue)
}
const opt = this.options.find(o => o.value === eventValue);
if (opt) {
const label = opt.label;
const pos = label.indexOf('(');
this.tableData[idx].name = pos === -1 ? label : label.slice(0, pos);
}
if (idx === 0) {
return;
}
axios.get('/get-icon?name=' + encodeURIComponent(this.tableData[idx].event))
.then(response => {
this.tableData[idx].icon = response.data;
})
.catch(error => {
console.log(error);
});
},
fillIcons() {
for (let idx = 1; idx < this.tableData.length - 1; idx++) {
const row = this.tableData[idx];
if (row.icon.length === 0) {
axios.get('/get-icon?name=' + encodeURIComponent(row.event))
.then(response => {
row.icon = response.data;
})
.catch(error => {
console.log(error);
});
}
}
},
resetIcons() {
for (let idx = 1; idx < this.tableData.length - 1; idx++) {
if (idx === 0 || idx === this.tableData.length - 1) {
continue;
}
this.tableData[idx].icon = '';
}
},
},
});
app.component(UploadFilled.name, UploadFilled);
app.use(ElementPlus);
app.mount('#app');
</script>
</body>
</html>