feat: 添加项目库组件并优化搜索页面样式和功能
新增项目库组件item-project,包含学校、专业、学费等信息的展示 优化搜索页面样式,调整分类项宽度和间距 修复搜索页面滚动定位问题,完善分页和URL参数处理 添加本地开发服务器脚本serve.ps1 更新public.css和public.less样式文件
This commit is contained in:
56
serve.ps1
Normal file
56
serve.ps1
Normal file
@@ -0,0 +1,56 @@
|
||||
$base = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$listener = [System.Net.Sockets.TcpListener]::new([System.Net.IPAddress]::Loopback, 5501)
|
||||
$listener.Start()
|
||||
Write-Host "http://127.0.0.1:5501/"
|
||||
while ($true) {
|
||||
$client = $listener.AcceptTcpClient()
|
||||
try {
|
||||
$stream = $client.GetStream()
|
||||
$reader = New-Object System.IO.StreamReader($stream, [System.Text.Encoding]::ASCII, $false, 1024, $true)
|
||||
$writer = New-Object System.IO.StreamWriter($stream)
|
||||
$writer.AutoFlush = $true
|
||||
$requestLine = $reader.ReadLine()
|
||||
if (-not $requestLine) { $client.Close(); continue }
|
||||
while ($true) { $line = $reader.ReadLine(); if ($line -eq $null -or $line -eq "") { break } }
|
||||
$rawPath = "/"
|
||||
if ($requestLine -match "^GET\s+([^\s]+)") { $rawPath = $matches[1] }
|
||||
$pathOnly = $rawPath.Split("?")[0]
|
||||
$pathOnly = [System.Uri]::UnescapeDataString($pathOnly)
|
||||
$reqExt = [System.IO.Path]::GetExtension($pathOnly)
|
||||
if ($pathOnly -like "/search/*" -and [string]::IsNullOrEmpty($reqExt)) { $file = Join-Path $base "search.html" }
|
||||
elseif ($pathOnly -eq "/") { $file = Join-Path $base "index.html" }
|
||||
else { $rel = $pathOnly.TrimStart("/"); $file = Join-Path $base $rel }
|
||||
if (-not (Test-Path $file)) {
|
||||
$status = "404 Not Found"
|
||||
$body = [System.Text.Encoding]::UTF8.GetBytes("Not Found")
|
||||
$contentType = "text/plain; charset=utf-8"
|
||||
}
|
||||
else {
|
||||
$status = "200 OK"
|
||||
$body = [System.IO.File]::ReadAllBytes($file)
|
||||
$ext = [System.IO.Path]::GetExtension($file).ToLower()
|
||||
switch ($ext) {
|
||||
".html" { $contentType = "text/html; charset=utf-8" }
|
||||
".css" { $contentType = "text/css" }
|
||||
".js" { $contentType = "application/javascript" }
|
||||
".png" { $contentType = "image/png" }
|
||||
".jpg" { $contentType = "image/jpeg" }
|
||||
".jpeg" { $contentType = "image/jpeg" }
|
||||
".svg" { $contentType = "image/svg+xml" }
|
||||
".json" { $contentType = "application/json" }
|
||||
".ico" { $contentType = "image/x-icon" }
|
||||
default { $contentType = "application/octet-stream" }
|
||||
}
|
||||
}
|
||||
$writer.WriteLine("HTTP/1.1 $status")
|
||||
$writer.WriteLine("Content-Type: $contentType")
|
||||
$writer.WriteLine("Content-Length: " + $body.Length)
|
||||
$writer.WriteLine("Connection: close")
|
||||
$writer.WriteLine("")
|
||||
$stream.Write($body, 0, $body.Length)
|
||||
} catch {
|
||||
try { $client.Close() } catch {}
|
||||
} finally {
|
||||
try { $client.Close() } catch {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user