Skip to content

Commit a313580

Browse files
committed
feat: 增加一键复制分享链接按钮
1 parent 15b4c27 commit a313580

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store-front-end",
3-
"version": "2.14.327",
3+
"version": "2.14.329",
44
"private": true,
55
"scripts": {
66
"dev": "vite --host",

src/components/ShareListItem.vue

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@
6464
<button class="copy-sub-link" @click.stop="onClickShareLink">
6565
<font-awesome-icon icon="fa-solid fa-link" />
6666
</button>
67+
<button class="copy-sub-link" @click.stop="onClickCopyLink">
68+
<font-awesome-icon icon="fa-solid fa-clone" />
69+
</button>
6770
<!-- 编辑 -->
6871
<button class="refresh-sub-flow" @click.stop="onClickEdit">
6972
<font-awesome-icon icon="fa-solid fa-pen-nib" />
@@ -123,6 +126,8 @@
123126
</template>
124127

125128
<script lang="ts" setup>
129+
import { useClipboard } from "@vueuse/core";
130+
import useV3Clipboard from "vue-clipboard3";
126131
import { Dialog, Toast } from "@nutui/nutui";
127132
import dayjs from "dayjs";
128133
import { storeToRefs } from "pinia";
@@ -138,14 +143,17 @@ import { useSettingsStore } from "@/store/settings";
138143
import { useSubsStore } from "@/store/subs";
139144
import { isMobile } from "@/utils/isMobile";
140145
import { useRouter } from "vue-router";
146+
import { useAppNotifyStore } from "@/store/appNotify";
141147
148+
const { showNotify } = useAppNotifyStore();
142149
const router = useRouter();
143150
const props = defineProps<{
144151
data: Share;
145152
disabled?: boolean;
146153
}>();
147154
const emit = defineEmits(["detail", "delete"]);
148-
155+
const { copy, isSupported } = useClipboard();
156+
const { toClipboard: copyFallback } = useV3Clipboard();
149157
const { t } = useI18n();
150158
const { env } = useBackend();
151159
const scrollTop = 0;
@@ -246,6 +254,17 @@ const getOneShareOrigin = async (keyName: string) => {
246254
}
247255
};
248256
257+
const onClickCopyLink = async () => {
258+
const url = getShareUrl();
259+
console.log('url', url);
260+
if (isSupported) {
261+
await copy(url);
262+
} else {
263+
await copyFallback(url);
264+
}
265+
showNotify({ title: t("sharePage.copyShare.succeedNotify") });
266+
};
267+
249268
const onClickShareLink = async () => {
250269
try {
251270
const keyName = encodeURIComponent(name.value);

0 commit comments

Comments
 (0)