11<script setup lang="ts">
2- import type { SuggestionUser } from " @/lion/api " ;
2+ import type { SessionShareAdapter , SessionShareUser } from " @jumpserver/connectors-core " ;
33import { useKokoSessionAdapter } from " #koko" ;
44import { getLionWorkspaceSession } from " @/lion/workspaces/useLionWorkspaceSessionRegistry" ;
55
@@ -14,22 +14,21 @@ const activeSessionId = computed(() => {
1414 return tab ?.panes .find ((pane ) => pane .id === activePaneId .value )?.id || tab ?.id || " " ;
1515});
1616const kokoAdapter = useKokoSessionAdapter (activeSessionId );
17- const lionAdapter = computed (() => getLionWorkspaceSession (activeSessionId .value )?.share || null );
18- const onlineUsers = computed (() => lionAdapter .value ?.onlineUsers .value || kokoAdapter .onlineUsers .value );
19- const shareInfo = computed (() => lionAdapter .value ?.shareInfo .value || kokoAdapter .shareInfo .value );
20- const userOptions = computed <SuggestionUser []>(
21- () => (lionAdapter .value ?.userOptions .value || kokoAdapter .userOptions .value ) as SuggestionUser []
17+ const adapter = computed <SessionShareAdapter >(
18+ () => getLionWorkspaceSession (activeSessionId .value )?.share || kokoAdapter
2219);
23- const hasMoreUsers = computed (() => Boolean (lionAdapter .value ?.hasMoreUsers .value ));
24- const adapterKey = computed (() => ` ${lionAdapter .value ? " lion" : " koko" }:${activeSessionId .value } ` );
20+ const onlineUsers = computed (() => adapter .value .onlineUsers .value );
21+ const shareInfo = computed (() => adapter .value .shareInfo .value );
22+ const userOptions = computed (() => adapter .value .userOptions .value );
23+ const hasMoreUsers = computed (() => adapter .value .hasMoreUsers .value );
2524
2625const shareModalOpen = ref (false );
2726const shareUserMenuOpen = ref (false );
2827const searchLoading = ref (false );
2928const showLinkResult = ref (false );
3029const searchQuery = ref (" " );
3130const selectedUserIds = ref <string []>([]);
32- const selectedUsers = ref <Record <string , SuggestionUser >>({});
31+ const selectedUsers = ref <Record <string , SessionShareUser >>({});
3332
3433const shareLinkRequest = reactive ({
3534 expiredTime: 10 ,
@@ -100,7 +99,7 @@ watch(
10099 }
101100);
102101
103- watch (adapterKey , () => {
102+ watch ([ activeSessionId , adapter ] , () => {
104103 shareModalOpen .value = false ;
105104 shareUserMenuOpen .value = false ;
106105 showLinkResult .value = Boolean (shareInfo .value .shareCode );
@@ -129,12 +128,7 @@ watch(selectedUserIds, (ids) => cacheSelectedUsers(ids));
129128
130129async function runSearch(query : string , loadMore = false ) {
131130 searchLoading .value = true ;
132- const lion = lionAdapter .value ;
133- if (! lion ) {
134- kokoAdapter .searchUsers (query );
135- return ;
136- }
137- await lion .searchUsers (query , loadMore );
131+ await adapter .value .searchUsers (query , loadMore );
138132 searchLoading .value = false ;
139133}
140134
@@ -145,10 +139,10 @@ watch(searchQuery, (query) => {
145139 debouncedSearch (query );
146140});
147141
148- const selectedShareUsers = computed <SuggestionUser []>(() =>
142+ const selectedShareUsers = computed <SessionShareUser []>(() =>
149143 selectedUserIds .value
150144 .map ((id ) => selectedUsers .value [id ] || userOptions .value .find ((item ) => item .id === id ))
151- .filter ((item ): item is SuggestionUser => Boolean (item ))
145+ .filter ((item ): item is SessionShareUser => Boolean (item ))
152146);
153147
154148function openShareModal() {
@@ -167,29 +161,25 @@ function handleCreateLink() {
167161 actionPerm: shareLinkRequest .actionPerm ,
168162 users: selectedShareUsers .value
169163 };
170- if (lionAdapter .value ) void lionAdapter .value .createShareLink (request );
171- else kokoAdapter .createShareLink (request );
164+ void adapter .value .createShareLink (request );
172165}
173166
174167function handleRemoveShareUser(userId : string ) {
175168 const user = onlineUsers .value .find ((item ) => item .user_id === userId && ! item .primary );
176169 if (! user ) return ;
177- if (lionAdapter .value ) void lionAdapter .value .removeShareUser (user );
178- else kokoAdapter .removeShareUser (user as any );
170+ void adapter .value .removeShareUser (user );
179171}
180172
181173function handleBack() {
182- if (lionAdapter .value ) lionAdapter .value .resetShareState ();
183- else kokoAdapter .resetShareState ();
174+ adapter .value .resetShareState ();
184175 showLinkResult .value = false ;
185176 selectedUserIds .value = [];
186177 selectedUsers .value = {};
187178 searchQuery .value = " " ;
188179}
189180
190181function handleCopyShareURL() {
191- if (lionAdapter .value ) void lionAdapter .value .copyShareURL ();
192- else kokoAdapter .copyShareURL ();
182+ void adapter .value .copyShareURL ();
193183}
194184 </script >
195185
0 commit comments