Skip to content

Commit 2fe0b16

Browse files
committed
upd: add some releases links
1 parent 583bacf commit 2fe0b16

8 files changed

Lines changed: 187 additions & 309 deletions

File tree

src/client/components/download-button.vue

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,53 @@ import { Prop } from 'vue-property-decorator';
44
import macOS from '@client/assets/images/macos.png';
55
import windows from '@client/assets/images/windows.png';
66
import download from '@client/assets/images/download.png';
7+
import platformUtil from '@client/utils/platform.util';
8+
import { ReleasesConfig } from '@client/utils/data.config';
79
810
export default class DownloadButton extends Vue {
911
@Prop({ type: String, default: 'Windows' }) platform!: string;
12+
@Prop({ type: String, default: "arm64"}) arch!: string;
1013
@Prop({ type: Boolean, default: false }) isHome: Boolean;
1114
12-
isSupportedPlatform = this.platform === 'windows' || this.platform === 'macOS';
15+
isSupportedPlatform = this.platform === 'windows' || this.platform === 'mac';
1316
14-
isUnSupportedPlatform = this.platform !== 'windows' && this.platform !== 'macOS';
17+
isUnsupportedPlatform = this.platform !== 'windows' && this.platform !== 'mac';
1518
1619
get platformName(): string {
17-
return this.platform === 'macOS' ? 'macOS' : 'Windows';
20+
return this.platform === 'mac' ? 'mac' : 'windows';
1821
}
1922
2023
get platformImage(): string {
2124
switch (this.platform) {
2225
case 'windows':
2326
return windows;
24-
case 'macOS':
27+
case 'mac':
2528
return macOS;
2629
default:
2730
return download;
2831
}
2932
}
33+
34+
private handleDownload() {
35+
const version = process.env.VITE_VERSION;
36+
const releasesConfig = new ReleasesConfig(version as string);
37+
let downloadLink = releasesConfig.downloadSingleSystemLink(this.platform, this.arch);
38+
console.log("Download link:", downloadLink);
39+
// window.open(downloadLink, '_blank');
40+
}
3041
}
3142
</script>
3243

3344
<template>
3445
<div class="btn-container">
35-
<button class="download btn">
46+
<button class="download btn" @click="handleDownload">
3647
<img :src="platformImage" alt="" />
37-
{{ isUnSupportedPlatform && isHome ? '下载可用版本' : '下载 ' + platformName + "版本" }}
48+
{{ isUnsupportedPlatform && isHome ? '下载可用版本' : '下载 ' + platformName + "版本" }}
3849
</button>
3950
<span class="download-all-platforms" v-if="isSupportedPlatform && isHome">
4051
下载 <router-link class="link" to="/releases">其他平台</router-link> 版本
4152
</span>
42-
<span class="download-all-platforms" v-if="isUnSupportedPlatform && isHome"
53+
<span class="download-all-platforms" v-if="isUnsupportedPlatform && isHome"
4354
>仅支持 Windows 和 macOS.</span
4455
>
4556
</div>

