<?php
 namespace App\Api\Controller; use ModStart\Core\Assets\AssetsUtil; use ModStart\Core\Input\Response; use ModStart\Core\Type\TypeUtil; use ModStart\Core\Util\ConstantUtil; use Module\Doc\Type\DocType; use Module\Lottery\Type\ActivityJoinMode; use Module\Lottery\Type\ActivityType; use Module\Lottery\Type\AmountType; use Module\Lottery\Type\CreditType; use Module\Lottery\Type\PrizeType; use Module\Lottery\Type\RedbagType; use Module\Member\Auth\MemberUser; use Module\Member\Auth\MemberVip; use Module\Member\Type\MemberMessageStatus; use Module\Member\Util\MemberVipUtil; use Module\Paper\Type\PaperExamStatus; use Module\Question\Api\Controller\QuestionTagController; use Module\Question\Type\QuestionType; use Module\Vendor\Cache\LazyValueUtil; use Module\Vendor\Support\ResponseCodes; class ConfigController extends BaseController { public function constant() { $constants = []; $constants['ActivityType'] = TypeUtil::dump(ActivityType::class); $constants['PrizeType'] = TypeUtil::dump(PrizeType::class); $constants['RedbagType'] = TypeUtil::dump(RedbagType::class); $constants['CreditType'] = TypeUtil::dump(CreditType::class); $constants['ActivityJoinMode'] = TypeUtil::dump(ActivityJoinMode::class); $constants['AmountType'] = TypeUtil::dump(AmountType::class); $content = []; $content [] = "// This file is created by " . action('\\' . __CLASS__ . '@constant') . "\n"; foreach ($constants as $name => $json) { $content[] = "export const $name = " . json_encode($json, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) . ";"; } return Response::raw(join("\n", $content), ['Content-Type' => 'text/plain']); } public function app() { $data = []; list($view, $_) = $this->viewPaths('index'); $hash = date('Ymd_His', filemtime($this->viewRealpath($view))); $data['hashPC'] = 'v' . $hash; $data['hashLazyValue'] = []; $data['user'] = [ 'id' => 0, 'avatar' => AssetsUtil::fixFull('asset/image/avatar.png'), 'avatarMedium' => AssetsUtil::fixFull('asset/image/avatar.png'), 'avatarBig' => AssetsUtil::fixFull('asset/image/avatar.png'), 'nickname' => '', 'username' => '', 'phone' => '', 'phoneVerified' => false, 'email' => '', 'emailVerified' => false, 'vip' => null, 'vipExpire' => null, ]; if (MemberUser::id()) { $memberUser = MemberUser::user(); $data['user']['id'] = $memberUser['id']; $data['user']['avatar'] = AssetsUtil::fixFull($memberUser['avatar'] ? $memberUser['avatar'] : $data['user']['avatar']); $data['user']['avatarMedium'] = AssetsUtil::fixFull($memberUser['avatarMedium'] ? $memberUser['avatarMedium'] : $data['user']['avatar']); $data['user']['avatarBig'] = AssetsUtil::fixFull($memberUser['avatarBig'] ? $memberUser['avatarBig'] : $data['user']['avatar']); $data['user']['username'] = $memberUser['username']; $data['user']['nickname'] = empty($memberUser['nickname']) ? null : $memberUser['nickname']; if (empty($data['user']['nickname'])) { $data['user']['nickname'] = $data['user']['username']; } $data['user']['phone'] = $memberUser['phone']; $data['user']['phoneVerified'] = !!$memberUser['phoneVerified']; $data['user']['email'] = $memberUser['email']; $data['user']['emailVerified'] = !!$memberUser['emailVerified']; $data['user']['vip'] = MemberVip::get(); $data['user']['vipExpire'] = $memberUser['vipExpire']; $data['hashLazyValue']['QuestionTags'] = LazyValueUtil::hash("QuestionTags", function () { return app(QuestionTagController::class)->all(); }); } return Response::jsonSuccessData($data); } } 