1
1
<script setup lang="ts">
2
- import { onMounted , reactive , ref , Ref } from ' vue' ;
2
+ import { computed , Fragment , onMounted , reactive , ref , Ref } from ' vue' ;
3
3
import codeBlock from ' ./codeBlock.vue' ;
4
+ import { useDetectDeviceType } from ' @/hooks/detectDeviceType' ;
5
+
6
+ const deviceType = useDetectDeviceType ();
4
7
const currenClickPlatform = ref (' ' );
8
+
9
+ if (deviceType .value !== ' other' ) {
10
+ currenClickPlatform .value = deviceType .value ;
11
+ } else {
12
+ deviceType .value = ' linux' ;
13
+ }
14
+
5
15
function showCode(type : string ) {
6
- if (currenClickPlatform .value === type ) currenClickPlatform .value = ' ' ;
7
- else currenClickPlatform .value = type ;
16
+ currenClickPlatform .value = type ;
8
17
}
9
18
const platforms = [
10
19
{
@@ -24,7 +33,7 @@ scoop install plc`,
24
33
{
25
34
type: ' linux' ,
26
35
icon: ' fa-brands fa-linux' ,
27
- iconColor: ' rgb(220, 160 , 50)' ,
36
+ iconColor: ' rgb(200, 150 , 50)' ,
28
37
code: ` apt install wget gnupg
29
38
wget -O - https://lang.pivotstudio.cn/apt/public.key | apt-key add -
30
39
echo "deb [arch=amd64] https://lang.pivotstudio.cn/apt/repo focal main
@@ -35,90 +44,67 @@ apt update
35
44
apt install pivot-lang ` ,
36
45
},
37
46
];
47
+
48
+ const curShowCode = computed (() => {
49
+ return platforms .find ((item ) => item .type === currenClickPlatform .value )?.code ;
50
+ });
38
51
</script >
39
52
<template >
40
53
<div id =" advantage" >
41
54
<div class =" gradient-font title" >Cross Platforms</div >
55
+ <div class =" detail-describe" >Download Pivot Lang with the command now!</div >
42
56
<div class =" advantages" >
43
- <div v-for =" item in platforms" class =" advantage-item" :key =" item.type" >
44
- <Transition >
45
- <codeBlock v-if =" currenClickPlatform === item.type" :class =" ['code-block', item.type]" :code =" item.code" ></codeBlock >
46
- </Transition >
47
- <Transition >
48
- <font-awesome-icon
49
- @click =" showCode(item.type)"
50
- inverse
51
- :icon =" item.icon"
52
- :style =" {
53
- color: item.iconColor,
54
- opacity: currenClickPlatform === item.type ? 0 : 1,
55
- display: currenClickPlatform === item.type ? 'hidden' : 'block',
56
- zIndex: currenClickPlatform === item.type ? -1 : 1,
57
- }"
58
- size =" 10x"
59
- class =" picture"
60
- />
61
- </Transition >
57
+ <div v-for =" item in platforms" :class =" { 'advantage-item': true, 'selected-item': item.type === currenClickPlatform }" :key =" item.type" >
58
+ <font-awesome-icon
59
+ @click =" showCode(item.type)"
60
+ inverse
61
+ :icon =" item.icon"
62
+ :style =" {
63
+ color: item.iconColor,
64
+ }"
65
+ size =" 10x"
66
+ class =" picture"
67
+ />
62
68
</div >
63
69
</div >
70
+ <codeBlock class =" code-block'" :code =" curShowCode" ></codeBlock >
64
71
</div >
65
72
</template >
66
73
<style lang="scss" scoped>
67
74
#advantage {
68
- .text-describe {
69
- .title-text {
70
- color : white ;
71
- }
72
- }
73
75
.advantages {
74
76
display : flex ;
75
77
flex-wrap : wrap ;
76
78
justify-content : center ;
77
79
align-items : center ;
78
80
.advantage-item {
79
- margin : 40px 0 ;
80
- position : relative ;
81
- }
82
- .text-describe {
83
- text-align : start ;
84
- font-size : 1.7vw ;
85
- }
86
- .picture {
81
+ margin : 10px 5vw ;
87
82
position : relative ;
88
- flex : 0 1 auto ;
89
- margin : 0 5vw ;
90
- background-color : #eee ;
91
- padding : 10px 24px ;
92
- border-radius : 50% ;
93
- cursor : pointer ;
94
- transition : all 0.7s ease ;
95
- // height: 30vw;
96
- }
97
- .code-block {
98
- width : calc (220px + 5vw );
99
- max-height : 220px ;
100
- transition : all 0.7s ease ;
101
- }
102
- @media (max-width : 800px ) {
103
- .advantage-item {
104
- margin : 10px 8vw ;
105
- .text-describe {
106
- font-size : 4vw ;
107
- width : 70% ;
108
- }
109
- .picture {
110
- margin : 0 auto 12px ;
111
- transform : scale (.9 );
112
- }
113
- .code-block {
114
- width : 60vw ;
115
- max-height : 220px ;
116
- transition : all 0.7s ease ;
83
+ .picture {
84
+ position : relative ;
85
+ flex : 0 1 auto ;
86
+ background-color : rgba (255 , 255 , 255 , 0.72 );
87
+ padding : 10px 26px ;
88
+ border-radius : 50% ;
89
+ cursor : pointer ;
90
+ transition : all 0.7s ease ;
91
+ margin : 0 auto 12px ;
92
+ transform : scale (0.9 );
93
+ & :hover {
94
+ background-color : #fff ;
117
95
}
96
+ // height: 30vw;
97
+ }
98
+ }
99
+
100
+ .selected-item {
101
+ .picture {
102
+ background-color : #fff ;
118
103
}
119
104
}
120
105
}
121
106
}
107
+
122
108
/* 下面我们会解释这些 class 是做什么的 */
123
109
.v-enter-active ,
124
110
.v-leave-active {
0 commit comments