更新默认页面
This commit is contained in:
parent
b392129706
commit
dd771a009e
|
|
@ -24,10 +24,11 @@ class View extends MineResponse
|
|||
*/
|
||||
public static function make(UISettingEntity $setting, $content = null): ResponseInterface
|
||||
{
|
||||
$title = $setting->getTitle();
|
||||
$logo = '/viewui/logo.svg';
|
||||
$apiRoot = $setting->getApiRoot();
|
||||
$homeUrl = $setting->getHomeUrl();
|
||||
$token = $setting->getUser()->getToken();
|
||||
$title = $setting->getTitle();
|
||||
if ($setting->getUser()->getUid() > 0) {
|
||||
$root = 'root';
|
||||
} else {
|
||||
|
|
@ -36,44 +37,28 @@ class View extends MineResponse
|
|||
$pageData = $setting->toArray();
|
||||
$pageData = json_encode($pageData, 256);
|
||||
if (!$content) {
|
||||
$content = <<<EOF
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>{$title}</title>
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">{{ message }}</div>
|
||||
<script>
|
||||
let AuthInfo = {};
|
||||
AuthInfo.token = "{$token}";
|
||||
window.config = {
|
||||
'apiRoot': "{$apiRoot}",
|
||||
'homeUrl': "{$homeUrl}"
|
||||
}
|
||||
</script>
|
||||
<script src="/static/js/vue.global.js"></script>
|
||||
<script>
|
||||
const { createApp } = Vue
|
||||
createApp({
|
||||
data() {
|
||||
return {
|
||||
message: 'Hello TkView!'
|
||||
}
|
||||
}
|
||||
}).mount('#app')
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
EOF;
|
||||
$content =file_get_contents(BASE_PATH . '/public/viewui/index.html');
|
||||
$str=[
|
||||
'Tkview',
|
||||
'logo.svg',
|
||||
'$apiRoot',
|
||||
'$homeUrl',
|
||||
'$token',
|
||||
'$pageData',
|
||||
];
|
||||
$data=[
|
||||
$title,
|
||||
$logo,
|
||||
$apiRoot,
|
||||
$homeUrl,
|
||||
$token,
|
||||
$pageData
|
||||
];
|
||||
$content=str_replace($str,$data,$content);
|
||||
}
|
||||
$response = new Response();
|
||||
$request = $response->withHeader('content-type', 'text/html; charset=utf8')
|
||||
->withBody(new SwooleStream($content));
|
||||
return $request;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue