From 34667f317fbb51788b5ba0ef51b8d855b805e7de Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Mon, 27 Feb 2023 17:25:39 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E5=9F=9F=E5=90=8D=E5=B7=A5=E5=85=B7=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/config/console.php | 5 ++- crmeb/crmeb/command/Util.php | 77 ++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 crmeb/crmeb/command/Util.php diff --git a/crmeb/config/console.php b/crmeb/config/console.php index d46c57129..c4e89ddaf 100644 --- a/crmeb/config/console.php +++ b/crmeb/config/console.php @@ -14,13 +14,14 @@ // +---------------------------------------------------------------------- return [ // 执行用户(Windows下无效) - 'user' => null, + 'user' => null, // 指令定义 'commands' => [ 'workerman' => \crmeb\command\Workerman::class, 'timer' => \crmeb\command\Timer::class, 'make:business' => \crmeb\command\Business::class, 'make:dao' => \crmeb\command\Dao::class, - 'make:service'=>\crmeb\command\Service::class, + 'make:service' => \crmeb\command\Service::class, + 'util' => \crmeb\command\Util::class ], ]; diff --git a/crmeb/crmeb/command/Util.php b/crmeb/crmeb/command/Util.php new file mode 100644 index 000000000..f34e48809 --- /dev/null +++ b/crmeb/crmeb/command/Util.php @@ -0,0 +1,77 @@ +setName('util') + ->addArgument('type', Argument::REQUIRED, '类型replace') + ->addOption('h', null, Option::VALUE_REQUIRED, '替换成当前域名') + ->addOption('u', null, Option::VALUE_REQUIRED, '替换的域名') + ->setDescription('工具类'); + } + + protected function execute(Input $input, Output $output) + { + $type = $input->getArgument('type'); + + switch ($type) { + case 'replace': + $host = $input->getOption('h'); + $url = $input->getOption('u'); + if (!$host) { + return $output->error('缺少替换域名'); + } + if (!$url) { + return $output->error('缺少替换的域名'); + } + $this->replaceSiteUrl($host, $url); + break; + } + + $output->info('执行成功'); + } + + protected function replaceSiteUrl(string $url, string $siteUrl) + { + $siteUrlJosn = str_replace('http://', 'http:\\\/\\\/', $siteUrl); + $valueJosn = str_replace('http://', 'http:\\\/\\\/', $url); + $prefix = Config::get('database.connections.' . Config::get('database.default') . '.prefix'); + $sql = [ + "UPDATE `{$prefix}system_attachment` SET `att_dir` = replace(att_dir ,'{$siteUrl}','{$url}'),`satt_dir` = replace(satt_dir ,'{$siteUrl}','{$url}')", + "UPDATE `{$prefix}store_product` SET `image` = replace(image ,'{$siteUrl}','{$url}'),`slider_image` = replace(slider_image ,'{$siteUrlJosn}','{$valueJosn}')", + "UPDATE `{$prefix}store_product_attr_value` SET `image` = replace(image ,'{$siteUrl}','{$url}')", + "UPDATE `{$prefix}store_seckill` SET `image` = replace(image ,'{$siteUrl}','{$url}'),`images` = replace(images,'{$siteUrlJosn}','{$valueJosn}')", + "UPDATE `{$prefix}store_combination` SET `image` = replace(image ,'{$siteUrl}','{$url}'),`images` = replace(images,'{$siteUrlJosn}','{$valueJosn}')", + "UPDATE `{$prefix}store_bargain` SET `image` = replace(image ,'{$siteUrl}','{$url}'),`images` = replace(images,'{$siteUrlJosn}','{$valueJosn}')", + "UPDATE `{$prefix}system_config` SET `value` = replace(value ,'{$siteUrlJosn}','{$valueJosn}')", + "UPDATE `{$prefix}article_category` SET `image` = replace(`image` ,'{$siteUrl}','{$url}')", + "UPDATE `{$prefix}article` SET `image_input` = replace(`image_input` ,'{$siteUrl}','{$url}')", + "UPDATE `{$prefix}article_content` SET `content` = replace(`content` ,'{$siteUrl}','{$url}')", + "UPDATE `{$prefix}store_category` SET `pic` = replace(`pic` ,'{$siteUrl}','{$url}')", + "UPDATE `{$prefix}system_group_data` SET `value` = replace(value ,'{$siteUrlJosn}','{$valueJosn}')", + "UPDATE `{$prefix}store_product_description` SET `description`= replace(description,'{$siteUrl}','{$url}')" + ]; + return Db::transaction(function () use ($sql) { + try { + foreach ($sql as $item) { + Db::execute($item); + } + } catch (\Throwable $e) { + throw new AdminException(400612, ['msg' => $e->getMessage()]); + } + }); + } +} From be165c8476d05d52c664ca5e2f090e737ecfa179 Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Mon, 27 Feb 2023 17:28:51 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/crmeb/command/Util.php | 1 + 1 file changed, 1 insertion(+) diff --git a/crmeb/crmeb/command/Util.php b/crmeb/crmeb/command/Util.php index f34e48809..10a84e3fc 100644 --- a/crmeb/crmeb/command/Util.php +++ b/crmeb/crmeb/command/Util.php @@ -62,6 +62,7 @@ class Util extends Command "UPDATE `{$prefix}article_content` SET `content` = replace(`content` ,'{$siteUrl}','{$url}')", "UPDATE `{$prefix}store_category` SET `pic` = replace(`pic` ,'{$siteUrl}','{$url}')", "UPDATE `{$prefix}system_group_data` SET `value` = replace(value ,'{$siteUrlJosn}','{$valueJosn}')", + "UPDATE `{$prefix}eb_diy` SET `value` = replace(value ,'{$siteUrlJosn}','{$valueJosn}')", "UPDATE `{$prefix}store_product_description` SET `description`= replace(description,'{$siteUrl}','{$url}')" ]; return Db::transaction(function () use ($sql) { From eef88e5ea3e76fa5ad51db2280a6367d96fd0f04 Mon Sep 17 00:00:00 2001 From: From-wh Date: Mon, 27 Feb 2023 17:30:15 +0800 Subject: [PATCH 3/4] =?UTF-8?q?improve:=20=E9=A1=B6=E9=83=A8=E6=93=8D?= =?UTF-8?q?=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/components/header-bar/header-bar.vue | 1 + .../main/components/header-notice/index.vue | 9 ++++++--- .../main/components/reload/reload.vue | 18 ++++++++++-------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/template/admin/src/components/main/components/header-bar/header-bar.vue b/template/admin/src/components/main/components/header-bar/header-bar.vue index 9c3d95959..2dfc22fc2 100644 --- a/template/admin/src/components/main/components/header-bar/header-bar.vue +++ b/template/admin/src/components/main/components/header-bar/header-bar.vue @@ -19,6 +19,7 @@