Skip to content

Commit

Permalink
Merge branch 'master' of github.com:kuaifan/dootask into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	public/css/app.css
#	public/js/app.js
#	public/js/build/120.js
#	public/js/build/120.js.LICENSE.txt
#	public/js/build/198.js
#	public/js/build/494.js
#	public/js/build/79.js
#	public/js/build/793.js
#	public/js/build/875.js
#	public/js/build/890.js
#	resources/assets/js/components/DrawerOverlay.vue
  • Loading branch information
kuaifan committed Jan 17, 2022
2 parents f0ce6cc + e1ef9a9 commit 1abd783
Show file tree
Hide file tree
Showing 54 changed files with 1,091 additions and 305 deletions.
35 changes: 31 additions & 4 deletions app/Module/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ public static function hostContrast($var1, $var2)
public static function getHost($var = '')
{
if (empty($var)) {
$var = url("/");
$var = self::url();
}
$arr = parse_url($var);
return $arr['host'];
Expand Down Expand Up @@ -756,7 +756,7 @@ public static function fillUrl($str = '')
) {
return $str;
} else {
return Base::leftDelete(url($str), "http://localhost");
return self::url($str);
}
}

Expand All @@ -773,8 +773,35 @@ public static function unFillUrl($str = '')
}
return $str;
}
$find = url('');
return Base::leftDelete($str, $find . '/');
return Base::leftDelete($str, self::url() . '/');
}

/**
* 获取url
* @param $path
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Routing\UrlGenerator|string
*/
public static function url($path = '')
{
try {
$url = url($path);
if (str_starts_with($url, "http://localhost/")) {
$url = "http://localhost:" . env("APP_PORT", "80") . "/" . substr($url, 17);
}
} catch (\Throwable) {
$url = self::getSchemeAndHost() . "/" . $path;
}
return $url;
}

/**
* 获取主地址
* @return string 如:http://127.0.0.1:8080
*/
public static function getSchemeAndHost()
{
$scheme = isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://';
return $scheme.($_SERVER['HTTP_HOST'] ?? '');
}

/**
Expand Down
55 changes: 42 additions & 13 deletions cmd
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ rand() {
echo $(($num%$max+$min))
}

rand_string() {
local lan=$1
if [[ `uname` == 'Linux' ]]; then
echo "$(date +%s%N | md5sum | cut -c 1-${lan})"
else
echo "$(docker run -it --rm alpine sh -c "date +%s%N | md5sum | cut -c 1-${lan}")"
fi
}

supervisorctl_restart() {
local RES=`run_exec php "supervisorctl update $1"`
if [ -z "$RES" ]; then
Expand Down Expand Up @@ -117,10 +126,10 @@ run_exec() {
echo -e "${Error} ${RedBG} 没有找到 $container 容器! ${Font}"
exit 1
fi
if [ "$container" = "mariadb" ] || [ "$container" = "nginx" ] || [ "$container" = "redis" ]; then
docker exec -it "$name" /bin/sh -c "$cmd"
else
if [ "$container" = "php" ]; then
docker exec -it "$name" /bin/bash -c "$cmd"
else
docker exec -it "$name" /bin/sh -c "$cmd"
fi
}

Expand Down Expand Up @@ -178,8 +187,11 @@ env_set() {
if [ -z "$exist" ]; then
echo "$key=$val" >> $cur_path/.env
else
command="sed -i '/^$key=/c\\$key=$val' /www/.env"
docker run -it --rm -v ${cur_path}:/www alpine sh -c "$command"
if [[ `uname` == 'Linux' ]]; then
sed -i "/^${key}=/c\\${key}=${val}" /www/.env
else
docker run -it --rm -v ${cur_path}:/www alpine sh -c "sed -i "/^${key}=/c\\${key}=${val}" /www/.env"
fi
if [ $? -ne 0 ]; then
echo -e "${Error} ${RedBG} 设置env参数失败!${Font}"
exit 1
Expand All @@ -192,10 +204,10 @@ env_init() {
cp .env.docker .env
fi
if [ -z "$(env_get DB_ROOT_PASSWORD)" ]; then
env_set DB_ROOT_PASSWORD "$(docker run -it --rm alpine sh -c "date +%s%N | md5sum | cut -c 1-16")"
env_set DB_ROOT_PASSWORD "$(rand_string 16)"
fi
if [ -z "$(env_get APP_ID)" ]; then
env_set APP_ID "$(docker run -it --rm alpine sh -c "date +%s%N | md5sum | cut -c 1-6")"
env_set APP_ID "$(rand_string 6)"
fi
if [ -z "$(env_get APP_IPPR)" ]; then
env_set APP_IPPR "10.$(rand 50 100).$(rand 100 200)"
Expand All @@ -207,16 +219,28 @@ arg_get() {
local value=""
for var in $cur_arg; do
if [[ "$find" == "y" ]]; then
value=$var
if [[ ! $var =~ "--" ]]; then
value=$var
fi
break
fi
if [[ "--$1" == "$var" ]] || [[ "-$1" == "$var" ]]; then
find="y"
value="yes"
fi
done
echo $value
}

is_arm() {
local get_arch=`arch`
if [[ $get_arch =~ "aarch" ]] || [[ $get_arch =~ "arm" ]]; then
echo "yes"
else
echo "no"
fi
}

####################################################################################
####################################################################################
####################################################################################
Expand All @@ -229,6 +253,11 @@ fi
if [ $# -gt 0 ]; then
if [[ "$1" == "init" ]] || [[ "$1" == "install" ]]; then
shift 1
# 判断架构
if [[ "$(is_arm)" == "yes" ]] && [[ -z "$(arg_get force)" ]]; then
echo -e "${Error} ${RedBG}暂不支持arm架构,强制安装请使用:./cmd install --force${Font}"
exit 1
fi
# 初始化文件
rm -rf composer.lock
rm -rf package-lock.json
Expand Down Expand Up @@ -302,9 +331,9 @@ if [ $# -gt 0 ]; then
echo -e "${OK} ${GreenBG} 卸载完成 ${Font}"
elif [[ "$1" == "reinstall" ]]; then
shift 1
./cmd uninstall
./cmd uninstall $@
sleep 3
./cmd install
./cmd install $@
elif [[ "$1" == "port" ]]; then
shift 1
env_set APP_PORT "$1"
Expand Down Expand Up @@ -367,10 +396,10 @@ if [ $# -gt 0 ]; then
elif [[ "$1" == "composer" ]]; then
shift 1
e="composer $@" && run_exec php "$e"
elif [[ "$1" == "super" ]]; then
elif [[ "$1" == "service" ]]; then
shift 1
supervisorctl_restart "$@"
elif [[ "$1" == "supervisorctl" ]]; then
e="service $@" && run_exec php "$e"
elif [[ "$1" == "super" ]] || [[ "$1" == "supervisorctl" ]]; then
shift 1
e="supervisorctl $@" && run_exec php "$e"
elif [[ "$1" == "models" ]]; then
Expand Down
2 changes: 2 additions & 0 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public function run()
$this->call(FilesTableSeeder::class);
$this->call(FileUsersTableSeeder::class);
$this->call(ProjectColumnsTableSeeder::class);
$this->call(ProjectFlowItemsTableSeeder::class);
$this->call(ProjectFlowsTableSeeder::class);
$this->call(ProjectLogsTableSeeder::class);
$this->call(ProjectTaskContentsTableSeeder::class);
$this->call(ProjectTaskUsersTableSeeder::class);
Expand Down
Loading

0 comments on commit 1abd783

Please sign in to comment.