src/client/components/home-footer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
22
import { Vue, Options } from 'vue-class-component';
3-
import DataConfig from '@client/utils/data.config';
3+
import { DataConfig } from '@client/utils/data.config';
44
55
@Options({})
66
export default class HomeFooter extends Vue {

src/client/components/release-item.vue

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { Vue, Options } from 'vue-class-component';
33
import { Prop } from 'vue-property-decorator';
44
import windows from '@client/assets/images/windows_colorful.png';
55
import macOS from '@client/assets/images/macos_colorful.png';
6-
import linux from '@client/assets/images/linux_colorful.png';
76
import DownloadButton from './download-button.vue';
7+
import { ReleasesConfig } from '@client/utils/data.config';
8+
import platformUtil from '@client/utils/platform.util';
89
910
@Options({
1011
components: {
@@ -18,54 +19,70 @@ export default class ReleaseItem extends Vue {
1819
switch (this.platform) {
1920
case 'windows':
2021
return windows;
21-
case 'macOS':
22+
case 'mac':
2223
return macOS;
23-
case 'linux':
24-
return linux;
2524
default:
2625
return '';
2726
}
2827
}
2928
3029
get downloadLink(): string {
31-
switch (this.platform) {
32-
case 'windows':
33-
return 'https://example.com/windows-download';
34-
case 'mac':
35-
return 'https://example.com/macos-download';
36-
case 'linux':
37-
return 'https://example.com/linux-download';
38-
default:
39-
return '';
40-
}
30+
const arch = platformUtil.getArchitecture();
31+
const downloadLink = new ReleasesConfig(process.env.VITE_VERSION as string).downloadSingleSystemLink(
32+
this.platform,
33+
arch,
34+
);
35+
return downloadLink;
4136
}
4237
4338
get otherLinks(): Array<{ type: string; items: Array<{ arch: string; name: string; link: string }> }> {
4439
switch (this.platform) {
4540
case 'windows':
4641
return [
4742
{
48-
type: 'Installer',
43+
type: 'Intel',
4944
items: [
50-
{ arch: 'x64', name: 'Windows 10', link: 'https://example.com/windows-10' },
51-
{ arch: 'arm64', name: 'Windows 11', link: 'https://example.com/windows-11' },
45+
{
46+
arch: 'x64',
47+
name: 'Windows (Intel)',
48+
link: new ReleasesConfig(process.env.VITE_VERSION as string).downloadSingleSystemLink('windows', 'x64'),
49+
},
5250
],
5351
},
5452
{
55-
type: 'Portable',
53+
type: 'Apple Silicon',
5654
items: [
57-
{ arch: 'x64', name: 'Windows 10', link: 'https://example.com/windows-10-msi' },
58-
{ arch: 'arm64', name: 'Windows 11', link: 'https://example.com/windows-11-msi' },
55+
{
56+
arch: 'arm64',
57+
name: 'Windows (Apple Silicon)',
58+
link: new ReleasesConfig(process.env.VITE_VERSION as string).downloadSingleSystemLink(
59+
'windows',
60+
'arm64',
61+
),
62+
},
5963
],
6064
},
6165
];
62-
case 'macOS':
66+
case 'mac':
6367
return [
6468
{
65-
type: '.dmg',
69+
type: 'Apple Silicon',
6670
items: [
67-
{ arch: 'x64', name: 'macOS Big Sur', link: 'https://example.com/macos-big-sur' },
68-
{ arch: 'arm64', name: 'macOS Monterey', link: 'https://example.com/macos-monterey' },
71+
{
72+
arch: 'arm64',
73+
name: 'macOS (Apple Silicon)',
74+
link: new ReleasesConfig(process.env.VITE_VERSION as string).downloadSingleSystemLink('mac', 'arm64'),
75+
},
76+
],
77+
},
78+
{
79+
type: 'Intel',
80+
items: [
81+
{
82+
arch: 'x64',
83+
name: 'macOS (Intel)',
84+
link: new ReleasesConfig(process.env.VITE_VERSION as string).downloadSingleSystemLink('mac', 'x64'),
85+
},
6986
],
7087
},
7188
];
@@ -78,10 +95,10 @@ export default class ReleaseItem extends Vue {
7895
switch (this.platform) {
7996
case 'windows':
8097
return `version ${process.env.VITE_VERSION} for .exe`;
81-
case 'macOS':
98+
case 'mac':
8299
return `version ${process.env.VITE_VERSION} for .dmg`;
83100
default:
84-
return `version ${process.env.VITE_VERSION} for .exe`;
101+
return null;
85102
}
86103
}
87104
}

src/client/modules/home/display.vue

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Vue, Options } from 'vue-class-component';
33
import { Prop } from 'vue-property-decorator';
44
import DownloadButton from '@client/components/download-button.vue';
55
import { isMac, isWindows } from '@client/utils';
6-
import DataConfig from '@client/utils/data.config';
6+
import { DataConfig } from '@client/utils/data.config';
77
88
@Options({
99
components: {
@@ -12,6 +12,7 @@ import DataConfig from '@client/utils/data.config';
1212
})
1313
export default class Display extends Vue {
1414
@Prop({ type: String, required: true }) readonly platform!: string;
15+
@Prop({ type: String, default: "arm64"}) readonly arch!: string;
1516
@Prop({ type: Boolean, default: false }) readonly isMobile!: boolean;
1617
isSupportedPlatform = isMac() || isWindows();
1718
@@ -46,34 +47,27 @@ export default class Display extends Vue {
4647
handleClickOutside = (e: MouseEvent) => {
4748
const target = e.target as HTMLElement;
4849
const dropdown = document.querySelector('.start-dropdown') as HTMLElement;
49-
50-
// 如果点击的不是下拉菜单内部元素,则关闭菜单
5150
if (dropdown && !dropdown.contains(target)) {
5251
this.isStartOpen = false;
5352
}
5453
};
5554
5655
handleEscapeKey = (e: KeyboardEvent) => {
57-
// 按 Escape 键关闭菜单
5856
if (e.key === 'Escape') {
5957
this.isStartOpen = false;
6058
}
6159
};
6260
6361
handleMenuItemClick = () => {
64-
// 点击菜单项后关闭菜单
6562
this.isStartOpen = false;
6663
};
6764
68-
mounted() {
69-
// 添加全局点击事件监听器
65+
created() {
7066
document.addEventListener('click', this.handleClickOutside);
71-
// 添加键盘事件监听器
7267
document.addEventListener('keydown', this.handleEscapeKey);
7368
}
7469
7570
beforeUnmount() {
76-
// 清理事件监听器
7771
document.removeEventListener('click', this.handleClickOutside);
7872
document.removeEventListener('keydown', this.handleEscapeKey);
7973
}
@@ -84,13 +78,11 @@ export default class Display extends Vue {
8478
<div class="content">
8579
<main class="content-main">
8680
<header class="content-main-title">
87-
<h1>
88-
为编程初学者而生
89-
</h1>
81+
<h1>为编程初学者而生</h1>
9082
<h2>一键配置现代的 C++、Python 和 VSCode 编程环境</h2>
9183
</header>
9284
<div class="content-main-subtitle">
93-
<DownloadButton :platform="platform" :is-home="true" />
85+
<DownloadButton :platform="platform" :is-home="true" :arch="arch" />
9486
<div class="start-dropdown">
9587
<a class="start" href="#" @click="handleStartClick">
9688
<svg

src/client/modules/home/home.view.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default class Home extends Vue {
5151

5252
<template>
5353
<div class="home">
54-
<Display :platform="this.getPlatform.os" :isMobile="homeState.isMobile" />
54+
<Display :platform="this.getPlatform.os" :arch="this.getPlatform.architecture" :isMobile="homeState.isMobile" />
5555
<GuideContainer />
5656
<HomeFooter />
5757
<Beams
@@ -76,12 +76,12 @@ export default class Home extends Vue {
7676
:deep(.el-icon) {
7777
color: #ffffff !important;
7878
}
79-
79+
8080
:deep(svg) {
8181
color: #ffffff !important;
8282
fill: #ffffff !important;
8383
}
84-
84+
8585
:deep(svg path) {
8686
fill: #ffffff !important;
8787
stroke: #ffffff !important;

src/client/modules/releases/releases.view.vue

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Vue, Options } from 'vue-class-component';
33
import { View } from 'bwcx-client-vue3';
44
import ReleaseItem from '@client/components/release-item.vue';
55
import HomeFooter from '@client/components/home-footer.vue';
6-
import DataConfig from '@client/utils/data.config';
6+
import { DataConfig } from '@client/utils/data.config';
77
88
@View('/releases')
99
@Options({
@@ -24,7 +24,7 @@ export default class Releases extends Vue {
2424
<header class="release-header">Download Algo Bootstrap</header>
2525
<div class="release-container">
2626
<ReleaseItem :platform="'windows'" />
27-
<ReleaseItem :platform="'macOS'" />
27+
<ReleaseItem :platform="'mac'" />
2828
</div>
2929
<a :href="getOldWebsiteLink" class="old-version" target="_blank">old website</a>
3030
<home-footer />
@@ -69,19 +69,19 @@ export default class Releases extends Vue {
6969
position: relative;
7070
}
7171
.old-version {
72-
position: absolute;
73-
bottom: 300px;
74-
@media screen and (max-width: 1200px) {
75-
bottom: 250px;
76-
}
77-
transform: translateY(50px);
78-
font-size: var(--font-small-size);
79-
color: var(--font-secondary-color);
80-
transition: color 0.3s ease;
72+
position: absolute;
73+
bottom: 300px;
74+
@media screen and (max-width: 1200px) {
75+
bottom: 250px;
76+
}
77+
transform: translateY(50px);
78+
font-size: var(--font-small-size);
79+
color: var(--font-secondary-color);
80+
transition: color 0.3s ease;
8181
82-
&:hover {
83-
color: var(--font-primary-color);
84-
}
82+
&:hover {
83+
color: var(--font-primary-color);
8584
}
85+
}
8686
}
8787
</style>

0 commit comments

Comments
 (0)