Flutter Example Apps (Source Code + YouTube Link)

Image

Clones/Apps

  1. Flutter WhatsApp Clone Appwatch

  2. Flutter Instagram Clone Appwatch

  3. Flutter Build a Beautiful Pokemon App – Englishwatch

  4. Flutter Build a Beautiful Pokemon App – Hindiwatch

  5. Flutter Responsive Game of Thrones Flutter Appwatch

  6. Flutter: Quiz Appwatch

  7. Flutter StackOverflow Appwatch

  8. Flutter Gender Prediction Appwatch

  9. Flutter Cocktail Appwatch

  10. Flutter Gif Search Engine Appwatch

  11. Flutter QuotesX Appwatch

Flutter For Web / Desktop / Responsive

  1. Flutter For Web: Getting Started | Migrating PokemonApp to Webwatch

  2. Flutter Web: Making a Responsive Portfolio App | Part 1watch

  3. Flutter Web: Deploying Portfolio App To Github.IO | Peanut Tutorial | Part 2watch

  4. Flutter Web: Deploying Flutter UIKit to Github Pages | Peanut Tutorialwatch

  5. Flutter Web : Flutter 1.10 Adding Web Support For New & Existing Projectswatch

  6. Flutter Web Desktop Cocktail Appwatch

  7. Flutter PWA Tutorial – 1/2watch

  8. Flutter Official PWA Support – 2/2watch

  9. Flutter Responsive Portfolio App | Flutter Mobile, Web, & Desktop | SpeedX Codewatch

Flutter Designs

  1. Adobe XD Flutter Early Access Tutorial | Getting Startedwatch

  2. Beautiful Nike Web Design Concept With Flutterwatch

Beginners & Intermediate

  1. Flutter Devfest Appwatch

  2. Flutter Firebase MLKIT Appwatch

  3. Flutter Tic Tac Toe Gamewatch

  4. Flutter Music Player Appwatch

  5. Flute Music PluginPub

  6. Flutter Firebase Setupwatch

  7. Flutter Firebase CRUDwatch

  8. Flutter Bottom Sheet Appwatch

  9. Flutter WebSockets Appwatch

  10. Flutter Sqflite MVP Appwatch

  11. Flutter Crypto Appwatch

  12. Flutter Redux Appwatch

  13. Flutter Frenzy Chat Appwatch

  14. Flutter Calculatorwatch

  15. Flutter Login Page Appwatch

  16. Flutter Login Page Bloc Pattern Appwatch

  17. Flutter Beautiful Material Navigation Drawerwatch

  18. Flutter Material Design Widgets – | Tabs | BottomNavigationBar | Stepper | Snackbar etc Appwatch

  19. Flutter Git Quick Start Guidewatch

  20. Flutter Local JSON Appwatch

  21. Flutter Fetching App Using HTTPwatch

  22. Flutter Swipe to delete ListView Appwatch

  23. Flutter Line Clipping Appwatch

  24. Flutter Bezier Curve Appwatch

  25. Flutter CryptoShadow Hugo EXTRAT

  26. Flutter LifeCycle And Orientationwatch

  27. Flutter Splash Screen – FlutKartwatch

  28. Flutter Real Splash Screens for both OSwatch

  29. Flutter Walkthrough Package & AppwatchPub

  30. Flutter Validating Form – Login Formwatch

  31. Flutter Age Calculator Appwatch

  32. Flutter Collapsing Toolbar Layoutwatch

  33. Flutter PullToRefresh ListViewwatch

  34. Flutter Internet Connectivitywatch

  35. Flutter Access Camera Appwatch

  36. Firebase Build Beautiful Wallpaper App P1watch

  37. Flutter: Integrate Ads | Create Admob Account P2watch

  38. Flutter: Integrate Analytics | Firebase Analytics | Handling Library Issues P3watch

  39. Flutter: Prepare App For Release | App Signing | Create JKS P4watch

  40. Flutter: Publish App to PlayStore | Fully Explained Demo P5watch

  41. Flutter: Expandable & Sticky Header Listwatch

  42. Flutter: Backdrop Widget Tutorial | Material Design 2.0watch

  43. Flutter: QR Code Scanner Appwatch

  44. Flutter: Integrate Google Maps Tutorialwatch

  45. VSCode Tips & Tricks | Flutter | 20 Useful Shortcutswatch

  46. Flutter: Handle Back Button Pressed | WillPopScope Widgetwatch

  47. Flutter: Programatically Check Whether Debug OR Release Modewatch

  48. Flutter: Make New Gmail Like FloatingActionButtonwatch

  49. Routes in Flutter | Push | PushNamed | GenerateRoute | Unknown Routewatch

  50. Flutter: Data Connection Checker | Wifi connected but no internetwatch

  51. Flutter: Android App Bundle Step By Step Guidewatch

  52. Flutter: Click | Pick | Crop | Compress an Image | AndroidXwatch

  53. Flutter: Overriding Dependencies | Solving Version Conflictswatch

  54. Flutter: Styling Google Maps For Multiple Themes | Android & iOS | Official Pluginwatch

  55. Flutter: WhatsApp Clone Status View | Story View Feature Tutorialwatch

  56. Making Ubuntu like terminal in Flutterwatch

  57. Westlife Using Flutter

