From 29b69d5138782090e1db42353c187c76a9341569 Mon Sep 17 00:00:00 2001 From: Wayne Date: Thu, 28 Sep 2023 03:30:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E9=A6=96=E9=A0=81=E5=BB=A3?= =?UTF-8?q?=E5=91=8A=E5=BD=88=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- src/main.js | 20 +- src/utils/liff.js | 11 + src/views/Home/index.vue | 324 +++++++++++---------- src/views/Register/index.vue | 525 ++++++++++++++++++----------------- 5 files changed, 473 insertions(+), 409 deletions(-) create mode 100644 src/utils/liff.js diff --git a/.env.development b/.env.development index d25b245..ab9b223 100644 --- a/.env.development +++ b/.env.development @@ -4,7 +4,7 @@ VUE_ENV = stage VUE_APP_BASE_URL = https://utel.zltest.com.tw -VUE_APP_LINE_LIFF_ID = 1656948609-xMp7dWAz +VUE_APP_LINE_LIFF_ID = 1656907652-p38ddKzQ VUE_APP_SEND_URL = https://liff.line.me/1656948609-BYr8Nynp diff --git a/src/main.js b/src/main.js index 634cc1d..2a231c4 100644 --- a/src/main.js +++ b/src/main.js @@ -3,6 +3,7 @@ import App from "./App.vue"; import router from "./router"; import store from "./store"; +import liff from '@line/liff'; import { vant } from "@/plugins/vant"; import { VueClipboard } from "@soerenmartius/vue3-clipboard"; @@ -10,8 +11,19 @@ import "@/assets/css/normalize.css"; import "@/assets/css/common.less"; // import './registerServiceWorker' -const vue = createApp(App); +liff.init({ + liffId: process.env.VUE_APP_LINE_LIFF_ID + }).then(() => { -vant(vue); -vue.use(VueClipboard); -vue.use(store).use(router).mount("#app"); + window.liff = liff; + + const vue = createApp(App); + + // 將LIFF實例提供給應用 + vant(vue); + vue.use(VueClipboard); + vue.use(store).use(router).mount("#app"); + + }).catch((error) => { + console.error('初始化 LIFF 時出錯:', error); + }); diff --git a/src/utils/liff.js b/src/utils/liff.js new file mode 100644 index 0000000..ec10cb1 --- /dev/null +++ b/src/utils/liff.js @@ -0,0 +1,11 @@ +import liff from "@line/liff"; + +async function initLiff(app) { + await liff.init({ liffId: process.env.VUE_APP_LINE_LIFF_ID }); + if (!liff.isLoggedIn()){ + liff.login({ redirectUri: window.location.href }); + } + app.provide('liff', liff); +} + +export default initLiff; \ No newline at end of file diff --git a/src/views/Home/index.vue b/src/views/Home/index.vue index 5942881..09c4a02 100644 --- a/src/views/Home/index.vue +++ b/src/views/Home/index.vue @@ -1,151 +1,10 @@ - - + + \ No newline at end of file diff --git a/src/views/Register/index.vue b/src/views/Register/index.vue index 72c45fb..8ee72f5 100644 --- a/src/views/Register/index.vue +++ b/src/views/Register/index.vue @@ -1,330 +1,343 @@ - - \ No newline at end of file +} +