1
1
<template >
2
2
<n-tabs animated trigger =" hover" size =" large" >
3
3
<n-tab-pane
4
- v-for =" (protocol , index) of permed_protocols "
4
+ v-for =" (connectType , index) of connectConnectTypeComputed "
5
5
:key =" index"
6
- :name =" protocol .name"
7
- :tab =" protocol .name.toUpperCase()"
6
+ :name =" connectType .name"
7
+ :tab =" connectType .name.toUpperCase()"
8
8
>
9
9
<n-form ref =" formRef" size =" large" label-placement =" top" >
10
10
<n-grid :cols =" 24" :x-gap =" 24" >
11
- <n-form-item-gi :span =" 24" :label =" t('Select account')" >
11
+ <!-- 账号选择 -->
12
+ <n-form-item-gi
13
+ :span =" 24"
14
+ :label =" t('Select account')"
15
+ :label-style =" { letterSpacing: '0.7px' }"
16
+ >
12
17
<n-select
13
18
v-model:value =" model.selectValue"
19
+ size =" medium"
14
20
:placeholder =" t('Select account')"
15
21
:options =" assetCount"
16
22
/>
17
23
</n-form-item-gi >
18
24
19
- <n-form-item-gi :span =" 24" :label =" t('Password')" >
25
+ <!-- 密码 -->
26
+ <n-form-item-gi
27
+ :span =" 24"
28
+ :label =" t('Password')"
29
+ :label-style =" { letterSpacing: '0.7px' }"
30
+ >
20
31
<n-grid :cols =" 24" :x-gap =" 24" >
21
32
<n-grid-item :span =" 18" >
22
33
<n-input
23
34
v-model:value =" model.inputValue"
24
35
:placeholder =" t('Please input password')"
25
36
clearable
37
+ size =" medium"
26
38
type =" password"
27
39
show-password-on =" mousedown"
28
40
/>
29
41
</n-grid-item >
30
- <n-grid-item :span =" 6" class =" remember-password" >
31
- <n-checkbox >{{ t('Remember password') }}</n-checkbox >
42
+ <n-grid-item
43
+ :span =" 6"
44
+ :style =" { display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }"
45
+ >
46
+ <n-checkbox size =" medium" >{{ t('Remember password') }}</n-checkbox >
32
47
</n-grid-item >
33
48
</n-grid >
34
49
</n-form-item-gi >
50
+
51
+ <!-- 连接方式 -->
52
+ <n-form-item-gi
53
+ :span =" 24"
54
+ :label =" t('Connect method')"
55
+ :label-style =" { letterSpacing: '0.7px' }"
56
+ >
57
+ <n-card >
58
+ <n-tabs animated size =" medium" justify-content =" center" type =" segment" >
59
+ <n-tab-pane
60
+ v-for =" (method, methodIndex) of connectType.connectMethods"
61
+ :name =" method.label"
62
+ :key =" methodIndex"
63
+ >
64
+ <n-radio-group v-model:value =" model.checkedValue" >
65
+ <n-space >
66
+ <n-radio
67
+ v-for =" (item, indexItem) of method.methods"
68
+ :key =" indexItem"
69
+ :value =" item.value"
70
+ size =" medium"
71
+ >
72
+ {{ item.label }}
73
+ </n-radio >
74
+ </n-space >
75
+ </n-radio-group >
76
+ </n-tab-pane >
77
+ </n-tabs >
78
+ </n-card >
79
+ </n-form-item-gi >
80
+
81
+ <!-- 高级选项 -->
82
+ <n-form-item-gi
83
+ :span =" 24"
84
+ :label-style =" { letterSpacing: '0.7px' }"
85
+ :class =" showAdvanced ? 'advanced-option' : ''"
86
+ >
87
+ <template #label >
88
+ <n-grid :cols =" 24" :x-gap =" 24" >
89
+ <n-grid-item :span =" 22" >
90
+ <span >{{ t('Advanced option') }}</span >
91
+ </n-grid-item >
92
+ <n-grid-item
93
+ :span =" 2"
94
+ :style =" { display: 'flex', justifyContent: 'flex-end', cursor: 'pointer' }"
95
+ >
96
+ <n-icon :size =" 16" @click =" handleShowAdvanced" >
97
+ <ArrowUp v-if =" showAdvanced" />
98
+ <ArrowDown v-else />
99
+ </n-icon >
100
+ </n-grid-item >
101
+ </n-grid >
102
+ </template >
103
+
104
+ <n-card
105
+ v-show =" !showAdvanced"
106
+ :title =" t('Backspace as Ctrl+H')"
107
+ :header-style =" { fontSize: '12px !important' }"
108
+ >
109
+ <n-select
110
+ v-model:value =" model.backspaceAsCtrlH"
111
+ size =" medium"
112
+ :placeholder =" t('Select account')"
113
+ :options =" backspaceOptions"
114
+ />
115
+ </n-card >
116
+ </n-form-item-gi >
117
+
118
+ <!-- 记住选择-->
119
+ <n-form-item-gi
120
+ :span =" 24"
121
+ :label-style =" { letterSpacing: '0.7px' }"
122
+ class =" remember-select"
123
+ >
124
+ <template #label >
125
+ <n-grid :cols =" 24" >
126
+ <n-grid-item :span =" 12" >
127
+ <span >{{ t('Remember select') }}</span >
128
+ </n-grid-item >
129
+ <n-grid-item
130
+ :span =" 12"
131
+ :style =" { display: 'flex', justifyContent: 'flex-end', cursor: 'pointer' }"
132
+ >
133
+ <n-checkbox size =" medium" >
134
+ <n-text :style =" { fontSize: '12px !important' }" >
135
+ {{ t('Automatic login next') }}
136
+ </n-text >
137
+ </n-checkbox >
138
+ </n-grid-item >
139
+ </n-grid >
140
+ </template >
141
+ </n-form-item-gi >
142
+
143
+ <!-- 连接按钮-->
144
+ <n-form-item-gi :span =" 24" justify =" center" >
145
+ <n-button type =" primary" round style =" width : 100% " size =" medium" >
146
+ {{ t('Connect') }}
147
+ </n-button >
148
+ </n-form-item-gi >
35
149
</n-grid >
36
150
</n-form >
37
151
</n-tab-pane >
38
152
</n-tabs >
39
153
</template >
40
154
41
155
<script setup lang="ts">
42
- import { computed , reactive } from ' vue' ;
156
+ import { computed , reactive , ref } from ' vue' ;
157
+
43
158
import { useI18n } from ' vue-i18n' ;
159
+ import { storeToRefs } from ' pinia' ;
160
+ import { ArrowDown , ArrowUp } from ' @vicons/ionicons5' ;
161
+ import { useGlobalStore } from ' @/stores/modules/global.ts' ;
44
162
45
163
const { t } = useI18n ();
164
+ const globalStore = useGlobalStore ();
165
+ const { connectMethods } = storeToRefs (globalStore );
166
+
167
+ interface Protocol {
168
+ name: string ;
169
+ port: number ;
170
+ public: boolean ;
171
+ setting: {
172
+ sftp_enabled: boolean ;
173
+ sftp_home: string ;
174
+ };
175
+ }
176
+
177
+ interface connectMethodItem {
178
+ component: string ;
179
+ endpoint_protocol: string ;
180
+ label: string ;
181
+ type: string ;
182
+ value: string ;
183
+ }
46
184
47
185
const props = defineProps <{
48
186
id: string ;
49
187
permedAccounts: any ;
50
188
permedProtocols: any ;
51
189
}>();
52
190
191
+ console .log (' props' , props );
192
+ console .log (' connectMethods' , connectMethods .value );
193
+
194
+ const model = reactive ({
195
+ inputValue: ' ' ,
196
+ selectValue: null ,
197
+ checkedValue: null ,
198
+ backspaceAsCtrlH: true
199
+ });
200
+
201
+ const showAdvanced = ref (false );
202
+
203
+ const connectMethodTypes = [
204
+ { value: ' web' , label: ' Web' , methods: [] },
205
+ { value: ' native' , label: t (' Native' ), methods: [] },
206
+ { value: ' applet' , label: t (' Applet' ), methods: [] },
207
+ { value: ' virtual_app' , label: t (' VirtualApp' ), methods: [] }
208
+ ];
209
+
53
210
const assetCount = computed (() => {
54
211
// todo)) 类型
55
212
const tempArr = [];
@@ -62,18 +219,69 @@ const assetCount = computed(() => {
62
219
63
220
return tempArr ! ;
64
221
});
222
+ const backspaceOptions = [
223
+ {
224
+ label: ' 是' ,
225
+ value: true
226
+ },
227
+ {
228
+ label: ' 否' ,
229
+ value: false
230
+ }
231
+ ];
65
232
66
- console .log (assetCount );
67
- console .log (props );
233
+ // 整合 连接方式 tab 数据
234
+ const connectConnectTypeComputed = computed (() => {
235
+ return props .permedProtocols .map ((protocol : Protocol ) => {
236
+ const filteredConnectMethods = connectMethodTypes
237
+ .map (type => {
238
+ return {
239
+ ... type ,
240
+ methods: connectMethods .value [protocol .name ].filter (
241
+ (method : connectMethodItem ) => type .value === method .type
242
+ )
243
+ };
244
+ })
245
+ .filter (type => type .methods .length > 0 );
68
246
69
- const model = reactive ({
70
- inputValue: ' ' ,
71
- selectValue: null
247
+ return {
248
+ name: protocol .name ,
249
+ connectMethods: filteredConnectMethods
250
+ };
251
+ });
72
252
});
253
+
254
+ const handleShowAdvanced = () => {
255
+ showAdvanced .value = ! showAdvanced .value ;
256
+ };
257
+
258
+ console .log (' connectConnectTypeComputed' , connectConnectTypeComputed );
73
259
</script >
74
260
75
261
<style scoped lang="scss">
76
- .remember-password {
262
+ :deep(.n-form-item-feedback-wrapper ) {
263
+ min-height : 20px ;
264
+ }
265
+
266
+ // 高级选项部分样式修改
267
+ :deep(.advanced-option ) {
268
+ .n-form-item-label {
269
+ margin-bottom : 25px ;
270
+ }
271
+ .n-form-item-blank ,
272
+ .n-form-item-feedback-wrapper {
273
+ display : none !important ;
274
+ }
275
+ }
276
+
277
+ // 记住选择样式修改
278
+ :deep(.remember-select ) {
279
+ .n-form-item-blank {
280
+ display : none ;
281
+ }
282
+ }
283
+ .remember-password ,
284
+ .advanced_option {
77
285
display : flex ;
78
286
align-items : center ;
79
287
justify-content : flex-end ;
0 commit comments