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