Advanced

  1. Flutter Advanced: Signature App (CustomPainter)watch

  2. Flutter Advanced: Dynamic Theming | Change Theme At Runtimewatch

  3. Flutter Advanced: Inherited Widget & Scoped Model Explained | Part – 1watch

  4. Flutter Advanced: BloC Pattern Explained | Part – 2watch

  5. Flutter Advanced Redux: Shopping Cart App From Scratch | Redux Time Travelwatch

  6. Flutter Advanced: Build Your First Plugin For Android & iOS | Flutter ToastswatchPub

  7. Flutter Advanced: Download Large Files (Pdf, Json, Image etc) With Progress %watch

  8. Flutter Advanced: Async Programming | Future | Async Awaitwatch

  9. Flutter Advanced: Semantic Versioningwatch

  10. Flutter Advanced : Build Beautiful Material Search App or Integrate it with Any Appwatch

  11. Flutter Advanced : Add Flutter To Existing Or New Android Appwatch

  12. Flutter Advanced: The BloC Pattern on Whiteboardwatch

  13. Flutter Advanced Login Page Bloc Pattern Appwatch

  14. Flutter Advanced Face ID & Touch ID/Fingerprint Local Auth Appwatch

  15. Flutter Advanced Securing your Flutter Apps | Prevent Screenshot Appwatch

  16. Flutter Advanced: ARCore Tutorial | Sceneform | Exploring New Possibilitieswatch

  17. Flutter Advanced: ARKit Tutorial | iOSwatch

  18. Flutter Advanced: PDF Viewer Tutorial Android & IOS | From URL & Assetwatch

  19. Flutter Advanced: Auto Create Models from JSON | Serializablewatch

  20. Flutter Advanced: Background Fetch | Run code in the background Android & iOSwatch

  21. Flutter Advanced: Lazy Loading ListViews | Load More Data On Scrollwatch

  22. Flutter Advanced: Find Widget’s Size & Position Using Render Objectwatch

  23. Flutter Advanced: TensorFlow Lite | Object Detection | YoloV2 | SSD Tutorialwatch

  24. Flutter Zoom In Zoom Out And Rotatewatch

Flutter Animation Series

  1. Flutter: Animation Series || Episode 1 || Basic Animation watch

  2. Flutter Animation: Ep 2 || Animation Series || Easing watch

  3. Flutter Animation: Ep 3 || Animation Series || Brick Animationswatch

  4. Flutter: Animation Series Ep 4 | Flipper Widgetwatch

  5. Flutter Flare 1.0 : Getting Started With 2D Animationswatch

  6. Flutter – Making a Christmas Tree 🎄| Tween Animationwatch

Flutter Library Series

  1. Awesome HTTP Inspector Tool | Flutter Library of the Week | EP-01 watch

  2. Awesome Animated Loaders | Flutter Library of the Week | EP-02 watch

  3. Awesome Onboarding Experience | Flutter Library of the Week | EP-03watch

  4. Awesome Overlays | Flutter Library of the Week | EP-04watch

  5. Awesome Extensions | Flutter Library of the Week | EP-05watch

  6. Storing Keys in .env file | BuildConfig | Flutter Library of the Week | EP-06watch

  7. Flutter Powerful VelocityX | VelocityX | Ch01-Ch05watch

  8. Flutter RxDart Explained – The Flutter Waywatch

Flutter Weekly Widgets Series

  1. Flutter: SizedBox | Flutter Weekly Widgets | Ep 1 watch

  2. Flutter: Animated Builder | Improve Performance | Ep 2 watch

  3. Flutter: Draggable & Drag Target | Ep 3 watch

  4. Flutter: World of Cupertino (iOS) | Ep 4 watch

  5. Flutter: Data Table | Ep 5 | Flutter Weekly Widgets watch

  6. Flutter: WebView | Browser App | Ep 6 | Website to Appwatch

  7. Flutter Advanced: Overlay Widget | Ep 7 | Flutter Weekly Widgets watch

  8. Flutter Advanced: Placeholder, Spacer, Visibility Widgets | Ep 8 watch

  9. Flutter Weekly Widgets S02E01 | Reordable ListViewwatch

  10. Flutter Weekly Widgets S02E02 | 3D ListViewwatch

  11. Flutter Weekly Widgets S02E03 | Universal Error Widgetwatch

Plugins on pub.dartlang.org

  1. Flutter VelocityX

  2. Flutter Flute Music Plugin – First Open Source Flutter based material design music player with audio plugin to play local music files.(Online Radio will be added soon).

  3. Flutter Walkthrough – A new Flutter package for both android and iOS which helps developers in creating animated walkthrough of their app.

  4. Flutter Toast PK – A new Flutter plugin for showing toast in android and ios.

  5. Random PK – A new Flutter package that gives a container with random color.

  6. PK Skeleton – A Facebook & Twitter Like Card Loading Shimmer Skeleton Library..

  7. MediumClapFlutter – A Custom Floating Action Button (FAB) library like clapping effect on Medium.

  8. audioplayers – A Flutter plugin to play multiple simultaneously audio files, works for Android and iOS.

  9. flame – A minimalist Flutter game engine.

Dart Series

  1. Learn Dart Basics in 30 Minswatch

  2. Thread of Execution, Functions & Call Stack- Dart Under The Hood CH1watch

Dart Backend Series (Source Code + YouTube Link)

  1. Dart: How to Setup Aqueduct | Intro | Aqueductwatch

  2. Dart: How to write your first REST API | Intro & 1/7 | Aqueductwatch

  3. Dart: How to make controllers ? | 1/7 | Aqueductwatch

  4. Dart: Indexing And Routing ? | 2/7 | Aqueductwatch

  5. Dart: How to write tests ? | 3/7 | Aqueductwatch

  6. Dart: How to setup PostgreSQL ? | 4/7 | Aqueductwatch

  7. Dart: How to write tests with test db ? | 5/7 | Aqueductwatch

  8. Dart: What is ORM ? | 5/7 | Aqueductwatch

  9. Dart: How to make DataModels ? | 5/7 | Aqueductwatch

  10. Dart: What are Relationships and Joins | 6/7 | Aqueductwatch

  11. Dart: How to deploy to real database ? | 7/7 | Aqueductwatch

  12. Server Side Dart – Exploring Angel | First APIwatch

  13. Flutter App + Backend (Angel) = FullStackwatch

  14. Deno (Backend) + Flutter (Frontend) Full Tutorial | QuotesX API & APPwatch

