Files
ulthon_admin/extend/base/admin/view/layout/default.html
augushong f3ac7189f2 refactor(component): tagInput/propertyInput/tableData 模板改为懒加载异步获取
原实现三个组件在 JS 顶层用 $.ajax({async:false}) 同步拉取 .html 模板,
每个页面打开固定发 3 个同步请求(阻塞主线程,与组件是否被使用无关),
且路径硬编码 /static/ 与 __STATIC__(OSS 部署)脱节,模板 URL 无版本
参数存在与 js 缓存不同步的漂移问题,请求失败时静默渲染空白。

改造内容:
- 模板改为首次 render() 时异步获取,Deferred 缓存供同页多实例共享,
  失败不缓存并在下次 render 自动重试,失败时 console.error + 提示
- 模板 URL 取 CONFIG.STATIC + CONFIG.STATIC_VERSION,layout 的
  window.CONFIG 新增这两项注入;无注入时逐级回退 /static 与 VERSION,
  兼容下游覆盖 layout 的旧页面
- 组件 CSS 由 _require.html 直接 link 引入(__STATIC__ + 版本键),
  替代原 JS 动态注入
- render() 返回 Promise(resolve Vue 实例);仓库内调用均为
  fire-and-forget,无兼容影响
2026-10-05 14:08:03 +00:00

45 lines
1.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{:sysconfig('site','site_name')}</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
{include file='common/_require'/}
<script>
window.CONFIG = {
ADMIN: "{$adminModuleName|default='admin'}",
CONTROLLER_JS_PATH: "{$thisControllerJsPath|default=''}",
ACTION: "{$thisAction|default=''}",
AUTOLOAD_JS: "{$autoloadJs|default='false'}",
IS_SUPER_ADMIN: "{$isSuperAdmin|default='false'}",
VERSION: "{$version|default='1.0.0'}",
CSRF_TOKEN: "{:token()}",
PAGE_KEY_NAME:'{$pageKeyName|default=$Request.url}',
// 静态资源根路径(与 __STATIC__ 模板替换一致,OSS 部署时指向 OSS),
// 供 JS 内部动态拼接静态资源地址的组件使用(tagInput/propertyInput/tableData 等)
STATIC: "__STATIC__",
// 静态资源版本键,与 _require.html 中 js/css 的 ?t= 参数同源,
// 保证动态请求的模板与引入的 js/css 缓存版本一致
STATIC_VERSION: "{:get_site_version_key()}"
};
var PATH_CONFIG = {
iconLess: "__STATIC__/plugs/font-awesome-4.7.0/less/variables.less",
};
window.PATH_CONFIG = PATH_CONFIG;
</script>
<script>window.UA_AUTH = {$uaAuth|raw|default='false'};</script>
{$content_js|raw}
{:sysconfig('site','site_js_insert')}
</head>
<body>
{__CONTENT__}
<script style="display: none;" id="data-brage" type="text/plain">{$data_brage|raw|default='[]'}</script>
</body>
</html>