| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php
- namespace App\Livewire;
- use App\Livewire\Traits\WithMathRender;
- use Livewire\Attributes\Computed;
- use Livewire\Component;
- class MathRenderTest extends Component
- {
- use WithMathRender;
- public string $search = '';
- public int $currentPage = 1;
- public array $sampleQuestions = [
- [
- 'code' => 'Q001',
- 'content' => '已知二次函数 $f(x) = ax^2 + bx + c$,求 $f(2)$ 的值。',
- 'difficulty' => 0.3,
- ],
- [
- 'code' => 'Q002',
- 'content' => '计算定积分:$$\int_0^1 x^2 dx$$',
- 'difficulty' => 0.6,
- ],
- [
- 'code' => 'Q003',
- 'content' => '证明三角恒等式:$\sin^2(x) + \cos^2(x) = 1$',
- 'difficulty' => 0.85,
- ],
- [
- 'code' => 'Q004',
- 'content' => '求极限:$$\lim_{x \to 0} \frac{\sin(x)}{x}$$',
- 'difficulty' => 0.7,
- ],
- [
- 'code' => 'Q005',
- 'content' => '解方程:$ax^2 + bx + c = 0$',
- 'difficulty' => 0.4,
- ],
- ];
- #[Computed]
- public function questions(): array
- {
- $filtered = array_filter($this->sampleQuestions, function($question) {
- if (empty($this->search)) {
- return true;
- }
- return str_contains(strtolower($question['content']), strtolower($this->search));
- });
- return array_values($filtered);
- }
- public function render()
- {
- return view('livewire.math-render-test');
- }
- }
|