This commit is contained in:
2023-04-06 16:52:04 +08:00
commit 7efe885a85
4 changed files with 177 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
/.idea
+8
View File
@@ -0,0 +1,8 @@
{
"/index":{
"title":"Index"
},
"/about":{
"title":"About"
}
}
+1
View File
@@ -0,0 +1 @@
*,::before,::after{-webkit-box-sizing:border-box;box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}*{--tw-ring-inset:var(--tw-empty,/*!*/ /*!*/);--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(59, 130, 246, 0.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000}:root{-moz-tab-size:4;-o-tab-size:4;tab-size:4}:-moz-focusring{outline:1px dotted ButtonText}:-moz-ui-invalid{box-shadow:none}::moz-focus-inner{border-style:none;padding:0}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}[type='search']{-webkit-appearance:textfield;outline-offset:-2px}abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}a{color:inherit;text-decoration:inherit}body{margin:0;font-family:inherit;line-height:inherit}b,strong{font-weight:bolder}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0;padding:0;line-height:inherit;color:inherit}button,select{text-transform:none}button,[type='button'],[type='reset'],[type='submit']{-webkit-appearance:button}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}button{background-color:transparent;background-image:none}button,[role="button"]{cursor:pointer}code,kbd,samp,pre{font-size:1em}fieldset{margin:0;padding:0}html{-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";line-height:1.5}hr{height:0;color:inherit;border-top-width:1px}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}img{border-style:solid;display:block;vertical-align:middle;max-width:100%;height:auto}input::placeholder{opacity:1;color:#9ca3af}input::webkit-input-placeholder{opacity:1;color:#9ca3af}input::-moz-placeholder{opacity:1;color:#9ca3af}input:-ms-input-placeholder{opacity:1;color:#9ca3af}input::-ms-input-placeholder{opacity:1;color:#9ca3af}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}legend{padding:0}ol,ul{list-style:none;margin:0;padding:0}progress{vertical-align:baseline}pre,code,kbd,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace}p{margin:0}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}summary{display:list-item}table{text-indent:0;border-color:inherit;border-collapse:collapse}textarea{resize:vertical}textarea::placeholder{opacity:1;color:#9ca3af}textarea::webkit-input-placeholder{opacity:1;color:#9ca3af}textarea::-moz-placeholder{opacity:1;color:#9ca3af}textarea:-ms-input-placeholder{opacity:1;color:#9ca3af}textarea::-ms-input-placeholder{opacity:1;color:#9ca3af}.space-x-5 > :not([hidden]) ~ :not([hidden]){--tw-space-x-reverse:0;margin-right:calc(1.25rem * var(--tw-space-x-reverse));margin-left:calc(1.25rem * calc(1 - var(--tw-space-x-reverse)))}.bg-red-300{--tw-bg-opacity:1;background-color:rgba(252, 165, 165, var(--tw-bg-opacity))}.bg-cyan-200{--tw-bg-opacity:1;background-color:rgba(165, 243, 252, var(--tw-bg-opacity))}.bg-gray-300{--tw-bg-opacity:1;background-color:rgba(209, 213, 219, var(--tw-bg-opacity))}.bg-red-200{--tw-bg-opacity:1;background-color:rgba(254, 202, 202, var(--tw-bg-opacity))}.bg-red-500{--tw-bg-opacity:1;background-color:rgba(239, 68, 68, var(--tw-bg-opacity))}.bg-red-400{--tw-bg-opacity:1;background-color:rgba(248, 113, 113, var(--tw-bg-opacity))}.bg-black{--tw-bg-opacity:1;background-color:rgba(0, 0, 0, var(--tw-bg-opacity))}.flex{display:-webkit-box;display:-ms-flexbox;display:-webkit-flex;display:flex}.justify-center{-webkit-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center}.h-20{height:5rem}.h-10{height:2.5rem}.h-12{height:3rem}.h-15{height:3.75rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-2xl{font-size:1.5rem;line-height:2rem}.p-5{padding:1.25rem}.p-2{padding:0.5rem}.p-3{padding:0.75rem}.px{padding-left:1px;padding-right:1px}.px-5{padding-left:1.25rem;padding-right:1.25rem}.text-light-200{--tw-text-opacity:1;color:rgba(250, 250, 250, var(--tw-text-opacity))}.w-full{width:100%}@media (min-width: 768px){.md\:p-5{padding:1.25rem}.md\:p-3{padding:0.75rem}.md\:w-2\/3{width:66.666667%}}
+167
View File
@@ -0,0 +1,167 @@
<?php
init();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="/favicon.ico"/>
<title><?php echo get_page_title(); ?></title>
<link rel="stylesheet" href="/css/style.css">
</head>
<body>
<div class="flex h-12 bg-black w-full p-3">
<div class="flex text-xl text-light-200">
Logo
</div>
<div class="flex space-x-5 text-light-200 text-xl px-5">
<div>
<a href="/">Hello</a>
</div>
<div>
<a href="/about">About</a>
</div>
</div>
</div>
<div class="flex justify-center">
<div class="md:w-2/3 w-full p-2 md:p-3">
<?php show_page(); ?>
</div>
</div>
</body>
</html>
<!--page func-->
<?php function show_index()
{
ob_start(); ?>
<div class="">
</div>
<?php
$html = ob_get_contents();
ob_clean();
echo $html;
}
?>
<?php function show_about()
{
ob_start(); ?>
<div class="">
about
</div>
<?php
$html = ob_get_contents();
ob_clean();
echo $html;
}
?>
<?php function show_404()
{
ob_start(); ?>
<div class="">
404 NOT FOUND
</div>
<?php
$html = ob_get_contents();
ob_clean();
echo $html;
}
?>
<!--page func end-->
<!--api-->
<?php
function check_api()
{
$uri = $_SERVER["REQUEST_URI"];
$func = ltrim(implode("_", explode("/", $uri)), "_");
if (str_starts_with($uri, "/api")) {
if (!function_exists($func)) echo_json([
"code" => 1,
"msg" => "uri错误",
"data" => []
]);
call_user_func($func);
}
}
function echo_json($data)
{
header('Content-Type: application/json; charset=utf-8');
echo json_encode($data, JSON_UNESCAPED_UNICODE);
die;
}
function api_test()
{
echo_json([
"code" => 0,
"msg" => "test",
"data" => []
]);
}
?>
<!--api end-->
<!--common func-->
<?php
function init()
{
define("BASE_PATH", __DIR__ . "/../");
define("CONFIG_PATH", BASE_PATH . "/./config/");
empty($_SERVER['REQUEST_URI']) || $_SERVER['REQUEST_URI'] == "/" && $_SERVER['REQUEST_URI'] = "/index";
check_api();
}
function get_page_title()
{
$uri = $_SERVER['REQUEST_URI'];
$pages = json_decode(file_get_contents(CONFIG_PATH . "page.json"), true);
return $pages[$uri]["title"] ?? "404 NOT FOUND";
}
function show_page()
{
$uri = $_SERVER["REQUEST_URI"];
$func = ltrim(implode("_", explode("/", $uri)), "_");
if (function_exists("show_{$func}")) {
call_user_func("show_{$func}");
} else {
call_user_func("show_404");
}
}
?>
<!--common func end-->