Skip to content

Commit

Permalink
feat: 增加一键复制分享链接按钮
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Feb 9, 2025
1 parent 15b4c27 commit a313580
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store-front-end",
"version": "2.14.327",
"version": "2.14.329",
"private": true,
"scripts": {
"dev": "vite --host",
Expand Down
21 changes: 20 additions & 1 deletion src/components/ShareListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
<button class="copy-sub-link" @click.stop="onClickShareLink">
<font-awesome-icon icon="fa-solid fa-link" />
</button>
<button class="copy-sub-link" @click.stop="onClickCopyLink">
<font-awesome-icon icon="fa-solid fa-clone" />
</button>
<!-- 编辑 -->
<button class="refresh-sub-flow" @click.stop="onClickEdit">
<font-awesome-icon icon="fa-solid fa-pen-nib" />
Expand Down Expand Up @@ -123,6 +126,8 @@
</template>

<script lang="ts" setup>
import { useClipboard } from "@vueuse/core";
import useV3Clipboard from "vue-clipboard3";
import { Dialog, Toast } from "@nutui/nutui";
import dayjs from "dayjs";
import { storeToRefs } from "pinia";
Expand All @@ -138,14 +143,17 @@ import { useSettingsStore } from "@/store/settings";
import { useSubsStore } from "@/store/subs";
import { isMobile } from "@/utils/isMobile";
import { useRouter } from "vue-router";
import { useAppNotifyStore } from "@/store/appNotify";
const { showNotify } = useAppNotifyStore();
const router = useRouter();
const props = defineProps<{
data: Share;
disabled?: boolean;
}>();
const emit = defineEmits(["detail", "delete"]);
const { copy, isSupported } = useClipboard();
const { toClipboard: copyFallback } = useV3Clipboard();
const { t } = useI18n();
const { env } = useBackend();
const scrollTop = 0;
Expand Down Expand Up @@ -246,6 +254,17 @@ const getOneShareOrigin = async (keyName: string) => {
}
};
const onClickCopyLink = async () => {
const url = getShareUrl();
console.log('url', url);
if (isSupported) {
await copy(url);
} else {
await copyFallback(url);
}
showNotify({ title: t("sharePage.copyShare.succeedNotify") });
};
const onClickShareLink = async () => {
try {
const keyName = encodeURIComponent(name.value);
Expand Down

0 comments on commit a313580

Please sign in to comment.