Icon.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace core\dict;
  12. /**
  13. * 图标
  14. * Class Icon
  15. * @package core\dict
  16. */
  17. class Icon extends BaseDict
  18. {
  19. /**
  20. * @param array $data
  21. * @return array
  22. */
  23. public function load(array $data): array
  24. {
  25. $sys_path = dirname(app()->getRootPath()) . str_replace('/', DIRECTORY_SEPARATOR, '/admin/src/styles/icon');
  26. $file_arr = getFileMap($sys_path);
  27. $icon_arr = [];
  28. if (!empty($file_arr)) {
  29. foreach ($file_arr as $ck => $cv) {
  30. if (str_contains($cv, '.json')) {
  31. $json_string = file_get_contents($ck);
  32. $icon = json_decode($json_string, true, 512, JSON_THROW_ON_ERROR);
  33. $icon_arr[] = $icon;
  34. }
  35. }
  36. }
  37. if (count($icon_arr) > 1) {
  38. $last_icon = array_pop($icon_arr); // 最后一个
  39. $first_icon = array_shift($icon_arr); // 第一个
  40. array_unshift($icon_arr, $last_icon); // 将系统图标放到第一位置
  41. $icon_arr[] = $first_icon; // 交换位置
  42. }
  43. return $icon_arr;
  44. }
  45. }