Jelajahi Sumber

feat: 增加share

sunxiao 2 minggu lalu
induk
melakukan
00e0b0873f
2 mengubah file dengan 33 tambahan dan 0 penghapusan
  1. 4 0
      src/main.js
  2. 29 0
      src/utils/wxShare.js

+ 4 - 0
src/main.js

@@ -1,4 +1,6 @@
 import { createSSRApp } from "vue";
+import share from './utils/wxShare';
+
 import pinia from "./stores";
 
 import App from "./App.vue";
@@ -8,5 +10,7 @@ export function createApp() {
 
   app.use(pinia);
 
+  app.mixin(share);
+
   return { app };
 }

+ 29 - 0
src/utils/wxShare.js

@@ -0,0 +1,29 @@
+export default {
+  data() {
+    return {
+      share: {
+        title: 'LibraAI智能体运营平台',
+        path: '/pages/home/index',
+        imageUrl: null
+      }
+    };
+  },
+  onShareAppMessage(res) {
+    // const pages = getCurrentPages();
+    // const currentPage = pages[pages.length - 1];
+    // this.share.path = `/${currentPage.route}`; // 动态设置当前页面路径
+    // return this.share;
+    return {
+			title: this.share.title,
+			path: this.share.path,
+			imageUrl: this.share.imageUrl,
+		}
+  },
+  onShareTimeline() {
+    return {
+			title: this.share.title,
+			path: this.share.path,
+			imageUrl: this.share.imageUrl,
+		}
+  }
+};