跳到主要内容
zyfrontend
一个全栈开发
查看所有作者

React Native 创建项目

· 阅读需 1 分钟
zyfrontend
一个全栈开发

创建项目cli

npx @react-native-community/cli@latest init Project_name

Watchman

你在 .watchmanconfig 配置了 ignore_dirs,目的是让 Watchman 忽略一些目录。如果修改了配置,需要让 Watchman 重新加载配置或重启 Watchman 监控。可以按照以下步骤操作:


1. 清理 Watchman 的状态缓存

watchman watch-del-all

这会移除所有 Watchman 的监控项目和缓存。


2. 重新启动 Watchman

一般 Watchman 是守护进程,会在后台自动启动,但你可以确保它重新加载配置:

watchman shutdown-server

这会停止 Watchman 的守护进程,下一次有监控请求时会自动启动。


3. 再次启动监控

在项目根目录运行:

watchman watch-project .

这会重新添加当前目录的监控,并应用新的 .watchmanconfig 配置。


4. 验证配置生效

watchman watch-list

确认你的项目被监控,同时 Watchman 不会再监控 ignore_dirs 中列出的目录。


💡 小提示:每次修改 .watchmanconfig 后,最好执行 watchman watch-del-all && watchman watch-project .,避免旧缓存影响。


Git的一些设置

· 阅读需 1 分钟
zyfrontend
一个全栈开发

git多账号配置

当一台电脑需要配置两个git,一个用来提交个人代码,一个用来提交工作代码

生成两个 SSH Key

# 生成个人 SSH Key
ssh-keygen -t rsa -C "个人邮箱@gmail.com" -f ~/.ssh/id_rsa_personal

# 生成工作 SSH Key
ssh-keygen -t rsa -C "工作邮箱gmail.com" -f ~/.ssh/id_rsa_work

配置 SSH Config

编辑 ~/.ssh/config 文件:

# 个人账号
Host github.com-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_personal

# 工作账号
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_work

添加 SSH 公钥到远程仓库

此略

使用说明

  1. 工作仓库

当远程工作仓库地址为git@github.com:github账号名/hello.git 如果想克隆下来需要修改一下: git clone git@github.com-work:github账号名/hello.git

  1. 个人仓库

当远程个人仓库地址为git@github.com:github账号名/hello.git 如果想克隆下来需要修改一下: git clone git@github.com-personal:github账号名/hello.git

  1. 本地已经有代码了,需设置远程仓库

git remote add origin git@github.com-work:github账号名/hello.git

Mac的一些设置

· 阅读需 1 分钟
zyfrontend
一个全栈开发
  • 加速按键重复响应(比系统设置面板更快)
defaults write -g InitialKeyRepeat -int 15
defaults write -g KeyRepeat -int 2

MySQL和Redis的安装

· 阅读需 1 分钟
zyfrontend
一个全栈开发

🍺 前置条件

先确认你是否安装了 Homebrew(Mac 常用的包管理器):

brew -v

如果没有,执行:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

一、安装 MySQL

  1. 安装 MySQL:

    brew install mysql
  2. 启动 MySQL 服务:

    brew services start mysql

    (如果只想临时运行,可以用 mysql.server start

  3. 登录 MySQL:

    mysql -u root
  4. 设置 root 密码(第一次可能为空密码):

    ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
    FLUSH PRIVILEGES;
  5. 停止 MySQL:

    brew services stop mysql

二、安装 Redis

  1. 安装 Redis:

    brew install redis
  2. 启动 Redis 服务:

    brew services start redis

    (临时启动可以用:redis-server /opt/homebrew/etc/redis.conf

  3. 测试 Redis:

    redis-cli

    输入:

    ping

    返回 PONG 表示正常运行。

  4. 停止 Redis:

    brew services stop redis

三、常用命令汇总

  • 查看运行的服务:

    brew services list
  • 重启 MySQL:

    brew services restart mysql
  • 重启 Redis:

    brew services restart redis

这样安装后,MySQL 默认监听 3306 端口,Redis 默认监听 6379 端口,你在本机就可以直接用客户端连接了。