client links

This commit is contained in:
yuri
2019-05-20 13:51:05 +03:00
parent f55d814cbb
commit 6fb21ccd77
3 changed files with 27 additions and 1 deletions

View File

@@ -108,6 +108,8 @@ class ClientManager
$loaderCacheTimestamp = $cacheTimestamp;
}
$linkList = $this->getMetadata()->get(['app', 'client', 'linkList'], []);
$scriptsHtml = '';
foreach ($jsFileList as $jsFile) {
$src = $this->basePath . $jsFile . '?r=' . $cacheTimestamp;
@@ -121,6 +123,15 @@ class ClientManager
$additionalStyleSheetsHtml .= "\n <link rel=\"stylesheet\" href=\"{$src}\">";
}
$linksHtml = '';
foreach ($linkList as $item) {
$href = $this->basePath . $item['href'] . '?r=' . $cacheTimestamp;
$as = $item['as'] ?? '';
$rel = $item['rel'] ?? '';
$type = $item['type'] ?? '';
$linksHtml .= "\n <link rel=\"{$rel}\" href=\"{$href}\" as=\"{$as}\" as=\"{$type}\">";
}
$data = [
'applicationId' => 'espocrm-application-id',
'apiUrl' => 'api/v1',
@@ -134,6 +145,7 @@ class ClientManager
'appClientClassName' => 'app',
'scriptsHtml' => $scriptsHtml,
'additionalStyleSheetsHtml' => $additionalStyleSheetsHtml,
'linksHtml' => $linksHtml,
];
$html = file_get_contents($htmlFilePath);

View File

@@ -24,5 +24,19 @@
"client/src/loader.js",
"client/src/utils.js",
"client/src/exceptions.js"
],
"linkList": [
{
"href": "client/fonts/open-sans/OpenSans-Bold.ttf",
"as": "font",
"type": "font/ttf",
"rel": "preload"
},
{
"href": "client/fonts/open-sans/OpenSans-Regular.ttf",
"as": "font",
"type": "font/ttf",
"rel": "preload"
}
]
}

View File

@@ -2,7 +2,7 @@
<html>
<head>
<title>{{applicationName}}</title>{{scriptsHtml}}
<link href="{{basePath}}{{stylesheet}}?r={{cacheTimestamp}}" rel="stylesheet" id='main-stylesheet'>{{additionalStyleSheetsHtml}}
<link href="{{basePath}}{{stylesheet}}?r={{cacheTimestamp}}" rel="stylesheet" id='main-stylesheet'>{{additionalStyleSheetsHtml}}{{linksHtml}}
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">