-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.html
231 lines (229 loc) · 9.88 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<title>Auto Scratch Desktop Mirror</title>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes"
/>
<link
rel="shortcut icon"
href="//www.google.com/s2/favicons?sz=64&domain=scratch.mit.edu"
/>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script
async
src="https://www.googletagmanager.com/gtag/js?id=G-FD23CNKF3B"
></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "G-FD23CNKF3B");
</script>
<link
href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900"
rel="stylesheet"
/>
<link
href="https://cdn.jsdelivr.net/npm/@mdi/[email protected]/css/materialdesignicons.min.css"
rel="stylesheet"
/>
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.css"
rel="stylesheet"
/>
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui"
/>
</head>
<body>
<div id="app">
<v-app>
<v-main>
<v-toolbar elevation="4">
<v-app-bar-nav-icon>
<v-icon>mdi-download-box-outline</v-icon>
</v-app-bar-nav-icon>
<v-toolbar-title
>Auto Scratch-Desktop Mirror NEXT</v-toolbar-title
>
</v-toolbar>
<v-container class="d-flex mt-5">
<v-row class="mx-5">
<v-col>
<div class="text-body-1">
Auto Scratch Desktop Mirror 是一个 Scratch
桌面版的开源下载镜像项目。我们通过 Github Workflow
自动下载 Scratch 官网的 Scratch 桌面版程序,并透过
CDN 或 Github Pages
提供,以方便中国大陆地区的用户下载。
<p class="font-weight-light mt-2 text-caption">
项目开源于
<a href="https://github.com/scratch-bar/asdm"
>GitHub</a
>,本版本由 waterblock79 开发。
<br />
感谢: Scratch Team, GitHub, Vue.js, Vuetify.js
以及所有为这个项目添砖加瓦的人们!
</p>
</div>
</v-col>
<v-col>
<v-card elevation="2">
<v-card-title>下载 Scratch 3.0</v-card-title>
<v-card-text>
您也可以尝试
<a
href="https://llk.github.io/scratch-gui/develop/"
>在线版本的 Scratch 3.0</a
>
,或在应用商店中下载
<a
href="https://apps.apple.com/cn/app/scratch-desktop/id1446785996?mt=12"
>Mac OS 版本</a
>
和
<a
href="https://www.microsoft.com/zh-cn/p/scratch-3/9pfgj25jl6x3"
>Windows 10 以上版本</a
>
的 Scratch 桌面版。
<br />
<b v-if="data.length"
>最后镜像于 {{ new
Date(data[0].time).toLocaleDateString() }}。</b
>
</v-card-text>
<v-card-actions>
<v-btn
color="primary"
v-for="download in data"
@click="downloadItem(download)"
text
:disabled="!!currentDownload"
>
<v-icon size="16">{{download.icon}}</v-icon>
{{download.description}}
</v-btn>
</v-card-actions>
<small class="ml-4 blue-grey--text" v-if="currentDownload"
>{{ (currentDownload?.size * progress / 100
/ 1024 / 1024).toFixed(1) }} MB 已下载</small
>
<v-progress-linear
:value="progress"
v-if="currentDownload"
></v-progress-linear>
</v-card>
<v-card elevation="2" class="mt-7">
<v-card-title>设置下载源</v-card-title>
<v-card-text>
通常情况下您<b>不需要更改下载源</b>,但如果默认下载源不可用,您可以更改为另外一个,或者自定义下载源。
<v-combobox
v-model="source"
:items="['', 'https://scratch-bar.github.io/asdm/', 'https://cdn.jsdelivr.net/gh/scratch-bar/asdm/']"
dense
></v-combobox>
</v-card-text>
</v-card>
</v-col>
</v-row>
</v-container>
</v-main>
</v-app>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.js"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script>
new Vue({
el: "#app",
vuetify: new Vuetify(),
data: {
data: [],
source: "",
currentDownload: null,
chunkLoaded: [],
progress: 0,
},
watch: {
source: {
handler() {
axios
.get(`${this.source}output/data.json`)
.then((res) => {
this.data = res.data;
})
.catch(e => alert(`我们在从 ${this.source} 获取下载清单时遇到了一个错误:\n${e}`))
},
immediate: true
},
},
methods: {
computeProgress() {
if (this.currentDownload) {
let sum = 0;
this.chunkLoaded.forEach((c) => {
if (Number.isInteger(c)) {
sum += c;
}
});
return (sum / this.currentDownload.size) * 100;
} else {
return 0;
}
},
downloadItem(item) {
this.currentDownload = item;
this.chunkLoaded = [];
let chunks = [],
sum = 0;
const source = axios.CancelToken.source();
item.download.forEach((chunk, index) => {
let chunkUrl = `${this.source}output/${chunk}`;
axios
.get(chunkUrl, {
responseType: "arraybuffer",
onDownloadProgress: (e) => {
this.chunkLoaded[index] = e.loaded;
this.progress = this.computeProgress();
},
cancelToken: source.token
})
.then((res) => {
chunks[index] = res.data;
sum++;
if (sum === item.download.length && this.currentDownload) {
let size = 0;
chunks.forEach((c) => (size += c.byteLength));
let output = new Uint8Array(size),
offset = 0;
chunks.forEach((c) => {
output.set(new Uint8Array(c), offset);
offset += c.byteLength;
});
let a = document.createElement("a");
a.href = URL.createObjectURL(new Blob([output]));
a.download = item.fileName;
a.click();
this.currentDownload = null;
}
})
.catch((e) => {
if (e.name === 'CanceledError') return;
alert("我们在获取 " + chunkUrl + " 时遇到了一个错误:\n" + e);
this.currentDownload = null;
source.cancel('Meet an error');
});
});
},
},
});
</script>
</body>
</html>