添加全局分享
This commit is contained in:
20
src/hooks/useShare.ts
Normal file
20
src/hooks/useShare.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
export default function useShare() {
|
||||||
|
const miniShareOptions = reactive({
|
||||||
|
// 分享标题
|
||||||
|
title: '',
|
||||||
|
//页面 path,不建议直接配置分享哪个页面就配置哪个页面的路径,有些页面不建议分享,如订单页,所以默认都是分享首页
|
||||||
|
path: '/pages/index/index',
|
||||||
|
// 分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径。支持PNG及JPG。显示图片长宽比是 5:4
|
||||||
|
imageUrl: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
// 发送给朋友
|
||||||
|
onShareAppMessage() {
|
||||||
|
return {
|
||||||
|
...miniShareOptions,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,6 +4,7 @@ import App from './App.vue'
|
|||||||
import { routeInterceptor } from './router/interceptor'
|
import { routeInterceptor } from './router/interceptor'
|
||||||
import { requestInterceptor } from './http/interceptor'
|
import { requestInterceptor } from './http/interceptor'
|
||||||
import NavBar from '@/components/Navbar.vue'
|
import NavBar from '@/components/Navbar.vue'
|
||||||
|
import useShare from '@/hooks/useShare'
|
||||||
|
|
||||||
import store from './store'
|
import store from './store'
|
||||||
import '@/style/index.scss'
|
import '@/style/index.scss'
|
||||||
@ -25,6 +26,8 @@ export function createApp() {
|
|||||||
app.provide('navbarHeight', getNavBarHeight())
|
app.provide('navbarHeight', getNavBarHeight())
|
||||||
app.provide('capsuleOffset', getCapsuleOffset())
|
app.provide('capsuleOffset', getCapsuleOffset())
|
||||||
|
|
||||||
|
app.mixin(useShare())
|
||||||
|
|
||||||
return {
|
return {
|
||||||
app,
|
app,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user