Project background

In recent years, with the vigorous development of open source in China, some colleges and universities have begun to explore open source into the campus, so that students can feel the charm of open source when they are students. This is also a new teaching mode that colleges and universities and domestic leading Internet enterprises try together. This project will document the learning results of the students during this period.

More topic background reference: [DoKit& Peking University topic] origin

series

[DoKit& Peking University] Origin

【DoKit& Peking University special Topic 】- Read the small program source code (a)

【DoKit& Peking University special Topic 】- Read the small program source code (two)

The original

One, foreword

This is a front-end beginner’s reading source code notes

Beginner front-end, according to their own preferences and needs to choose to learn wechat small program. Read the source code of Didi DoKit small program direction, on the one hand, I can learn about front-end related content, on the other hand, I hope to take this opportunity to try to contact open source projects.

To what extent is a front-end “beginner” a beginner

Before learning wechat small program development, I only learned Java, C++ and other object-oriented languages and basic computer foundation, without contact with JavaScript, HTML, CSS and other front-end content. These front-end related content I learned through wechat small program development while watching, including basic HTML syntax, CSS box model, Flex layout, etc.

Ii. First acquaintance with Didi DoKit

According to didi DoKit’s official documentation:

1, DoraemonKit can quickly make your business test code can be unified management here, unified closure;

2, DoraemonKit built-in many common tools, avoid repeated implementation, one access, you will have a powerful tool set;

3. With doKit platform, Mock interface, health check and file synchronization assistant make it easy for you to cooperate with others, greatly improving the efficiency of research and development.

To put it simply, Didi DoKit is a set of test tools for front-end developers. By introducing this set of tools into their own projects, they do not need to rewrite the test modules themselves, thus further improving the development efficiency.

Doraemon’s four dimensional pocket

DoKit is a functional platform for Android, iOS and wechat applets. Some of the functions introduced on the official website are not implemented in the wechat applets. Currently, the functions of DoKit applets include: App information, location simulation, cache management, ANY H5 gate, request injection, update version, and data simulation.

After that, the goal is to read the source code to understand how each function is implemented, but before reading the source code, you need to reference the DoKit module into your own applets project.

3. Reference the DoKit module to your own project

The introduction of the DoKit applet side module is easy. You can download it from the official guide or download it from Github.

DoKit applet github address

Let’s create a new applet sample project and introduce the Dokit module, with the result shown.

Click on the DoKit icon to see the functional interface of DoKit:

Click each function button to experience various functions. It should be noted that authorization is required after clicking the location simulation function.

Like all other mobile apps, wechat applet also needs authorization to obtain user privacy information. The specific setting method is to add permission in the app.json file of the applet, indicating the purpose of obtaining information.

"Permission ": {"scope.userLocation": {"desc":" your location information will be stolen (X)"}}Copy the code

You can see that the applet will normally apply for authorization when clicking position simulation again.

conclusion

So far, we have briefly understood the function of Didi Dokit, introduced the Dokit module into our own mini program project, and obtained the location authorization. Starting with the next article, we’ll officially start reading the source code for Dokit.

The author information

Author: As zhuang and As Harmonic

Original link: juejin.cn/post/694715…

Source: Nuggets