# 02. SDK 使用
URL: /%E6%96%87%E6%A1%A3/04.%E5%BC%80%E5%8F%91%E6%96%87%E6%A1%A3/01.%20%E5%89%8D%E7%AB%AF%E5%BC%80%E5%8F%91/05.%20%E5%B9%B3%E5%8F%B0%E5%BC%80%E5%8F%91/02.%20%E5%85%AC%E4%BC%97%E5%8F%B7%E5%BC%80%E5%8F%91/02.%20SDK%E4%BD%BF%E7%94%A8


# 02. SDK 使用

封装了一些微信常用的 js-sdk 操作。

## 0.2.1 配置页面是否需要开启授权

| 参数           | 类型      | 默认值   |
| ------------ | ------- | ----- |
| requiresAuth | boolean | false |

```js
  {
    path: '/home',
    name: 'home',
    component: () => import('/@/views/home/index.vue'),
    meta: {
      title: '首页',
      keepAlive: false,
      requiresAuth: true, // 是否需要授权
    },
  },
```

## 0.2.3 自动分享配置参数

`shareInfo`

| 参数         | 类型      | 说明           |
| ---------- | ------- | ------------ |
| isShare    | boolean | 是否开启自动分享配置参数 |
| shareTitle | string  | 分享的标题        |
| imgUrl     | string  | 分享的卡片图片      |
| desc       | string  | 分享的描述        |

```js
  {
    path: '/shareAuto',
    name: 'shareAuto',
    component: () => import('/src/views/shareAuto/ShareAuto.vue'),
    meta: {
      title: '',
      shareInfo: {
        isShare: true,
        shareTitle: '',
        imgUrl: '',
        desc: '',
      },
    },
  },
```

## 0.2.4 手动分享配置参数

```js
  import { useWxSDK } from '/@/hooks/useWxSDK';
  import { useWxShare } from '/@/hooks/useWxShare';

  const { initConfig } = useWxSDK();
  
  initConfig().then(() => {
    useWxShare({
        title: '',
        desc: '',
        imgUrl: '',
    });
  });
```

1. 啥是自动配置，是不是说，整个页面固定分享参数，而手动分享是说根据业务需要自行指定。
