|
@@ -5,8 +5,27 @@ import { useMainStore } from "@/stores/main";
|
|
|
import { useDisplay } from "vuetify";
|
|
|
import { storeToRefs } from "pinia";
|
|
|
import { useI18n } from "vue-i18n";
|
|
|
+import { googleTokenLogin } from "vue3-google-login";
|
|
|
+import { saveLocalToken } from "@/utils";
|
|
|
import Navbar from "@/components/Navbar.vue";
|
|
|
|
|
|
+const GOOGLE_CLIENT_ID =
|
|
|
+ "136107811725-n71808u8t465f1afhpe2e5j7mn606nd8.apps.googleusercontent.com";
|
|
|
+
|
|
|
+const data = ref();
|
|
|
+
|
|
|
+const handleGoogleAccessTokenLogin = () => {
|
|
|
+ googleTokenLogin({
|
|
|
+ clientId: GOOGLE_CLIENT_ID,
|
|
|
+ }).then((response: any) => {
|
|
|
+ console.log("Google response", response);
|
|
|
+ console.log("response.access_token", response.access_token);
|
|
|
+ data.value = response;
|
|
|
+ saveLocalToken(response.access_token);
|
|
|
+ mainStore.setToken(response.access_token);
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
const mainStore = useMainStore();
|
|
|
const mainStoreRef = storeToRefs(mainStore);
|
|
|
|
|
@@ -40,7 +59,7 @@ function submit() {
|
|
|
|
|
|
// lifecycle
|
|
|
onMounted(() => {
|
|
|
- console.log('onMounted');
|
|
|
+ console.log("onMounted");
|
|
|
});
|
|
|
</script>
|
|
|
|
|
@@ -95,16 +114,67 @@ onMounted(() => {
|
|
|
}}</router-link>
|
|
|
</p>
|
|
|
|
|
|
- <v-btn
|
|
|
- rounded="pill"
|
|
|
- color="primary"
|
|
|
- @click.prevent="submit"
|
|
|
- class="login-btn"
|
|
|
- >
|
|
|
- {{ t("loginLink") }}
|
|
|
- </v-btn>
|
|
|
+ <div class="d-flex flex-column">
|
|
|
+ <v-btn
|
|
|
+ rounded="pill"
|
|
|
+ color="primary"
|
|
|
+ @click.prevent="submit"
|
|
|
+ class="login-btn"
|
|
|
+ >
|
|
|
+ {{ t("loginLink") }}
|
|
|
+ </v-btn>
|
|
|
+
|
|
|
+ <section class="line">
|
|
|
+ <p> 快速登入 </p>
|
|
|
+ <span></span>
|
|
|
+ </section>
|
|
|
+
|
|
|
+ <v-btn
|
|
|
+ class="google-btn"
|
|
|
+ type="button"
|
|
|
+ @click="handleGoogleAccessTokenLogin"
|
|
|
+ rounded="pill"
|
|
|
+ >
|
|
|
+ <img src="@/assets/img/google.png" alt="" />
|
|
|
+ 使用 Google 進行登入
|
|
|
+ </v-btn>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <!-- <button type="button" @click="handleGoogleAccessTokenLogin">
|
|
|
+ 使用 Google 進行登入
|
|
|
+ </button> -->
|
|
|
</v-form>
|
|
|
</v-col>
|
|
|
</v-row>
|
|
|
</v-container>
|
|
|
</template>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.line {
|
|
|
+ margin-top: 50px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ position: relative;
|
|
|
+ p {
|
|
|
+ position: relative;
|
|
|
+ z-index: 1;
|
|
|
+ color: #888888;
|
|
|
+ background-color: #fff;
|
|
|
+ }
|
|
|
+ span {
|
|
|
+ display: block;
|
|
|
+ border-top: 1px solid #888888;
|
|
|
+ width: 280px;
|
|
|
+ position: absolute;
|
|
|
+ bottom: 12px;
|
|
|
+ }
|
|
|
+}
|
|
|
+.google-btn {
|
|
|
+ margin-top: 20px;
|
|
|
+ background-color: #fff;
|
|
|
+ img {
|
|
|
+ width: 20px;
|
|
|
+ margin-right: 10px;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|