更新记录

1.2.0(2021-12-05) 下载此版本

  • perf: 完善qqrobot函数的配置
  • perf: 优化openapi的接口协议
  • fix: 完善云函数修复已知问题
  • fix: 修复 修改题目的接口协议
  • perf: 请求自定义头修改
  • build: 新增esbuild-node-tsc依赖
  • build: uni-captcha

1.1.2(2021-11-07) 下载此版本

1.1.2

  • 完善数据库所有的schema
  • 完善certificationApplyOrder表的createDate等字段
  • 修复内容安全api的问题(完善get-accesstoken公共模块)
  • qq机器人正式服开启,欢迎大家进群玩耍,随时学习,快速提高

1.1.0(2021-11-06) 下载此版本

  • npm包 新增typescript-type核心包,重构了unicloud/explain/sword-core等所有类型提示
  • 新增 CI 持续集成小程序实现自动发布
  • 新增 unicloud后端架构大幅调整,从explain1->explain2,所有核心云函数都将采用http云函数URL化
  • 新增 后端架构调整&代码重构&美化代码
  • 新增 TS运行时校验功能
  • 新增 后端核心函数新增中间件体系
  • 新增 更改explain2核心部分代码
  • 新增 核心主要函数将cjs替换为es
  • 新增 QQ机器人系统,推送海量题目
  • 新增 微信小程序结束了审核,此后微信小程序&QQ小程序将会正常迭代
  • 新增 重构&美化了API层的所有代码(*下一个版本会重点改进这里)
  • 新增 更改官网的部分内容
  • 新增 app核心工程升级了所有的依赖包到最新版本(*后续会对windows电脑部署项目出现的bug进行修复)
  • 新增 整个app工程引入了husky和lint-staged,eslint
  • 更多内容请查阅具体代码或者阅读升级说明
查看更多

平台兼容性

阿里云 腾讯云 支付宝云
× ×
Vue2 Vue3
×
App 快应用 微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序
× × × × ×
钉钉小程序 快手小程序 飞书小程序 京东小程序
× × × ×
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
× × × × × × × × ×

云函数类插件通用教程

使用云函数类插件的前提是:使用HBuilderX 2.9+


剑指题解

互联网人题解神器,神器在手,offer我有
随手刷题 | 无广告绿色免费 | 个性推荐 | 每日自动推送 | 多维度丰富领域知识


项目的起源是一个 github 仓库,名为前端知识每日 3+1,正是这个优秀的题库项目才有了我们团队开发聚合题库的想法。在我们国内程序员圈子,大多数小伙伴为了更好的技术发展和 offer,都通过训练题来提高自己的眼界,其中不乏包括算法/业务/软技能的题目,但是因为我们的环境和侧重点不一样,所以我们接触的项目和题目都不一样,而市面上很少有一个项目能做到,涵盖不同圈子的聚合题库。 《剑指题解》项目就是一个优秀的互联网行业聚合题库神器。

开源免费不易,请关注我们的公众号以及开源仓库

沈昊Seho/InternetQuestionBank
Github 点 star, 拉取代码时请选择最新分支 Dcloud 插件市场支持我们

欢迎加入我们的QQ群,每天都会推送业务题/编程题目,帮助大家一点一点地成长

点击加入qq群/钉钉群 (也可以滑动到底部扫描二维码)

目录

特点

  1. 汇聚优秀的开源题目,以技术社区为主线展开的刷题 APP
  2. 根据用户的喜好,去推送相关的最新题目,不会再刷到 “牛头不对马嘴”无用的题目
  3. 我们绑定了微信服务号,每日定时推送给用户最新的题目,让你能在每天清晨就开启活力新一天
  4. 刷题 APP 无广告,无硬性推广,一切盈利皆在赞助/官网流量
  5. 我们还有很多有意思的待开发 feature,比如大佬带萌新模式,还将开启校园/企业的通道,让每一个学生/员工都能每时每刻提高自己
  6. 剑指题解开源项目,从原型图到小程序,UI 图,UML,API 文档,第三方 API 对接说明书,使用说明都将免费开源,欢迎各位同僚二开,让这个行业变得更好,我们将用心地辅助你们解决在技术上的难题。

技术栈

关于技术栈的选型可以参考我们的语雀文档 周边物料的开源,还需要感谢 mockPlus 以及语雀:

UML

由于此部分在开发新 feature 的工作中可能会进行变更或者本就有实质性的错误,欢迎向我们反馈错误,我们将感激不尽。

云服务/函数架构图

核心数据库类图

拉取任务

更多

更多相关资料请移步 out/doc或者语雀-UML

设计概览

设计源文件请移步:点击查看-为了您的体验,请务必下载最新版本的设计图 原型图在线预览: 点击查看, 如果失效请联系我们

API设计(读写职责分离)

读写职责分离模式(CQRS)是一种把查询(Queries) 数据和和更新(Commands) 数据通过使用各自独立的接口分开的模式。 Uniapp 的 Unicloud 很好,其中的 jql 也是大开眼界,确实统一了前端开发操作数据库的体验,让我们前端开发操作数据库非常友好,但是我们使用 CQRS 将这些原本封装的很好的 API 不予以使用。

  • 前端使用 jql 去读取想要的数据
  • 写入操作就交给云函数去执行

