11<template >
22 <!-- 滚动内容 -->
3- <nut-swipe ref =" swipe" class =" sub-item-swipe" :disabled =" props.disabled" >
3+ <nut-swipe
4+ ref =" swipe"
5+ class =" sub-item-swipe"
6+ :disabled =" props.disabled"
7+ @close =" setIsMoveClose()"
8+ @open =" setIsMoveOpen()"
9+ @click =" onClickPreviews()"
10+ >
411 <div
512 class =" sub-item-wrapper"
613 :style =" { padding: appearanceSetting.isSimpleMode ? '9px' : '16px' }"
@@ -123,6 +130,7 @@ import { computed, createVNode, ref } from "vue";
123130import { useI18n } from " vue-i18n" ;
124131import logoIcon from " @/assets/icons/logo.png" ;
125132import logoRedIcon from " @/assets/icons/logo-red.png" ;
133+ import PreviewPanel from " @/components/PreviewPanel.vue" ;
126134import { useBackend } from " @/hooks/useBackend" ;
127135import { useHostAPI } from " @/hooks/useHostAPI" ;
128136import { usePopupRoute } from " @/hooks/usePopupRoute" ;
@@ -157,7 +165,7 @@ const name = computed(() => {
157165
158166const displayName = computed (() => {
159167 return props ?.data ?.displayName ;
160- })
168+ });
161169const remark = computed (() => {
162170 return props ?.data ?.remark ;
163171});
@@ -236,23 +244,26 @@ const getOneShareOrigin = async (keyName: string) => {
236244 case " file" :
237245 return subsStore .getOneFile (keyName );
238246 }
239- }
247+ };
248+
240249const onClickShareLink = async () => {
241- console .log (" props" , props );
242- const keyName = encodeURIComponent (name .value );
243- const item = await getOneShareOrigin (keyName );
244- console .log (' item' , item )
245- if (! item ) {
246- return Toast .text (t (" sharePage.noOriginalTips" ));
247- }
248- if (type .value === ' file' ) {
249- router .push (` /edit/files/${keyName } ` );
250- }
251- if (type .value === ' sub' ) {
252- router .push (` /edit/subs/${keyName } ` );
253- }
254- if (type .value === ' col' ) {
255- router .push (` /edit/collections/${keyName } ` );
250+ try {
251+ const keyName = encodeURIComponent (name .value );
252+ const item = await getOneShareOrigin (keyName );
253+ if (! item ) {
254+ return Toast .text (t (" sharePage.noOriginalTips" ));
255+ }
256+ if (type .value === " file" ) {
257+ router .push (` /edit/files/${keyName } ` );
258+ }
259+ if (type .value === " sub" ) {
260+ router .push (` /edit/subs/${keyName } ` );
261+ }
262+ if (type .value === " col" ) {
263+ router .push (` /edit/collections/${keyName } ` );
264+ }
265+ } catch (error ) {
266+ console .error (error );
256267 }
257268};
258269
@@ -276,6 +287,82 @@ const onClickDelete = () => {
276287 });
277288};
278289
290+ const ismove = ref (false );
291+
292+ // 增加延迟防止打开时 触发不了
293+ const setTimeoutTF = () => {
294+ setTimeout (() => {
295+ ismove .value = false ;
296+ }, 200 );
297+ };
298+
299+ const setIsMoveOpen = () => {
300+ ismove .value = true ;
301+ setTimeoutTF ();
302+ };
303+
304+ const setIsMoveClose = () => {
305+ ismove .value = true ;
306+ setTimeoutTF ();
307+ };
308+
309+ const secretPath = computed (() => {
310+ return env .value ?.meta ?.node ?.env ?.SUB_STORE_FRONTEND_BACKEND_PATH || " " ;
311+ });
312+
313+ const getShareUrl = () => {
314+ try {
315+ const { type, name, token } = props .data ;
316+ const shareUrl = ` ${host .value .replace (
317+ new RegExp (` ${secretPath .value }$ ` ),
318+ " " ,
319+ )}/share/${type }/${encodeURIComponent (name )}?token=${encodeURIComponent (
320+ token ,
321+ )} ` ;
322+ return shareUrl ;
323+ } catch (error ) {
324+ console .error (error );
325+ return " " ;
326+ }
327+ };
328+ const onClickPreviews = () => {
329+ console .log (' name' , name .value );
330+ console .log (' props' , props .data );
331+ if (type .value === " file" ) {
332+ return ;
333+ }
334+ if (ismove .value ) {
335+ return false ;
336+ }
337+ swipeController ();
338+ const url = getShareUrl ();
339+ console .log (' url' , url );
340+ Dialog ({
341+ title: t (" subPage.previewTitle" ),
342+ content: createVNode (PreviewPanel , {
343+ name ,
344+ type: " share" ,
345+ url ,
346+ general: t (" subPage.panel.general" ),
347+ notify: t (" subPage.copyNotify.succeed" ),
348+ tipsTitle: t (` subPage.panel.tips.title ` ),
349+ tipsContent: ` ${t (" subPage.panel.tips.content" )}\n ${t (
350+ " syncPage.addArtForm.includeUnsupportedProxy.tips.content" ,
351+ )} ` ,
352+ desc: t (` subPage.panel.tips.desc ` ),
353+ tipsOkText: t (` subPage.panel.tips.ok ` ),
354+ tipsCancelText: t (` subPage.panel.tips.cancel ` ),
355+ }),
356+ onOpened : () => swipe .value .close (),
357+ popClass: " auto-dialog" ,
358+ // @ts-ignore
359+ closeOnClickOverlay: true ,
360+ noOkBtn: true ,
361+ noCancelBtn: true ,
362+ closeOnPopstate: true ,
363+ lockScroll: false ,
364+ });
365+ };
279366 </script >
280367
281368<style lang="scss" scoped>
0 commit comments