-
-
Notifications
You must be signed in to change notification settings - Fork 686
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: update image and add cli-mind websocket laf client sdk (#1004)
- Loading branch information
1 parent
e970a66
commit e258a7b
Showing
22 changed files
with
119 additions
and
438 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
.*xx.* | ||
https://beian.miit.gov.cn/ | ||
.*127-0-0-1.* | ||
https://oss.laf.dev | ||
https://oss.laf.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
--- | ||
title: laf-client-sdk | ||
--- | ||
|
||
# {{ $frontmatter.title }} | ||
|
||
## 介绍 | ||
laf 为前端提供了 `laf-client-sdk` 适用于任何 js 运行环境。 | ||
|
||
## 安装 | ||
|
||
```bash | ||
npm install laf-client-sdk | ||
``` | ||
|
||
## 使用示例 | ||
```js | ||
import { Cloud } from "laf-client-sdk"; | ||
|
||
const cloud = new Cloud({ | ||
// 这里 APPID 需要换成对应的 APPID | ||
baseUrl: "https://APPID.laf.run", | ||
// 这里是访问策略的入口地址,如果没有访问策略可不填 | ||
dbProxyUrl: "/proxy/app", | ||
// 请求时带的token,可空 | ||
getAccessToken: () => localStorage.getItem("access_token"), | ||
}); | ||
``` | ||
|
||
微信小程序中使用 | ||
```js | ||
import { Cloud } from "laf-client-sdk"; | ||
|
||
const cloud = new Cloud({ | ||
baseUrl: "https://APPID.laf.run", | ||
dbProxyUrl: "/proxy/app", | ||
getAccessToken: () => localStorage.getItem("access_token"), | ||
environment: "wxmp", | ||
}); | ||
``` | ||
|
||
UNI-APP 中使用 | ||
```js | ||
import { Cloud } from "laf-client-sdk"; | ||
|
||
const cloud = new Cloud({ | ||
baseUrl: "https://APPID.laf.run", | ||
dbProxyUrl: "/proxy/app", | ||
getAccessToken: () => localStorage.getItem("access_token"), | ||
environment: "uniapp", | ||
}); | ||
``` | ||
## 调用云函数 | ||
|
||
```ts | ||
import { Cloud } from "laf-client-sdk"; | ||
|
||
const cloud = new Cloud({ | ||
baseUrl: "https://APPID.laf.run", | ||
dbProxyUrl: "/proxy/app", | ||
getAccessToken: () => localStorage.getItem("access_token"), | ||
}); | ||
|
||
// 调用 getCode 云函数,并且传入参数 | ||
const res = await cloud.invoke("getCode", { phone: phone.value }); | ||
``` | ||
|
||
## 操作数据库 | ||
|
||
```ts | ||
import { Cloud } from "laf-client-sdk"; | ||
|
||
const cloud = new Cloud({ | ||
baseUrl: "https://APPID.laf.run", | ||
dbProxyUrl: "/proxy/app", | ||
getAccessToken: () => localStorage.getItem("access_token"), | ||
}); | ||
// 获取用户表中的数据。 | ||
const res = await db.collection('user').get() | ||
``` | ||
|
||
:::tip | ||
通过 client SDK 我们可以像在云函数中一样操作数据库,更多操作情参考 云数据库 章节。 | ||
还有就是需要配合相对应的访问策略。 | ||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.