Files
WAI_Project_UNIX/pages/demo/other/share.uvue
2025-10-30 19:28:09 +08:00

74 lines
1.5 KiB
Plaintext

<template>
<cl-page>
<view class="p-3">
<demo-item :label="t('分享文本')">
<cl-button @tap="shareText">{{ t("分享文本") }}</cl-button>
</demo-item>
<demo-item :label="t('分享图片')">
<cl-button @tap="shareImage">{{ t("分享图片") }}</cl-button>
</demo-item>
<demo-item :label="t('分享文件')">
<cl-button @tap="shareFile">{{ t("分享文件") }}</cl-button>
</demo-item>
<demo-item :label="t('分享链接')">
<cl-button @tap="shareLink">{{ t("分享链接") }}</cl-button>
</demo-item>
</view>
</cl-page>
</template>
<script lang="ts" setup>
import { shareWithSystem } from "@/uni_modules/cool-share";
import DemoItem from "../components/item.uvue";
import { t } from "@/locale";
function shareText() {
shareWithSystem({
type: "text",
title: "Cool Unix 是一个高效的项目脚手架",
summary: "",
success: () => {
console.log("success");
},
fail: (error) => {
console.log("fail", error);
}
});
}
function shareImage() {
shareWithSystem({
type: "image",
imageUrl: "https://cool-js.com/logo.png",
success: () => {
console.log("success");
}
});
}
function shareFile() {
shareWithSystem({
type: "file",
href: "https://show.cool-admin.com/用户导入模版.xlsx",
success: () => {
console.log("success");
}
});
}
function shareLink() {
shareWithSystem({
type: "link",
href: "https://cool-js.com/",
success: () => {
console.log("success");
}
});
}
</script>
<style lang="scss" scoped></style>