Browse Source

新增 云开发匿名登录

wangzhihui 4 năm trước cách đây
mục cha
commit
96ad9247a5
3 tập tin đã thay đổi với 19 bổ sung1 xóa
  1. 1 0
      index.html
  2. 2 1
      package.json
  3. 16 0
      src/apis/cloudLogin.js

+ 1 - 0
index.html

@@ -9,6 +9,7 @@
       src="https://map.qq.com/api/gljs?v=1.exp&key=Y2BBZ-IHRKU-V42VO-BFQEE-K7252-ZBBSF"
     ></script> -->
     <script src="https://webapi.amap.com/maps?v=2.0&key=0b84075e96d01623f704867a601139bb"></script>
+    <script src="https://imgcache.qq.com/qcloud/cloudbase-js-sdk/1.6.0/cloudbase.full.js"></script>
     <title>Huihenduo App</title>
     <style>
       * {

+ 2 - 1
package.json

@@ -7,9 +7,10 @@
     "serve": "vite preview"
   },
   "dependencies": {
+    "@cloudbase/js-sdk": "^1.7.1",
+    "@element-plus/icons": "^0.0.11",
     "axios": "^0.21.1",
     "element-plus": "^1.1.0-beta.24",
-    "element3": "^0.0.40",
     "lodash": "^4.17.21",
     "md5": "^2.3.0",
     "vite-plugin-compression": "^0.3.5",

+ 16 - 0
src/apis/cloudLogin.js

@@ -0,0 +1,16 @@
+import cloudbase from "@cloudbase/js-sdk";
+
+const tcb = cloudbase.init({
+  env: "huihenduo-2gx127w7f837b584",
+});
+
+const auth = tcb.auth({
+  persistence: "local",
+});
+
+async function AnonymousLogin() {
+  await auth.anonymousAuthProvider().signIn();
+  const loginState = await auth.getLoginState();
+}
+AnonymousLogin();
+export default tcb;