Workshops & Interviews

  1. Flutter From Scratch – Workshop | Photos Info App | Instagram Clone & Morewatch

  2. Taking Flight with VelocityX – Pawan Kumar (Flutter Week)watch

  3. Interview With A Googler | Chris Sells | Episode 01 | Flutter Q&Awatch

How to Use a Joystick with Serial Monitor

This project will show you how to use joystick with serial monitor.

Operation and uses

 

The joystick is similar to two potentiometers connected together, one for the vertical movement (Y-axis) and other for the horizontal movement (X-axis).

 

 

The potentiometers are variable resistances and, in a way, they act as sensors that provide us with varying voltage depending on their rotation.

Generally, joysticks are used in the military, leisure and aviation sectors.

 

Using the joystick pins

 

VCC

GND

VRx -> Variable resistance x

VRY -> Variable resistance Y

SW -> Switch / Button

Connection

MODULE -> ARDUINO

  • VCC -> 5V
  • GND -> GND
  • VRx -> A0
  • VRy -> A1
  • SW -> Pin 2
int VRx = A0;
int VRy = A1;
int SW = 2;

int xPosition = 0;
int yPosition = 0;
int SW_state = 0;
int mapX = 0;
int mapY = 0;

void setup() {
  Serial.begin(9600); 
  
  pinMode(VRx, INPUT);
  pinMode(VRy, INPUT);
  pinMode(SW, INPUT_PULLUP); 
  
}

void loop() {
  xPosition = analogRead(VRx);
  yPosition = analogRead(VRy);
  SW_state = digitalRead(SW);
  mapX = map(xPosition, 0, 1023, -512, 512);
  mapY = map(yPosition, 0, 1023, -512, 512);
  
  Serial.print("X: ");
  Serial.print(mapX);
  Serial.print(" | Y: ");
  Serial.print(mapY);
  Serial.print(" | Button: ");
  Serial.println(SW_state);

  delay(100);
  
}

总结100+前端优质库,让你成为前端百事通

js相关库

js 常用工具类

  1. 「lodash」 一个一致性、模块化、高性能的 JavaScript 实用工具库。
  2. 「xijs」 一款面向复杂业务场景的 javascript 工具库
  3. 「ramda」 一个很重要的库,提供了许多有用的方法,每个 JavaScript 程序员都应该掌握这个工具
  4. 「day.js」 一个轻量的处理时间和日期的 JavaScript 库,和 Moment.js 的 API 设计保持完全一样, 体积只有 2kb
  5. 「big.js」 一个小型,快速的 JavaScript 库,用于任意精度的十进制算术运算
  6. 「qs」 一个 url 参数转化 (parse 和 stringify)的轻量级 js 库
  7. 「decimal.js」 实现 JavaScript 的任意精度的十进制类型库

表单校验

  1. 「Validator.js」 一个强大的 js 表单校验库
  2. 「Validate.js」 致力于提供一种验证数据的跨框架和跨语言方式的 js 库, 已通过 100%代码覆盖率的单元测试

dom 库

  1. 「JQuery」 封装了各种 dom/事件操作, 设计思想值得研究借鉴
  2. 「zepto」 jquery 的轻量级版本, 适合移动端操作
  3. 「fastclick」 一个简单易用的库,它消除了移动端浏览器上的物理点击和触发一个 click 事件之间的 300ms 的延迟。目的就是在不干扰你目前的逻辑的同时,让你的应用感觉不到延迟,反应更加灵敏。

文件处理

  1. 「file-saver」 一个在客户端保存文件的解决方案,非常适合在客户端上生成文件的 Web 应用程序
  2. 「js-xlsx」 一个强大的解析和编写 excel 文件的库

网络请求

  1. 「Axios」 一个基于 Promise 的 HTTP 库,可用在 Node.js 和浏览器上发起 HTTP 请求,支持所有现代浏览器,甚至包括 IE8+
  2. 「Superagent」 基于 Ajax 的优化, 可以与 Node.js HTTP 客户端搭配使用
  3. 「fly.js」 一个基于 promise 的 http 请求库, 可以用在 node.js, Weex, 微信小程序, 浏览器, React Native 中

动画库

  1. 「Anime.js」 一个 JavaScript 动画库,可以处理 CSS 属性,单个 CSS 转换,SVG 或任何 DOM 属性以及 JavaScript 对象
  2. 「Velocity」 一个高效的 Javascript 动画引擎,与 jQuery 的 $.animate() 有相同的 API, 同时还支持彩色动画、转换、循环、画架、SVG 支持和滚动等效果
  3. 「Vivus」 一个零依赖的 JavaScript 动画库,可以让我们用 SVG 制作动画,使其具有被绘制的外观
  4. 「GreenSock JS」 一个 JavaScript 动画库,用于创建高性能、零依赖、跨浏览器动画,已在超过 400 万个网站上使用, 并且可以在 React、Vue、Angular 项目中使用
  5. 「Scroll Reveal」 零依赖,为 web 和移动浏览器提供了简单的滚动动画,以动画的方式显示滚动中的内容
  6. 「Kute.js」 一个强大高性能且可扩展的原生 JavaScript 动画引擎,具有跨浏览器动画的基本功能
  7. 「Typed.js」 一个轻松实现打字效果的 js 插件
  8. 「fullPage.js」 一个可轻易创建全屏滚动网站的 js 滚动动画库, 兼容性无可替代
  9. 「iscroll」 移动端使用的一款轻量级滚动插件
  10. 「swiper.js」 一款强大的 js 跨端触摸滑动插件
  11. 「MixItUp」 是用于 DOM 操作的高性能,无依赖库,使您能够使用精美的动画过滤,排序,添加和删除 DOM 元素的 js 动画库
  12. 「Lottie」 一个用于 Android,iOS,Web 和 Windows 的库,用于解析使用 Bodymovin 导出为 json 的 Adobe After Effects 动画,并在移动设备和网络上呈现它们

