Skip to content

Commit a355284

Browse files
SkyBird233MingcongBai
authored andcommitted
feat(download): reset download tab state everytime
1 parent c5fed95 commit a355284

File tree

4 files changed

+32
-74
lines changed

4 files changed

+32
-74
lines changed

src/pages/download/DownloadIndex.vue

+8-9
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ import CategorySecond from '../../components/CategorySecond.vue';
33
import TitleComponent from './components/TitleComponent.vue';
44
import DownloadButtonGroup from './components/DownloadButtonGroup.vue';
55
import WslDetails from './components/WslDetails.vue';
6-
import { ref, useTemplateRef , computed } from 'vue';
6+
import { ref, useTemplateRef, computed } from 'vue';
77
import DownloadButton from './components/DownloadButton.vue';
88
import { useRoute } from 'vue-router';
99
import useClipboard from 'vue-clipboard3';
1010
import { ElMessage, ElDialog } from 'element-plus';
11-
import { useDownloadPageStore } from '../../stores/download-page.js';
1211
import { highlightElement } from '../../utils/animation.ts';
1312
import { requestGetJson, useHighlightWatch } from '../../utils/utils.js';
1413
@@ -27,7 +26,6 @@ const archGroupInfo = {
2726
};
2827
2928
const route = useRoute();
30-
const downloadPageStore = useDownloadPageStore();
3129
//#endregion
3230
3331
//#region Clipboard
@@ -507,14 +505,15 @@ const omaInstallScript = 'curl -sSf https://repo.aosc.io/get-oma.sh | sudo sh';
507505
description="适用于基于 Apple 芯片的 Mac 设备"
508506
:navigation-list="appleSiliconNavigationList"
509507
small-title />
510-
<div
511-
class="flex flex-col self-end [&_.theme-bg-color-secondary-primary]:py-2">
508+
<div class="self-end">
512509
<DownloadButton
513510
arch-name="下载"
514-
@click="
515-
downloadPageStore.dialogTabArm64 = 'apple-silicon-instruction';
516-
downloadPageStore.dialogArm64State = true;
517-
" />
511+
:popover-data="
512+
antong1List.filter((i) => i.title === 'arm64')[0].popoverData
513+
"
514+
:isa-info="antong1List.filter((i) => i.title === 'arm64')[0]"
515+
:sources="sources"
516+
initial-dialog-tab="apple-silicon-instruction" />
518517
</div>
519518
</div>
520519
</div>

src/pages/download/components/DownloadButton.vue

