Console.php 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <?php namespace Manage\Api;
  2. use Dever;
  3. use Manage\Lib\Auth;
  4. class Console extends Auth
  5. {
  6. # 控制台首页
  7. public function index()
  8. {
  9. $config = Dever::config('manage');
  10. $data['layout'] = [
  11. [
  12. 'tip' => 24,
  13. ],
  14. ];
  15. $data['tip'] = [
  16. 'type' => 'tip',
  17. 'name' => $this->getMsg($this->user['name']),
  18. 'content' => '您正在使用{title},请通过左侧导航栏选择需要操作的模块。祝你工作愉快!',
  19. ];
  20. if (isset($config['console']) && $config['console']) {
  21. $data = Dever::call($config['console'], [$data]);
  22. }
  23. return $data;
  24. }
  25. # 问候语
  26. private function getMsg($username, $lang = 'zh')
  27. {
  28. $hour = date('H');
  29. if ($hour < 8) {
  30. $period = 'morning_early';
  31. } elseif ($hour <= 11) {
  32. $period = 'morning';
  33. } elseif ($hour <= 13) {
  34. $period = 'noon';
  35. } elseif ($hour < 18) {
  36. $period = 'afternoon';
  37. } else {
  38. $period = 'evening';
  39. }
  40. $greetings = [
  41. 'zh' => [
  42. 'morning_early' => [
  43. "新的一天开始啦,{username},愿你充满能量与好心情 🌅",
  44. "早上好,{username}!今天也要元气满满地出发 ☀️",
  45. "又是充满希望的一天,{username},愿你元气满满 ✨",
  46. "清晨的阳光最温柔,祝你一天好心情,{username} 🌞",
  47. "清晨的努力,是成功的开始,加油,{username}!",
  48. "起这么早,是被梦想叫醒的,还是被闹钟吓醒的?⏰,{username}",
  49. "早安,{username},太阳都羡慕你勤劳 🌞",
  50. "日出东方,一切皆静,{username} 🌄",
  51. "时间不语,却回答一切,{username} 🧘",
  52. "越努力,越幸运,新的一天,加油,{username} 💪",
  53. "今天做的每一件小事,都是未来的伏笔,{username} 📝",
  54. "美好的一天从早晨开始,{username},加油!",
  55. "黎明的第一缕光,送给勤奋的你,{username}。",
  56. ],
  57. 'morning' => [
  58. "上午好,{username}!看到你上线真开心 😄",
  59. "今天也要高效完成每一项任务,加油,{username} 💪",
  60. "专注的你,最有魅力,{username} 🧠",
  61. "把事情做到最好,是你的风格,{username} 🔧",
  62. "保持节奏,每一天都值得记录,{username} 📅",
  63. "上午好,{username}!今天也要继续摸鱼计划 🐟",
  64. "再摸一会鱼,就到中午了,加油,{username} ✊",
  65. "你走你的路,花自开,{username} 🌸",
  66. "心静则清,行稳则远,{username} 🌿",
  67. "你正在书写属于你自己的不凡人生,{username} 📖",
  68. "相信自己,你比想象中更强大,{username} ✨",
  69. "每个上午都是新的开始,{username},抓住机会!",
  70. "专注且坚定,{username},你值得赞扬!",
  71. ],
  72. 'noon' => [
  73. "中午好,{username}!记得按时吃饭补充能量 🍱",
  74. "工作再忙,也别忘了照顾自己,{username} ❤️",
  75. "好好吃饭,下午才有力气继续冲,{username} 💼",
  76. "中场休息,补充体力,{username} 🌯",
  77. "饭不吃饱,哪有力气摸鱼,{username} 🐠",
  78. "中午不休息,下午徒伤悲,{username} 😵",
  79. "饭要好好吃,觉要好好睡,{username} 🌿",
  80. "坐看云起时,不争一时高下,{username} ☁️",
  81. "每一次坚持,都是积累能量,{username} 🔋",
  82. "中午短暂放松,是为了更好出发,{username} 🚀",
  83. "阳光正好,{username},午饭别忘了吃饱哦!",
  84. "充能中,{username},下午继续加油!",
  85. ],
  86. 'afternoon' => [
  87. "下午好,{username}!来杯咖啡提提神 ☕",
  88. "再坚持一会儿,胜利就在眼前,{username} 🏁",
  89. "保持专注,继续向前,{username} 💼",
  90. "喝口水,伸个懒腰,继续冲,{username} 💨",
  91. "摸鱼也需要节奏,别太张扬,{username} 😏",
  92. "困了就看老板照片提神,{username} 🧃",
  93. "一花一世界,一念一清净,{username} 🪷",
  94. "茶要慢饮,事要缓做,{username} 🍵",
  95. "你所付出的努力,终将照亮前路,{username} 💡",
  96. "不怕慢,只怕站,坚持走就对了,{username} 🛤️",
  97. "努力的下午,{username},胜利不远了!",
  98. "冲刺时间到,{username},继续燃烧吧!",
  99. ],
  100. 'evening' => [
  101. "晚上好,{username}!愿你天黑有灯,下雨有伞 🌙",
  102. "今天也辛苦啦,好好休息,{username} 🛏️",
  103. "收工啦,放松一下,明天继续努力,{username} ✨",
  104. "一天结束了,给自己点个赞,{username} 👍",
  105. "打卡下班是对生活最基本的尊重,{username} 📤",
  106. "今天摸鱼圆满成功,记得下次继续,{username} 🐳",
  107. "夜深人静时,心要平,{username} 💭",
  108. "万事随心,内心清明,{username} ✨",
  109. "收获不在今天,也会在明天到来,{username} 🌟",
  110. "夜晚是沉淀的时刻,也是蓄力的开始,{username} 🌌",
  111. "星空很美,{username},别忘了好好休息!",
  112. "忙碌一天,{username},放松自己,明天更好!",
  113. ],
  114. ],
  115. 'en' => [
  116. 'morning_early' => [
  117. "Good morning {username}! A new day, a new beginning ☀️",
  118. "Wake up, {username}! The sun is shining just for you 🌞",
  119. "Early bird {username}, you’re catching all the worms! 🐦",
  120. "Rise and shine, {username}! Let's seize the day! ✨",
  121. "Morning, {username}! The world awaits your greatness!",
  122. ],
  123. 'morning' => [
  124. "Good morning {username}! Let's make today productive 💪",
  125. "Hey {username}, rise and grind! ☕",
  126. "Keep pushing forward, {username}. Success awaits! 🚀",
  127. "Stay focused, {username}, and make it happen! 🧠",
  128. "Morning hustle, {username}! Keep that energy high!",
  129. "Seize the morning, {username}! Make it count!",
  130. ],
  131. 'noon' => [
  132. "Hi {username}, don't forget to grab some lunch 🍱",
  133. "Take a break, {username}, recharge your energy! ⚡",
  134. "Refuel well, {username}, the afternoon awaits! 🌟",
  135. "Lunch time, {username}! Enjoy your meal 🍔",
  136. "Midday break, {username}! Stay refreshed!",
  137. "Keep up the great work, {username}! Almost halfway!",
  138. ],
  139. 'afternoon' => [
  140. "Afternoon vibes, {username}! Keep going strong 💼",
  141. "Almost there, {username}! Keep up the great work 🏆",
  142. "Stay hydrated, {username}, and keep focused! 💧",
  143. "You’re doing great, {username}! Keep pushing! 🔥",
  144. "Keep the momentum, {username}! Afternoon grind!",
  145. "Push through, {username}! The finish line is near!",
  146. ],
  147. 'evening' => [
  148. "Good evening {username}! Time to wind down 🌙",
  149. "Relax and recharge, {username}, you earned it 🛏️",
  150. "Well done today, {username}! See you tomorrow 👋",
  151. "Evenings are for rest, {username}. Take care! 🌌",
  152. "Night falls, {username}. Rest well and dream big!",
  153. "Time to relax, {username}. Tomorrow is a new chance!",
  154. ],
  155. ],
  156. ];
  157. $langGroup = $greetings[$lang] ?? $greetings['zh'];
  158. $lines = $langGroup[$period] ?? $langGroup['morning_early'];
  159. $template = $lines[array_rand($lines)];
  160. return str_replace('{username}', $username, $template);
  161. }
  162. }