鼠标/键盘相关

  1. 「KeyboardJS」 一个在浏览器中使用的库(与 node.js 兼容).它使开发人员可以轻松设置键绑定和使用组合键来设置复杂的绑定.
  2. 「SortableJS」 功能强大的 JavaScript 拖拽库

图形/图像处理库

  1. 「html2canvas」 一个强大的使用 js 开发的浏览器网页截图工具
  2. 「dom-to-image」 一个可以将任意 DOM 节点转换为用 JavaScript 编写的矢量(SVG)或光栅(PNG 或 JPEG)图像的库
  3. 「pica」 一个在浏览器中调整图像大小,而不会出现像素失真,处理速度非常快的图片处理库
  4. 「Lena.js」 一个轻量级的可以给你图像加各种滤镜的 js 库
  5. 「Compressor.js」 一个使用本地 canvas.toBlob API 进行图像有损压缩的 js 库
  6. 「Fabric.js」 一个易于使用的基于 HTML5 canvas 元素的图片编辑器
  7. 「merge-images」 一个将多张图片合并成一张图的 js 插件
  8. 「cropperjs」 一款强大的图片裁切库, 支持灵活的图片裁切方式
  9. 「Grade」 一个基于图像中的前 2 种主要颜色生成互补渐变背景的库

表单表格

  1. 「x-spreadsheet」 一个基于 web 的简单易用的表格插件

Css 相关库

  1. hover.css 开箱即用的鼠标悬停动画
  2. animate.css 一个跨浏览器的简单便捷的 CSS 动画库
  3. Magic 集成各种特殊动效的 css 动画库
  4. kite 一个兼容性极好且灵活的布局 css 库
  5. csshake 一个能够震动和晃动DOM元素的 CSSku 库
  6. hint.css 一个用纯 css 和 html 实现的提示库

React相关库

UI 库

  1. Ant design 用于研发企业级中后台产品的 UI 组件库
  2. Ant design mobile 基于 Ant Design 设计体系的 React UI 移动端组件库
  3. MaterialUI 世界最受欢迎的基于质感设计的 React UI 库
  4. toolbox 一套使用 CSS 模块功能实现 Google 的 Material Design 规范的 React 组件
  5. Fabric UI 微软开源的 UX 框架的集合,用于创建共享代码,设计和交互行为的精美的跨平台应用程序
  6. React desktop 基于 React 的 JavaScript 库,旨在将本机桌面体验带入网络,其中包含许多 macOS Sierra 和 Windows 10 组件。react-desktop 与 NW.js 和 Electron.js 完美结合,但是可以在任何 JavaScript 驱动的项目中使用
  7. Zent 有赞 PC 端 WebUI 规范的 React 实现,提供了一整套基础的 UI 组件以及一些常用的业务组件
  8. react-icons 基于 React 封装的丰富的图标库

状态管理

  1. Redux JavaScript 状态容器,提供可预测化的状态管理
  2. Redux Thunk Redux 的异步处理中间件
  3. MobX 通过函数响应式编程使得状态管理变得简单和可扩展
  4. Dva 一个基于 redux 和 redux-saga 的数据流方案

工具类

  1. React Virtualized 一个能渲染大型列表和表格的 React 解决方案
  2. react-file-viewer React 在线 PDF 预览插件
  3. react-copy-to-clipboard 基于 React 的复制到剪切板组件
  4. qrcode.react 基于 React 的生成二维码的组件
  5. nprogress 适用于 YouTube,Medium 等的顶部进度条组件
  6. react-syntax-highlighter 基于 React 的代码高亮组件
  7. react-contextmenu 右键菜单组件
  8. emoji-mart 基于 React 的表情库
  9. react-highlight-words 基于 React 的关键字高亮
  10. WaterMark 水印组件

数据可视化

  1. AntV 包含 G2、G6、F2、L7 以及一套完整的图表使用和设计规范, 提供强大的数据可视化需求
  2. G2Plot 基于 G2 封装的开箱即用的可视化组件库
  3. recharts 使用 React 和 D3 构建的自定义的图表库
  4. Viser 支持多种主流框架的可视化库

拖拽/排序

  1. react-beautiful-dnd 漂亮,可移植性 列表拖拽库
  2. react-dnd 可帮助我们构建复杂的拖放界面,同时保持组件的分离
  3. react-moveable 支持自由拖拽, 缩放, 参考线的灵活强大的拖拽库
  4. react-grid-layout 强大的网格拖拽排序缩放库
  5. mixitup 强大且高性能的列表卡片排序动画库

动画/动效果

  1. Halogen 使用 React 的加载动画集合
  2. react-loading 一款基于 react 的轻量级加载动画库, 支持按需导入, 开箱即用
  3. react-move 漂亮的,数据驱动的 React 动画库
  4. react-spring 一个基于弹簧物理学的动画库
  5. react-text-loop-next 文字轮播动画

图像处理

  1. react-image-crop 强大的图片裁切库
  2. react-sparklines 基于数据自动生成趋势线
  3. dom-to-image 基于 dom 生成图片的 canvas 库
  4. react-img-editor 支持截图编辑的图片库

编辑器相关

  1. braft-editor 富文本编辑器
  2. powerNice 文档编辑器
  3. mitu 图片编辑器
  4. h5-dooring H5 页面编辑器
  5. GGEditor 可视化图编辑器
  6. react-codemirror2 代码编辑器
  7. jsoneditor json 编辑器

地图相关

  1. google-map-react 谷歌地图插件
  2. react-amap 高德地图插件
  3. react-baidu-map 百度地图

优秀国产项目集合

可视化编辑器

  • h5-dooring
  • dooringx
  • v6.dooring
  • mitu
  • watermark-pro

