说明

以下功能模块,已存在默认配置,不需要额外接入,修改配置即可。

业务接入

操作示例

1. 设置业务接口(业务请求时,默认带上Token令牌)

// 请修改成-实际业务后端接口,例:BASE_API = '/template-api'
let BASE_API = ''

2. 请求接口(正在开发中…)

进行接口请求(开发环境时,会使用当前工程的request请求;生成环境时,使用工作台提供的统一请求方法)

async mounted () {
    try {
      let res = await this.$REQUEST({
        url: `${this.$BASE_API}/page`,
        method: 'GET',
        params: {
          page: 1,
          size: 5,
        },
      })
      this.list = res.data
    } catch (e) {
      console.error(e)
    }
  }

认证鉴权接入

nuxt.config.js里可以设置是否开启认证。开启后,未登录或登录过期会跳转到认证中心,登录成功后返回;

// nuxt.config.js
module.exports = {
  env: {
    ...
    isAuth: true // 是否开启登录验证
  },
}

工作台打开应用时,已携带用户Token,该工程将处理并将令牌存储到Cookies里,也可以设置存储的Key值;

// nuxt.config.js
module.exports = {
  env: {
    ...
    tokenKey: 'paiUiToken', // 存储token, cookie主键
  },
}
  • 用户信息
    默认会请求获取用户信息,并存储到Vuex;
    页面获取:this.$store.state.user_info

  • 套件权限
    使用/auth-api/oauth2/getSuiteInfo 接口获取套件信息、权限、角色等;

// 获取用户信息/套件信息
export const getSuiteInfo = () => {
  return request({
    url: `${process.env.AUTH_API}/oauth2/getSuiteInfo`,
    method: 'GET',
    params: {
      appCode: 'cn.flyrise.xxx' // 套件标识,与后端绑定,与套件/后端需一致
    }
  })
}

OSS接入

nuxt.config.js里可以设置是否开启OSS;

// nuxt.config.js
module.exports = {
  env: {
    ...
    isOss: false, // 是否开启OSS-需要后端业务接口对接OSS,请修改/api/user.js
  },
}

需要基于后端对接OSS中心,并由后端提供一个接口,去获取OSS的token

// api/user.js
export const getOssToken = () => {
  return request({
    url: `${process.env.BASE_API}/oss/token`,
    method: 'GET'
  })
}

注意:该Url是业务后端对OSS中心中专的接口


消息接入

使用process.env.MSG_API,去请求相关的接口

操作示例

1. 发送信息

  request({
    url: `${process.env.MSG_API}/message/sendWs`,
    method: 'POST',
    data: {
      appId: this.message.appId,
      businessSystemId: 'iot',
      content: this.message.content,
      delayedSendTime: '',
      enterpriseId: '111',
      msgType: '对话消息',
      param: {},
      receiveOrgIds: [],
      receiveUserIds: [this.$store.state.user_info.userId],
      receiveUserType: 'user',
      sendUserId: this.$store.state.user_info.userId,
      sendUserName: this.$store.state.user_info.nickName,
      sendUserOrgId: '1291622002163060736',
      sendUserOrgName: '22',
      title: this.message.title
    }
  })

2. 获取消息分类列表

  request({
    url: `${process.env.MSG_API}/message/msgAppList`,
    method: 'GET',
    params: {
      channel: 'ws',
      userId: this.$store.state.user_info.userId
    }
  })

3. 获取套件历史消息

  request({
    url: `${process.env.MSG_API}/message/appHistoryMsg`,
    method: 'GET',
    params: {
      appId: this.appId,
      channel: 'ws',
      current: 1,
      size: 200,
      userId: this.$store.state.user_info.userId
    }
  })

4. 标记已读消息

  request({
    url: `${process.env.MSG_API}/message/updateRead`,
    method: 'POST',
    data: {
      msgId: this.msgId,
      userId: this.user.userId
    }
  })
更具体消息对接,请到以下链接查看↓

http://api.flyrise.cn:9099/docs/open-docs/open-docs-1ctpsf8m64bhn


全文检索接入

使用process.env.SEARCH_API,去请求相关的接口

import { GetSearchClassList, ApiGetApps } from '~/api/search'

操作示例

1. 获取查询的分类

      const query = {
        "buzType": "",
        "comId": this.user_info.entEntity.id,
        "fileType": "",
        "fromType": "WEB",
        "page": 0,
        "pageSize": 0,
        "queryStr": '放假通知',  // 搜索关键词
        "queryType": 1,
        "userId": this.$store.state.user_info.userId
      }
      GetSearchClassList(query).then(res => {
          // ...
      })
// api/search.js
export const GetSearchClassList = (query) => {
  return request({
    url: `${process.env.SEARCH_API}/search/searchBuzTypeList`,
    method: 'POST',
    data: query
  })
}

2. 根据分类获取列表数据

     const query = {
        "buzType": this.itemData.buzType, // 当前搜索的类型
        "comId": this.user_info.entEntity.id,
        "fileType": "",
        "fromType": "WEB",
        "page": 0,
        "pageSize": 15,
        "queryStr": '放假通知',  // 搜索关键词
        "queryType": 1,
        "userId": this.user_info.userId
      }
      ApiGetSearchData(query).then(res => {
        // ...
      })
// api/search.js
export const ApiGetSearchData = (query) => {
  return request({
    url: `${process.env.SEARCH_API}/search/searchList`,
    method: 'POST',
    data: query
  })
}
更具体全文检索对接,请到以下链接查看↓

http://api.flyrise.cn:9099/docs/open-docs//987


数据资产接入

使用Pai生成的web数据小组件,即可直接使用。

文档更新时间: 2021-07-08 11:20   作者:管理员