如图,前端读取一个列表数据

const db = uniCloud.database();
const databaseName = "testInit";
// 获取测试数据列表
export function getTestList() {
  return new Promise((resolve) => {
    db.collection(databaseName)
      .get()
      .then((res) => {
        // res 为数据库查询结果
        resolve(res);
      })
      .catch((err) => {
        // err.message 错误信息
        // err.code 错误码
      });
  });
}

我们将这样的文件抽出了一个一个查询模块,每一个模块对应了一个数据表(这里是 testInit)封装在了 API 这个文件夹中。

Vue 页面将这样去调用,这样我们在 API 查询层将做好数据的处理,确保 Vue 拿到的是可以直接渲染的干净数据。

import { getTestList } from "../../api/test";
const data = getTestList();

我们写入操作将通过HTTP调用云函数,唯一设计不同的地方在于,我们将云函数这个概念改变了,一个云函数是一个版本的接口。

在我们的初步技术调研过程中,由于 Uni 官方并没有提供给用户云函数开发框架,但是我们在插件市场中找到了一款名为 explain 的开发框架,它可以迅速的帮助我们实现 restapi 风格的单路由云函数 explain.js 快速开发 uni 云函数的框架

在v1.1.0版本之后,后端进行了v1版本接口的重构,使用ts运行时校验来代替我们参数检查的工作

import * as explain from 'explain';
import articleService from '../service/article';
import * as IArticle from '../../proto/article';

export = class ArticleController extends explain.service {
  private service: articleService;
  constructor(e: CloudData) {
    super(e);
    this.service = new articleService(this);
  }
  /**
   * @name 添加/发布文章
   * @param IArticle.AddArticle
   * @return {*}  {Promise<unknown>}
   * @link https://www.yuque.com/mlgrgm/lmm8g4/kif3lf#g13V0
   * @memberof ArticleController
   */
  async addArticle(): Promise<unknown> {
    return await this.service.addArticle(this.event.data as IArticle.AddArticle);
  }
};

在客户端调用这个云函数

await request({
  route: `api/article`,
  method: 'POST',
  data: params,
  checkLogin: true
});

想要了解更多API相关内容,请移步我们的API文档

开放API

openAPI是剑指题解1.0.9版本之后的新内容,我们将暴露一部分的云函数给外部,用户可以通过后台管理系统来获取自身专属的公共api,openapi对于每一个用户来说都是免费的,但是目前每个月限制了调用次数。在初步我们每个月都会往每个用户中加入200次调用次数,每个月重置。这个调用次数随着用户的增加而上调。

可以从图中看到,openapi和coreapi是2个云函数,这样做的目的主要还是保持coreapi的封闭性,openapi和数据库表openapi联系,在数据表定义了数个开发的api,存储着name,remark,info等字段,这些字段均表示了api的各种信息,在管理后台管理员可以对这些api进行控制。

剑指题解程序中的token在目前的版本中是永久的,这是非常不安全的,预计在1.0之后的版本会对token进行有效期调整。openapi的2要素就是token+apiid,token是永久的token(除非您在APP中退出当前账号,这才会销毁token)。我们在后台管理系统中提供了非常简便的【复制公共API】按钮,只需要按照文档进行请求即可。

查阅公共api文档

配套后台管理系统

后台管理系统开放角色为:管理员, 普通用户,认证答题官(具有发布权限),目前版本仍然在完善中,而且大可放心的是,后台管理系统仍然使用unicloud进行快速开发,在读取我们没有使用jql,而是直接在页面渲染client-db组件。 关于为什么和app的技术栈不一样,我这边简单归纳了几点,首先我希望后台管理系统是大家一起维护提pr的,作为一款管理产品,拓展不会太宽,是要求门槛很低且需要快速开发的,所以选择了上手较快的云开发产品

关于已经有小程序账号的用户如何进入管理后台:请移步这个文档
剑指题解后台管理系统: http://sword.admin.yinzhuoei.com/#/pages/login/login
源代码:https://github.com/swordCodePractice/swordUserAdmin

作者和贡献者们

感谢为《剑指题解》这个优秀项目贡献自己一份力的小伙伴们:

如果您想加入到我们的贡献者队列中,请联系我们,这里还有相关贡献者的介绍,希望对您有帮助

相关开源物料

题库合作伙伴

下载小程序后台管理系统源代码下载

其他渠道联系我们:联系我们

友情开源项目

秋云ucharts跨端图表库

许可

Apache License © 剑指题解

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

无javascript:void(0)

许可协议

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

  1. Definitions.

    "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.

    "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.

    "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.

    "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.

    "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.

    "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.

    "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).

    "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.

    "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."

    "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.

  2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.

  3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.

  4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:

    (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and

    (b) You must cause any modified files to carry prominent notices stating that You changed the files; and

    (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and

    (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.

    You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.

  5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.

  6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.

  7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.

  8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.

  9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.

    END OF TERMS AND CONDITIONS

    APPENDIX: How to apply the Apache License to your work.

    To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.

    Copyright [yyyy] [name of copyright owner]

    Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. © 2021 GitHub, Inc.

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问