vue 后台模版

  • vue3.0-template-admin
  • vue-admin-box
  • ant-simple-pro

文档工具

  • html2md

H5 活动插件

  • lucky-canvas

视频播放器

  • JoL-player

Arduino Nano CNC Shield V4 with grbl PIN ERROR

The CNC Shield V4 came with some factory errors being a cloned version for china, the step puls and step direction pin numbers have been alternated, this article also show how to correct it. Just modify one file.

modify cpu_map.h file at line 39

#define X_STEP_BIT 5 // Uno Digital Pin 2
#define Y_STEP_BIT 6 // Uno Digital Pin 3
#define Z_STEP_BIT 7 // Uno Digital Pin 4

and line 47

#define X_DIRECTION_BIT 2 // Uno Digital Pin 5
#define Y_DIRECTION_BIT 3 // Uno Digital Pin 6
#define Z_DIRECTION_BIT 4 // Uno Digital Pin 7

 

save and exit

recompile and upload firmware

and done.

都2021移動端適配你還用flexible.js嗎?vw+rem一行代碼搞定

了解一下rem

rem(font size of the root element)是相對長度單位。相對於根元素(即html 元素)font-size 計算值的倍數。

適配原理:將px 替換成rem,動態修改html 的font-size 適配。它可以很好的根據根元素的字體大小來進行變化,從而達到各種屏幕基本一致的效果體驗

u 同學給的設計稿

常見的設計圖寬度,當然也可以是其他的寬度,比如720 像素的

  1. 375 iPhone7
  2. 750 二倍圖
  3. 320 iPhone5
  4. 640 二倍圖

為什麼給的是375?因為這個是iPhone7 的寬度,

也就是說最低兼容到375 像素的屏幕。(低於375 佈局可能會亂)

其他的同理

1. vw + rem 方案

如果效果圖是375px 的,

html 的style 屬性的font-size 設置為26.666666vw

css 中20px 改寫為0.2rem 即可

<!DOCTYPE html>
<html lang="en" style="font-size: 26.666666vw">
    <head>
        <meta charset="UTF-8" />
        <!--
        下面一行代码的解析:
        width=device-width 内容宽度 等于 设备宽度,换句话说 网页宽度为设备宽度
        initial-scale=1.0 初始缩放比等于1.0倍,换句话说 网页初始化缩放比为1.0 就是默认不缩放
    -->
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
        <title>Document</title>
        <style>
            /* 设置 div 为宽度100px高度18px */
            .app-main {
                /* 移动端写法 */
                width: 1rem;
                height: 0.18rem;
                /* 
                PC端写法
                width: 100px;
                height: 18px; */
            }
        </style>
    </head>
    <body>
        <div class="app-main"></div>
    </body>
</html>
复制代码

為什麼是26.666666vw?得了解下面幾個問題

-   1. 什么是 viewport?
-   2. 为什么要用它?
-   3. 怎么用?
-   4. `vw`、`vh`是什么?

答:

1. 什么是 viewport?
   [MDN viewport](https://developer.mozilla.org/zh-CN/docs/Web/CSS/Viewport_concepts)的解析是
   视口(viewport)代表当前可见的计算机图形区域。在 Web 浏览器术语中,通常与浏览器窗口相同,但不包括浏览器的 UI, 菜单栏等——即指你正在浏览的文档的那一部分。

2. 用它来移动端适配,兼容不同的设备,当然不局限于移动端,这里只讨论移动端

3. 只需要在`head`中定义 `<meta name="viewport" content="width=device-width, initial-scale=1.0" />`就行,具体如下:

`
<head>
    <meta charset="UTF-8" />
    <!--
        下面一行代码的解析:
        width=device-width 内容宽度 等于 设备宽度,换句话说 网页宽度为设备宽度
        initial-scale=1.0 初始缩放比等于1.0倍,换句话说 网页初始化缩放比为1.0 就是默认不缩放
    -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
</head>
`

4.  `vw` 是视口宽度的一个单位,viewport width 的简称,根据 viewport 相关定义,
    已经定义好了的,PC 端 100vw 就等于浏览器的宽度,移动端 100vw 就是设备的宽度(按照上面的 width=device-width)
    `vh` 同理,是视口高度,viewport height 的简称,100vh 就是可视窗口的高度
复制代码

了解完上面的知識點,我們可以回答

為什麼font-size 設置成26.666666vw?

设计图的宽度 = 设备宽度
假如 设计图的宽度为 375px,当然可以是其他的,这里是一个假如,如果是640,750就把375换成对应的数值按照以下方法换算就行就行
因为
    375px = 100vw
那么
    1px = 100 / 375 vw = 0.26666666666666666vw(约等于)

为了方便计算,放大一百倍,精确到6位,只能下取舍,因为上取舍,计算宽度的时候会大于页面宽度,从而出现滚动条
故:
    100px = 26.666666vw(约等于)

又因为给 html 标签设置 font-size 为 26.666666vw (约等于)

1rem为font-size的大小

所以:
    1rem = 100px
    0.2rem = 20px
也就是说:
    设计图上的 12px 换算成rem就是0.12rem,20px就写成0.2rem即可
复制代码

優點:不需要引入新的js,一行代碼搞定適配問題缺點:瀏覽器兼容性差,IE9 以下不支持,但現代瀏覽器,特別是移動端,基本都支持


可以參考:

設計圖大小(單位px) html 的font-size(單位vw) 備註
375 26.666666 效果圖20px,代碼應該寫0.2rem
750 13.333333 效果圖20px,代碼應該寫0.2rem
320 31.25 效果圖20px,代碼應該寫0.2rem
640 15.625 效果圖20px,代碼應該寫0.2rem

2. flexible 方案,(阿里)

lib-flexible的github 上有著這樣的一句話。

由於 viewport 單位得到眾多瀏覽器的兼容,lib-flexible這個過渡方案已經可以放棄使用,不管是現在的版本還是以前的版本,都存有一定的問題。建議大家開始使用viewport 來替代此方案。vw的兼容方案可以參閱《如何在Vue 項目中使用vw 實現移動端適配》一文。

我們可以得到一個很明確的信息,lib-flexible 這個方案已經被放棄使用了,我們可以去擁抱 vw 的那套實現方案。

3. 基於flexible 的hotcss方案

圖片上傳在ios中click事件無效

addImage方法中的this.input.click()在ios中無法生效。
網上提供的幾種解決方法,供大家參考:

1、​將click 事件直接綁定到目標​元素(​​即.target)上;
2、將目標​元素換成a 或者button 等可點擊的​元素;
​3、將click 事件委託到​​​​​非document 或body 的​​父級元素上;
​4、給​目標元素加一條樣式規則cursor: pointer。

我最後採用了直接調用dom的原生方法觸發input的點擊事件

addImage = () => {
const event = document.createEvent(‘MouseEvents’);
event.initMouseEvent(‘click’,false,false);
this.input.dispatchEvent(event)
};

Create Login Signup UI Screens in Vue with Bootstrap 4

In this tutorial, we are going to create responsive Login & Signup UI screens using the Bootstrap 4 CSS framework in the Vue.js application.

We will create a Login screen, Sign up screen, and Forgot Password screen from scratch.

Bootstrap is a free and open-source CSS based UI framework, and It is used for rapid front-end development. It offers plenty of UI components that are 100% responsive and can work on any device size smoothly. It contains CSS- and JavaScript-based design templates for typography, forms, buttons, navigation, and other interface components.

Vue.js is a robust progressive open-source JavaScript framework, and It is used use by web developers for creating excellent user interfaces and single-page applications. It makes app development quite simple and straightforward. The primary factor of Vue is that it is lightweight, flexible, modular, and highly performant.

Let’s start creating Login and Registration user-interface templates for Vue.js.

 

Vue.js Login & Signup UI Example

You need to have following tools and frameworks ready to get started with this tutorial:

  • Vue CLI
  • Vue
  • Bootstrap 4
  • Code Editor

Generate Vue App with Vue CLI

The Vue CLI offers the standard tooling option for swift development in Vue, run the command to install Vue CLI.

npm install -g @vue/cli

# or 

yarn global add @vue/cli

Make sure which vue-cli version has been installed in your development system:

vue --version

Generate a new Vue.js project by running the command from Vue CLI.

vue create vue-animated-ui

Answer Vue CLI questions with following choices.

# ? Please pick a preset: Manually select features
# ? Check the features needed for your project: Babel, Router, CSS Pre-processors, Linter
# ? Use history mode for router? (Requires proper server setup for index fallback in production) Yes
# ? Pick a CSS pre-processor (PostCSS, Autoprefixer and CSS Modules are supported by default): Sass/SCSS (with dart-sass)
# ? Pick a linter / formatter config: Basic
# ? Pick additional lint features: Lint on save
# ? Where do you prefer placing config for Babel, ESLint, etc.? In package.json
# ? Save this as a preset for future projects? (y/N) No

Head over to project folder.

cd vue-animated-ui

Start to see the latest created Vue app on the browser window.

npm run serve

Adding Bootstrap 4 in Vue.js

To use the Bootstrap UI components, we need to install the Bootstrap module in our Vue app.

npm install bootstrap

# or

yarn add bootstrap

Import Bootstrap path in the main.js file. It makes Bootstrap module available throughout our app.

import Vue from 'vue'
import App from './App.vue'
import router from './router'

import 'bootstrap/dist/css/bootstrap.min.css'

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')

We also need to define the Font Awesome icon CDN path in the public/index.html. It allow us to add some useful icons in our Vue app.

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

Adding Global CSS in Vue.js Project

Let’s look at the most asked question regarding Vue that how to add global styles via CSS in a Vue.js project.

Create a css folder inside the src/assets folder then create the main.css file in it.

Define the global CSS path inside the main.js file just below the Bootstrap path.

import Vue from 'vue'
import App from './App.vue'
import router from './router'

import 'bootstrap/dist/css/bootstrap.min.css'
import '@/assets/css/main.css'

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')

Add the common style of our primary authentication components in assets/css/main.css file.

* {
  box-sizing: border-box;
}

body {
  background: #2554FF !important;
  min-height: 100vh;
  display: flex;
  font-weight: 400;
}

body,
html,
.App,
.vue-tempalte,
.vertical-center {
  width: 100%;
  height: 100%;
}

.navbar-light {
  background-color: #ffffff;
  box-shadow: 0px 14px 80px rgba(34, 35, 58, 0.2);
}

.vertical-center {
  display: flex;
  text-align: left;
  justify-content: center;
  flex-direction: column;    
}

.inner-block {
  width: 450px;
  margin: auto;
  background: #ffffff;
  box-shadow: 0px 14px 80px rgba(34, 35, 58, 0.2);
  padding: 40px 55px 45px 55px;
  border-radius: 15px;
  transition: all .3s;
}

.vertical-center .form-control:focus {
  border-color: #2554FF;
  box-shadow: none;
}

.vertical-center h3 {
  text-align: center;
  margin: 0;
  line-height: 1;
  padding-bottom: 20px;
}

label {
  font-weight: 500;
}

.forgot-password,
.forgot-password a {
  text-align: right;
  font-size: 13px;
  padding-top: 10px;
  color: #7a7a7a;
  margin: 0;
}

.forgot-password a {
  color: #2554FF;
}

.social-icons {
  text-align: center;
  font-family: "Open Sans";
  font-weight: 300;
  font-size: 1.5em;
  color: #222222;
}

.social-icons ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.social-icons ul li {
  display: inline-block;
  zoom: 1;
  width: 65px;
  vertical-align: middle;
  border: 1px solid #e3e8f9;
  font-size: 15px;
  height: 40px;
  line-height: 40px;
  margin-right: 5px;
  background: #f4f6ff;
}

.social-icons ul li a {
  display: block;
  font-size: 1.4em;
  margin: 0 5px;
  text-decoration: none;
}
.social-icons ul li a i {
  -webkit-transition: all 0.2s ease-in;
  -moz-transition: all 0.2s ease-in;
  -o-transition: all 0.2s ease-in;
  -ms-transition: all 0.2s ease-in;
  transition: all 0.2s ease-in;
}

.social-icons ul li a:focus i,
.social-icons ul li a:active i {
  transition: none;
  color: #222222;
}

Create User Login UI in Vue

Designing and developing a login screen a bit time consuming task and requires some additional skills for a software developer. As we know, the login component allows you to access an application. It contains some strong web development fundamentals such as creating HTML forms, routing to navigate to some other screen, and two-way data-binding to extract the data from the login form.

We’re going to learn how to build a beautiful login form in the Vue.js application.

Create a Login.vue file in components folder and add the following code inside the components/Login.vue file.

<template>
    <div class="vue-tempalte">
        <form>
            <h3>Sign In</h3>

            <div class="form-group">
                <label>Email address</label>
                <input type="email" class="form-control form-control-lg" />
            </div>

            <div class="form-group">
                <label>Password</label>
                <input type="password" class="form-control form-control-lg" />
            </div>

            <button type="submit" class="btn btn-dark btn-lg btn-block">Sign In</button>

            <p class="forgot-password text-right mt-2 mb-4">
                <router-link to="/forgot-password">Forgot password ?</router-link>
            </p>

            <div class="social-icons">
                <ul>
                    <li><a href="#"><i class="fa fa-google"></i></a></li>
                    <li><a href="#"><i class="fa fa-facebook"></i></a></li>
                    <li><a href="#"><i class="fa fa-twitter"></i></a></li>
                </ul>
            </div>

        </form>
    </div>
</template>

<script>
    export default {
        data() {
            return {}
        }
    }
</script>

Create User Login UI in Vue

Build Sign up Template

Well, sign up in simple terms means to create a new account or register in an application. It could be signing up for any web portal or even for a newsletter. When you visit any new website, you need to create an account using the name, email, and password.

In this step, we are going to create an eye-catching registration UI screen in Vue using the Bootstrap 4 Form component.

Create components/Signup.vue and paste the given below code inside the file.

<template>
    <div class="vue-tempalte">
        <form>
            <h3>Sign Up</h3>

            <div class="form-group">
                <label>Full Name</label>
                <input type="text" class="form-control form-control-lg"/>
            </div>

            <div class="form-group">
                <label>Email address</label>
                <input type="email" class="form-control form-control-lg" />
            </div>

            <div class="form-group">
                <label>Password</label>
                <input type="password" class="form-control form-control-lg" />
            </div>

            <button type="submit" class="btn btn-dark btn-lg btn-block">Sign Up</button>

            <p class="forgot-password text-right">
                Already registered 
                <router-link :to="{name: 'login'}">sign in?</router-link>
            </p>
        </form>
    </div>
</template>

<script>
    export default {
        data() {
            return {}
        }
    }
</script>

Build Vue Sign up Template

Forgot Password Screen in Vue

“Forgot password” screen is used to recover any password that you forgot for any specific account for the application.

Create components/ForgotPassword.vue and paste the given below code inside the file.

<template>
    <div class="vue-tempalte">
        <form>
            <h3>Forgot Password</h3>

            <div class="form-group">
                <label>Email address</label>
                <input type="email" class="form-control form-control-lg" />
            </div>

            <button type="submit" class="btn btn-dark btn-lg btn-block">Reset password</button>

        </form>
    </div>
</template>

<script>
    export default {
        data() {
            return {}
        }
    }
</script>

Forgot password in Vue

Enable Vue Router

Next, we enable the router in the vue app, these routes will allow us to navigate from one page to another page. So, first install the vue router package in the app.

npm install vue-router

Add the following code inside the router/index.js file.

import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

  const routes = [
  {
    path: '/',
    name: 'signup',
    component: () => import('../components/Signup.vue')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../components/Login.vue')
  },
  {
    path: '/forgot-password',
    name: 'forgot-password',
    component: () => import('../components/ForgotPassword.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router

Implement Vue Navigation with Bootstrap 4

Finally, we will create the simple and beautiful navigation bar that will allow us jump from one template to another template in Vue app.

Include the given below code inside the App.vue file.

<template>
  <div class="vue-tempalte">
    <!-- Navigation -->
    <nav class="navbar shadow bg-white rounded justify-content-between flex-nowrap flex-row fixed-top">
      <div class="container">
        <a class="navbar-brand float-left" href="https://www.positronx.io" target="_blank">
           positronX.io
        </a>
        <ul class="nav navbar-nav flex-row float-right">
          <li class="nav-item">
            <router-link class="nav-link pr-3" to="/login">Sign in</router-link>
          </li>
          <li class="nav-item">
            <router-link class="btn btn-outline-primary" to="/">Sign up</router-link>
          </li>
        </ul>
      </div>
    </nav>

    <!-- Main -->
    <div class="App">
      <div class="vertical-center">
        <div class="inner-block">
          <router-view />
        </div>
      </div>
    </div>
  </div>
</template>

Summary

We just created beautiful UI screes for Vue authentication process, we explored how to create some beautiful Login, Signup and Forgot password templates with Bootstrap 4.

You can download the full code from this GitHub repository.

WangEditor添加首行缩进功能

官方也不增加这个,但对于经常写文章的用户来说,首行缩进是很实用的功能,改变一下样式就可以了text-indent: 2em;

修改一下初始化wangEditor的地方,注册一个菜单

//初始化编辑器
var E = window.wangEditor;
// 菜单 key ,各个菜单不能重复
const menuKey = ‘MyTextIndentMenuKey’

// 注册菜单
E.registerMenu(menuKey, MyTextIndentMenu)

var editor = new E(‘#’+id);

 

新增一个MyTextIndentMenu.js,代码如下:

 

const E = window.wangEditor
const { $, BtnMenu , DropListMenu, PanelMenu, DropList, Panel, Tooltip } = E

const lengthRegex = /^(\d+)(\w+)$/
const percentRegex = /^(\d+)%$/
const reg = /^(SECTION|P|H[0-9]*)$/

// 第一,菜单 class ,Button 菜单继承 BtnMenu class https://www.wangeditor.com/doc/
class MyTextIndentMenu extends BtnMenu{
constructor(editor) {
// data-title属性表示当鼠标悬停在该按钮上时提示该按钮的功能简述text-indent: 2em;
const $elem = E.$(
`<div class=”w-e-menu w-e-icon-indent-increase” data-title=”首行缩进”>
</div>`
)
super($elem, editor)
}
// 菜单点击事件
clickHandler() {
// 做任何你想做的事情text-indent: 2em;
// 可参考【常用 API】文档,来操作编辑器
this.command();
}
// 菜单是否被激活(如果不需要,这个函数可以空着)
// 1. 激活是什么?光标放在一段加粗、下划线的文本时,菜单栏里的 B 和 U 被激活,如下图
// 2. 什么时候执行这个函数?每次编辑器区域的选区变化(如鼠标操作、键盘操作等),都会触发各个菜单的 tryChangeActive 函数,重新计算菜单的激活状态
tryChangeActive() {
// 激活菜单
// 1. 菜单 DOM 节点会增加一个 .w-e-active 的 css class
// 2. this.this.isActive === true
const editor = this.editor
const $selectionElem = editor.selection.getSelectionStartElem()
const $selectionStartElem = $($selectionElem).getNodeTop(editor)

if ($selectionStartElem.length <= 0) return

if ($selectionStartElem.elems[0].style[‘textIndent’] !== ”) {
this.active()
} else {
this.unActive()
}
}
/**
* 执行命令
* @param value value
*/
command() {
const editor = this.editor
const $selectionElem = editor.selection.getSelectionContainerElem()

// 判断 当前选区为 textElem 时
if ($selectionElem && editor.$textElem.equal($selectionElem)) {
// 当 当前选区 等于 textElem 时
// 代表 当前选区 可能是一个选择了一个完整的段落或者多个段落
const $elems = editor.selection.getSelectionRangeTopNodes()
if ($elems.length > 0) {
$elems.forEach((item) => {
this.operateElement($(item), editor)
})
}
} else {
// 当 当前选区 不等于 textElem 时
// 代表 当前选区要么是一个段落,要么是段落中的一部分
if ($selectionElem && $selectionElem.length > 0) {
$selectionElem.forEach((item) => {
this.operateElement($(item), editor)
})
}
}

// 恢复选区
editor.selection.restoreSelection()
this.tryChangeActive()
}

operateElement($node, editor) {
const $elem = $node.getNodeTop(editor)
let type = ‘increase’;
if($node.elems[0].style[‘textIndent’] !== ”)
type = ‘decrease’;

if (reg.test($elem.getNodeName())) {
if (type === ‘increase’) this.increaseIndentStyle($elem, this.parseIndentation(editor))
else if (type === ‘decrease’) this.decreaseIndentStyle($elem, this.parseIndentation(editor))
}
}
increaseIndentStyle($node, options) {
const $elem = $node.elems[0]
if ($elem.style[‘textIndent’] === ”) {
$node.css(‘text-indent’, options.value + options.unit)
} else {
const oldPL = $elem.style[‘textIndent’]
const oldVal = oldPL.slice(0, oldPL.length – options.unit.length)
const newVal = Number(oldVal) + options.value
$node.css(‘text-indent’, `${newVal}${options.unit}`)
}
}
decreaseIndentStyle($node, options) {
const $elem = $node.elems[0]
if ($elem.style[‘textIndent’] !== ”) {
const oldPL = $elem.style[‘textIndent’]
const oldVal = oldPL.slice(0, oldPL.length – options.unit.length)
const newVal = Number(oldVal) – options.value
if (newVal > 0) {
$node.css(‘text-indent’, `${newVal}${options.unit}`)
} else {
$node.css(‘text-indent’, ”)
}
}
}

parseIndentation(editor) {
const { indentation } = editor.config

if (typeof indentation === ‘string’) {
if (lengthRegex.test(indentation)) {
const [value, unit] = indentation.trim().match(lengthRegex).slice(1, 3)
return {
value: Number(value),
unit,
}
} else if (percentRegex.test(indentation)) {
return {
value: Number(indentation.trim().match(percentRegex)?indentation.trim().match(percentRegex):[1]),
unit: ‘%’,
}
}
} else if (indentation.value !== void 0 && indentation.unit) {
return indentation
}

return {
value: 2,
unit: ’em’,
}
}

}

ubuntu 下使用openconnect 连接vpn

使用openconnect在ubuntu 中安装openconnect,可以在软件中心找到.

 

在/etc/vpc/目录下新建vpnc-script 文件

文件内容可以到此处拷贝

http://git.infradead.org/users/dwmw2/vpnc-scripts.git/blob_plain/HEAD:/vpnc-script

 

sudo openconnect -u 用户名 –script=/etc/vpnc/vpnc-script –no-dtls vpn.test.com

 

输入密码后提示

POST https://vpn.test.com/+webvpn+/index.html

Got CONNECT response: HTTP/1.1 200 OK

CSTP connected. DPD 30, Keepalive 20

Connected tun0 as 10.22.22.22, using SSL

 

连接成功!!!