+15-27
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<script setup>
22
import { ref, computed } from 'vue';
33
import DownloadDetails from './DownloadDetails.vue';
4-
import { useDownloadPageStore } from '../../../stores/download-page.js';
54
import { useRouter } from 'vue-router';
65
76
const props = defineProps({
@@ -41,47 +40,35 @@ const props = defineProps({
4140
disabled: {
4241
type: Boolean,
4342
default: false
43+
},
44+
initialDialogTab: {
45+
type: String,
46+
default: 'installer'
4447
}
4548
});
4649
4750
const router = useRouter();
4851
const dialogState = ref(false);
49-
const downloadPageStore = useDownloadPageStore();
5052
const archNameBrackets = props.archName.match(/^(.*?)([((].*[))])?$/);
5153
5254
const osName = '安同 OS'; // TODO: dynamic OS name (AOSC OS / Afterglow OS)
5355
const dialogTitle = computed(
5456
() => `下载详情:${osName} - ${props.isaInfo?.zhLabel}`
5557
);
5658
57-
const setDialogState = (state) => {
58-
if (props.isaInfo?.title === 'arm64') {
59-
downloadPageStore.dialogArm64State = state;
59+
const onClick = () => {
60+
if (props.url) {
61+
router.push(props.url);
6062
} else {
61-
dialogState.value = state;
63+
dialogState.value = true;
6264
}
6365
};
64-
65-
const dialogModel = computed({
66-
get() {
67-
return props.isaInfo?.title === 'arm64'
68-
? downloadPageStore.dialogArm64State
69-
: dialogState.value;
70-
},
71-
set(value) {
72-
if (props.isaInfo?.title === 'arm64') {
73-
downloadPageStore.dialogArm64State = value;
74-
} else {
75-
dialogState.value = value;
76-
}
77-
}
78-
});
7966
</script>
8067
8168
<template>
8269
<div>
8370
<el-popover
84-
:disabled="popoverData === undefined || dialogModel"
71+
:disabled="popoverData === undefined || dialogState"
8572
:placement="popoverData?.placement"
8673
:hide-after="0"
8774
trigger="hover"
@@ -94,9 +81,7 @@ const dialogModel = computed({
9481
backgroundColor: buttonColor,
9582
width: $props.width + 'px'
9683
}"
97-
@click="
98-
url?.startsWith('#') ? router.push(url) : setDialogState(true)
99-
"
84+
@click="onClick"
10085
class="theme-bg-color-secondary-primary h-full grow hover:no-underline cursor-pointer py-2 overflow-hidden">
10186
<slot></slot>
10287
<span class="first-line-p">{{ archNameBrackets[1] }}</span>
@@ -107,14 +92,17 @@ const dialogModel = computed({
10792
10893
<el-dialog
10994
v-if="!disabled && popoverData && isaInfo"
110-
v-model="dialogModel"
95+
v-model="dialogState"
11196
width="80%"
97+
destroy-on-close
11298
:title="dialogTitle">
11399
<DownloadDetails
114100
:arch="archName"
115101
:content="popoverData.content"
116102
:isa-info="isaInfo"
117-
:sources="sources" />
103+
:sources="sources"
104+
:initial-tab="initialDialogTab"
105+
/>
118106
</el-dialog>
119107
</div>
120108
</template>

src/pages/download/components/DownloadDetails.vue

+9-27
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<script setup>
2-
import { computed } from 'vue';
2+
import { ref } from 'vue';
33
import { ElTabs, ElTabPane } from 'element-plus';
44
import DownloadDetailsMain from './DownloadDetailsMain.vue';
55
import DownloadDetailsAppleSiliconInstruction from './DownloadDetailsAppleSiliconInstruction.vue';
6-
import { useDownloadPageStore } from '../../../stores/download-page.js';
76
87
const props = defineProps({
98
isaInfo: {
@@ -22,27 +21,18 @@ const props = defineProps({
2221
sources: {
2322
type: [{ name: String, loc: String, url: String }],
2423
required: true
25-
}
26-
});
27-
28-
const downloadPageStore = useDownloadPageStore();
29-
const activeTab = computed({
30-
get() {
31-
return props.isaInfo.title === 'arm64'
32-
? downloadPageStore.dialogTabArm64
33-
: downloadPageStore.dialogTab;
3424
},
35-
set(value) {
36-
if (['installer', 'livekit'].includes(value)) {
37-
downloadPageStore.dialogTab = value;
38-
}
39-
downloadPageStore.dialogTabArm64 = value;
25+
initialTab: {
26+
type: String,
27+
default: 'installer'
4028
}
4129
});
30+
31+
const dialogTab = ref(props.initialTab);
4232
</script>
4333

4434
<template>
45-
<el-tabs v-model="activeTab" class="*:px-2 pb-2">
35+
<el-tabs v-model="dialogTab" class="*:px-2 pb-2">
4636
<el-tab-pane
4737
:disabled="!isaInfo.installer"
4838
label="系统安装盘"
@@ -78,15 +68,7 @@ const activeTab = computed({
7868
disabled>
7969
<!-- TODO -->
8070
</el-tab-pane>
81-
<el-tab-pane
82-
label="Docker"
83-
name="docker"
84-
disabled
85-
/>
86-
<el-tab-pane
87-
label="虚拟机镜像"
88-
name="vm"
89-
disabled
90-
/>
71+
<el-tab-pane label="Docker" name="docker" disabled />
72+
<el-tab-pane label="虚拟机镜像" name="vm" disabled />
9173
</el-tabs>
9274
</template>

src/stores/download-page.js

-11
This file was deleted.

0 commit comments

Comments
 (0)