Sfoglia il codice sorgente

update google login

SyuanYu 2 anni fa
parent
commit
bfa4f1b006
4 ha cambiato i file con 32 aggiunte e 4 eliminazioni
  1. 1 1
      frontend/.gitignore
  2. 0 1
      frontend/index.html
  3. 30 2
      frontend/src/views/Login.vue
  4. 1 0
      frontend/tsconfig.app.json

+ 1 - 1
frontend/.gitignore

@@ -6,7 +6,7 @@ yarn-debug.log*
 yarn-error.log*
 pnpm-debug.log*
 lerna-debug.log*
-
+/node_modules
 node_modules
 .DS_Store
 dist

+ 0 - 1
frontend/index.html

@@ -9,7 +9,6 @@
   <meta http-equiv="cache-control" content="no-cache">
   <meta http-equiv="pragma" content="no-cache">
   <meta http-equiv="expires" content="0">
-
   <title>Vite App</title>
 </head>
 

+ 30 - 2
frontend/src/views/Login.vue

@@ -6,10 +6,29 @@ import { useDisplay } from "vuetify";
 import { storeToRefs } from "pinia";
 import { useI18n } from "vue-i18n";
 import Navbar from "@/components/Navbar.vue";
+import { googleTokenLogin } from "vue3-google-login";
+
+const GOOGLE_CLIENT_ID =
+  "136107811725-n71808u8t465f1afhpe2e5j7mn606nd8.apps.googleusercontent.com";
+
+const data = ref();
+
+const handleGoogleAccessTokenLogin = () => {
+  googleTokenLogin({
+    clientId: GOOGLE_CLIENT_ID,
+  }).then((response) => {
+    console.log("Google response", response);
+    data.value = response;
+  });
+};
 
 const mainStore = useMainStore();
 const mainStoreRef = storeToRefs(mainStore);
 
+const callback = (response: any) => {
+  console.log("Google response", response);
+};
+
 // variable
 const email = ref("");
 const password = ref("");
@@ -110,11 +129,20 @@ onMounted(() => {
               <span></span>
             </section>
 
-            <v-btn rounded="pill" @click.prevent="submit" class="google-btn">
+            <v-btn
+              class="google-btn"
+              type="button"
+              @click="handleGoogleAccessTokenLogin"
+              rounded="pill"
+            >
               <img src="@/assets/img/google.png" alt="" />
-              以 Google 帳號登入
+              使用 Google 進行登入
             </v-btn>
           </div>
+
+          <!-- <button type="button" @click="handleGoogleAccessTokenLogin">
+            使用 Google 進行登入
+          </button> -->
         </v-form>
       </v-col>
     </v-row>

+ 1 - 0
frontend/tsconfig.app.json

@@ -3,6 +3,7 @@
   "include": ["env.d.ts", "src/**/*", "src/**/*.vue", "src/**/*.json"],
   "exclude": ["src/**/__tests__/*"],
   "compilerOptions": {
+    "allowJs": true,
     "composite": true,
     "baseUrl": ".",
     "paths": {