npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue3-google-facebook-signin

v1.0.2

Published

[![npm](https://img.shields.io/npm/v/vue3-google-facebook-signin)](https://www.npmjs.com/package/vue3-google-facebook-signin) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/vue3-google-facebook-signin) ![npm](https://img.shields.io/npm/dw/v

Downloads

163

Readme

vue3-google-facebook-signin

npm npm bundle size npm NPM

海外第三方登录:facebook登录,google登录
(传入对应的Facebook应用的appId、谷歌应用的clientId即可)

安装

  • With NPM
npm install -S vue3-google-facebook-signin
  • With Yarn
yarn add vue3-google-facebook-signin
  • With PNPM
pnpm add vue3-google-facebook-signin

开始使用

使用示例

<template>
  <FacebookSignin 
    :appId="facebookAppId" 
    @success="onSignInSuccessFacebook"
    @error="onSignInErrorFacebook"
  >
    <span class="btn-primary">Facebook登录自定义样式按钮</span>
  </FacebookSignin>

  <GoogleSignin
    :clientId="clientId"
    @success="onSignInSuccessGoogle"
    @error="onSignInErrorGoogle"
  >
    <span class="btn-primary">Google登录自定义样式按钮</span>
  </GoogleSignin>
</template>
<script setup>
import { ref } from 'vue'
import { GoogleSignin, FacebookSignin } from 'vue3-google-facebook-signin'
/*
 * facebook登录,官方参考:https://developers.facebook.com/docs/facebook-login/web?locale=zh_CN
 * Facebook应用的appId
*/
const facebookAppId = ref('') // Facebook应用的appId
function onSignInSuccessFacebook(response) {
  // 成功回调数据,自行处理:response
  let facebookIdsStr = ''
  let facebookIdsList = []
  // 当存在多个userID时
  const userID = response.authResponse.userID
  if (userID) {
    window.FB.api(`/${userID}/ids_for_business`, function (response) {
      if (response && !response.error) {
        facebookIdsList = response.data
        facebookIdsList.map((item) => {
          facebookIdsStr = facebookIdsStr + item.id + ','
        })
        facebookIdsStr = facebookIdsStr.substring(
          0,
          facebookIdsStr.length - 1
        )
        console.log(facebookIdsList)
      }
    })
  } else {
    console.log('登录失败')
  }
}
function onSignInErrorFacebook(error) {
  console.log(error)
}

/*
 * google登录,官方参考:https://developers.google.com/identity/sign-in/web/reference?hl=zh-cn#googleusergetauthresponseincludeauthorizationdata
 * 谷歌应用的clientId
*/
const clientId = ref('') // 谷歌应用的clientId
function onSignInSuccessGoogle(idToken) {
  console.log(idToken)
}
function onSignInErrorGoogle(error) {
  console.log(error)
}

</script>
  • 注意1:Facebook的登录,需要在Facebook的后台配置 JavaScript SDK 允许使用的网域,官网后台:https://developers.facebook.com/

  • 注意2:Google的登录,需要在Google的后台控制台 “Web 应用”的客户端 ID处 配置 已获授权的网域,已获授权的javascript来源,已获授权的重定向 URL,官网后台:https://console.developers.google.com/