2024年7月

第 1 步:yarn镜像配置

yarn config set registry https://registry.npmmirror.com -g
yarn config set disturl https://npmmirror.com/dist -g
yarn config set electron_mirror https://npmmirror.com/mirrors/electron/ -g
yarn config set sass_binary_site https://npmmirror.com/mirrors/node-sass/ -g
yarn config set phantomjs_cdnurl https://npmmirror.com/mirrors/phantomjs/ -g
yarn config set chromedriver_cdnurl https://cdn.npmmirror.com/dist/chromedriver -g
yarn config set operadriver_cdnurl https://cdn.npmmirror.com/dist/operadriver -g
yarn config set fse_binary_host_mirror https://npmmirror.com/mirrors/fsevents -g

第 2 步:创建新应用程序

yarn create electron-app projectname --template=vite

- 阅读剩余部分 -

使用 update-alternatives 进行版本切换

一、 创建 phpv.sh 文件

#!/bin/bash

VERSION=$1

if [ -z "$VERSION" ];then
  echo "请输入要切换的PHP版本"
  echo "可用版本列表: $(dir /etc/php)"
  echo "当前版本信息:"
  php -v
  exit
fi

sudo update-alternatives --set php /usr/bin/php${VERSION}

php -v

二、 添加执行权限

chmod+x phpv.sh

三、 创建别名, .profile 增加如下代码

alias phpv='/home/用户目录/script/phpv.sh'

使用Docker Desktop配置好本地PHP开发环境,发现打开一个链接都要花上好几秒时间,研究发现原因在于把本地项目文件挂载到容器中,但是Windows文件挂载到WSL2文件I/O性能非常差,这就是慢的原因。

不要使用 Docker Desktop,安装WSL2,把WSL2当服务器使用,在里面安装Docker,项目文件也不要放在Windows目录,直接放WSL2里面,性能飞起。

安装前修改以下目录和文件权限为777

chmod 777 runtime -R
chmod 777 application/database.php
chmod 777 application/config.php
chmod 777 public
chmod 777 application/extra/site.php
chmod 777 application/admin/command/Install
chmod 777 public/uploads
chmod 777 public/assets/js/addons.js
chmod 777 application/extra/addons.php

安装后修复以下目录和文件权限

chmod 644 application/database.php
chmod 644 application/config.php
chmod 755 public
chmod 755 application/admin/command/Install