diff --git a/src/Module/Api/AccountController.php b/src/Module/Api/AccountController.php index aba712e..201d346 100644 --- a/src/Module/Api/AccountController.php +++ b/src/Module/Api/AccountController.php @@ -17,6 +17,7 @@ use Windwalker\DI\Attributes\Autowire; use Windwalker\DI\Attributes\Service; use Windwalker\Filesystem\FileObject; +use Windwalker\Filesystem\Path; use Windwalker\Filesystem\TempFileObject; use Windwalker\Http\Response\AttachmentResponse; use Windwalker\ORM\ORM; @@ -74,7 +75,7 @@ public function items( public function logoSearch(AppContext $app): array { - $q = (string) $app->input('q'); + $q = (string) $app->input('q') ?: 'key'; $color = (string) $app->input('color') ?: '#ffffff'; $dir = fs(WINDWALKER_ROOT . '/node_modules/@fortawesome/fontawesome-free/svgs'); @@ -85,16 +86,18 @@ public function logoSearch(AppContext $app): array if ($directFile->exists()) { $image = $this->readImageIcon($directFile, $color, $app); + $icon = $directFile->getBasename('.svg'); - return compact('image'); + return compact('image', 'icon'); } $directFile = $dir->appendPath('/brands/' . $searchText . '.svg'); if ($directFile->exists()) { $image = $this->readImageIcon($directFile, $color, $app); + $icon = $directFile->getBasename('.svg'); - return compact('image'); + return compact('image', 'icon'); } foreach ($dir->files(true) as $file) { @@ -102,13 +105,15 @@ public function logoSearch(AppContext $app): array if (str_contains($basename, $searchText)) { $image = $this->readImageIcon($file, $color, $app); + $icon = $file->getBasename('.svg'); - return compact('image'); + return compact('image', 'icon'); } } return [ - 'image' => '' + 'image' => '', + 'icon' => '', ]; } @@ -164,6 +169,11 @@ public function save( ); $image = (string) $result?->getUri(); + if (!Path::isAbsolute($image)) { + $systemUri = $app->getSystemUri(); + $image = $systemUri->addUriBase($image, $systemUri->root); + } + $account->setImage($image); $account = $orm->createOne(Account::class, $account);