Kairyou's Blog

专注于WEB前端开发, 追求更好的用户体验, 更好的开发体验 [长沙前端QQ群:234746733]
  • npm包 CDN 收集

    / 分类: 工具 / No Comments

    jsDelivr(支持 combine)
    `https://cdn.jsdelivr.net/npm/:package@:version/:file`
    # https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
    unpkg
    `https://unpkg.com/:package@:version/:file`
    # https://unpkg.com/[email protected]/dist/jquery.min.js
    饿了么
    `https://npm.elemecdn.com/:package@:version/:file`
    # https://npm.elemecdn.com/[email protected]/dist/jquery.min.js
    知乎
    `https://unpkg.zhimg.com/:package@:version/:file`
    # https://unpkg.zhimg.com/[email protected]/dist/jquery.min.js
    百度
    `https://code.bdstatic.com/npm/:package@:version/:file`
    # https://code.bdstatic.com/npm/[email protected]/dist/jquery.min.js

    jsDelivr国内可能部分网络有问题, 但仅jsDelivr才支持combine(多个文件合并).
    使用CDN引入, 可以独立公共资源, 省去webpack打包. 当然, 也有人用来做图床.

  • Flutter开发环境搭建

    / 分类: 开发 / No Comments

    安装Dart
    brew tap dart-lang/dart
    brew install dart
    # ~/.zshrc 或 ~/.bashrc 新增1行:
    export PATH="$HOME/.pub-cache/bin:$PATH" # pub
    安装fvm (同时安装多个flutter版本)
    pub global activate fvm
    fvm install stable # 或指定比如: 1.10.7, [Versions](http://url.cn/52OcNkr)
    # ~/.zshrc 或 ~/.bashrc 新增1行:
    export PATH="$HOME/fvm/versions/stable/bin:$PATH" # fullter
    # fvm list # 已安装的版本号
    flutter version manager

    fvm或者flutter channel切换版本都不太好用(一个是需要以fvm开始命令, 一个是不能按项目切换版本),
    推荐使用 direnv 设定:

    brew install direnv
    # 项目目录内执行 (指定了version为stable):
    direnv allow;
    echo 'VERSION="stable"; export PATH="$HOME/fvm/versions/$VERSION/bin:$PATH"' > .envrc;
    信息打印
    flutter --version
    flutter doctor -v # 检查环境配置
    # 安装依赖, 比如 XCode, Android Studio
    brew install cocoapods
    编辑器设定:
    • VSCode

      • Extensions安装:Flutter, Dart
      • 如果 VSCode 提示: Could not find a flutter SDK: 重启下VSCode
      • quicktype插件, 根据JSON生成Data Class. 用法:

        • VSCode > Settings 设定 "quicktype.justTypes": false
        • 创建并打开xxx.dart, 复制json代码, VSCode: view > Command Palette > Paste JSON as Code, 根据剪贴板的json生成Code.
        • 生成的code, 最好正则替换下: \b(json\[.*\]).map\( > ($1 ?? []).map(, fromJson\((json\[.*\])\) > fromJson($1 ?? {})
    • Android Studio

      • Android Studio(启动并完成设置向导, Configure/Plugins安装: Flutter, Dart)
      • shell执行: flutter doctor --android-licenses
      • Perferences:

        • Flutter Sdk path: <user>/fvm/versions/stable
        • Dart Sdk path: <user>/fvm/versions/stable/bin/cache/dart-sdk
    模拟器
    • Android模拟器, Android Studio配置:

      • Configure/Tools - AVD Manager, Create Virtual Device, 选择一个设备, Next.
      • 其他版本Android: Preferences - Appearance & Behavior - System Settings - Android SDK, 勾选版本(比如: Android 8.0)安装.
    • IOS模拟器, Xcode配置:

      • Open Developer Tool - Simulator, Hardware - Device, 选择iOS和iPhone型号.
      • 其他版本iOS: Perferences - Components, Simulator 选择一个iOS版本下载.
    flutter emulators # 列出模拟器
    # flutter emulators --launch apple_ios_simulator # 启动模拟器

    环境搭建完毕, 推荐用VSCore开发.

    查看全文 »