diff --git a/CHANGELOG.md b/CHANGELOG.md index d95d8ea31581899ab4c86804470f958bc3380b1f..445fe35946b51e8d99c8337de008df0b3225e5f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ ## [Unreleased] +### Changed + +- 更新应用标题组件 + + ## [0.7.38-alpha.17] - 2024-10-25 ### Changed diff --git a/src/panel-component/panel-app-title/panel-app-title.controller.ts b/src/panel-component/panel-app-title/panel-app-title.controller.ts index 5be36f0a77252ca0d25439a8fdec5389f0464896..4641a214178aa9d4be3338f9a64a35cb9d4ee8d2 100644 --- a/src/panel-component/panel-app-title/panel-app-title.controller.ts +++ b/src/panel-component/panel-app-title/panel-app-title.controller.ts @@ -51,44 +51,58 @@ export class PanelAppTitleController extends PanelItemController async onInit(): Promise { await super.onInit(); this.handleRawItemParams(); - const indexViewModel: IAppIndexView = this.panel.view.model; - // 抬头 - if (indexViewModel.title) { - document.title = indexViewModel.title; - } - if (this.model.sysImage && this.model.sysImage.rawContent) { - this.state.icon = this.model.sysImage.rawContent; - } else if (indexViewModel.appIconPath) { - // 图标路径 - this.state.icon = indexViewModel.appIconPath; - } + const viewModel = this.panel.view.model; + if (viewModel.viewType !== 'APPINDEXVIEW') { + const app = ibiz.hub.getApp(); + if (app.model.title) { + document.title = app.model.title; + } + if (app.model.caption) { + this.state.caption = app.model.title || ''; + } + } else { + const indexViewModel: IAppIndexView = viewModel; + // 抬头 + if (indexViewModel.title) { + document.title = indexViewModel.title; + } + if (this.model.sysImage && this.model.sysImage.rawContent) { + this.state.icon = this.model.sysImage.rawContent; + } else if (indexViewModel.appIconPath) { + // 图标路径 + this.state.icon = indexViewModel.appIconPath; + } - // 图标路径2(收缩时) - if (indexViewModel.appIconPath2) { - this.state.icon2 = indexViewModel.appIconPath2; - } + // 图标路径2(收缩时) + if (indexViewModel.appIconPath2) { + this.state.icon2 = indexViewModel.appIconPath2; + } - // 标题 - if (indexViewModel.caption) { - this.state.caption = indexViewModel.caption.split(this.captionSplit)[0]; - this.state.caption2 = - indexViewModel.caption.split(this.captionSplit)[1] || - indexViewModel.caption.split(this.captionSplit)[0]; - } + // 标题 + if (indexViewModel.caption) { + this.state.caption = indexViewModel.caption.split(this.captionSplit)[0]; + this.state.caption2 = + indexViewModel.caption.split(this.captionSplit)[1] || + indexViewModel.caption.split(this.captionSplit)[0]; + } - // 子标题 - if (indexViewModel.subCaption) { - this.state.subCaption = indexViewModel.subCaption.split( - this.captionSplit, - )[0]; - this.state.subCaption2 = - indexViewModel.subCaption.split(this.captionSplit)[1] || - indexViewModel.subCaption.split(this.captionSplit)[0]; - } + // 子标题 + if (indexViewModel.subCaption) { + this.state.subCaption = indexViewModel.subCaption.split( + this.captionSplit, + )[0]; + this.state.subCaption2 = + indexViewModel.subCaption.split(this.captionSplit)[1] || + indexViewModel.subCaption.split(this.captionSplit)[0]; + } - // 是否为 svg 图标 - if (this.state.icon.endsWith('.svg') || this.state.icon2.endsWith('.svg')) { - this.state.isSvg = true; + // 是否为 svg 图标 + if ( + this.state.icon.endsWith('.svg') || + this.state.icon2.endsWith('.svg') + ) { + this.state.isSvg = true; + } } } diff --git a/src/panel-component/panel-app-title/panel-app-title.scss b/src/panel-component/panel-app-title/panel-app-title.scss index 6d7e17d1e6a157c6776f8d7f987324e64c14fad4..2a95ba75c965d5fdaee074b97bcf381a2a9628c2 100644 --- a/src/panel-component/panel-app-title/panel-app-title.scss +++ b/src/panel-component/panel-app-title/panel-app-title.scss @@ -4,6 +4,7 @@ $panel-app-title: ( 'font-weight': getCssVar(font-weight, bold), 'padding': 0 getCssVar(spacing, base, tight), 'collapse-padding': 0 getCssVar(spacing, tight), + 'not-index-height': 60px, ); @include b(panel-app-title) { @@ -86,4 +87,8 @@ $panel-app-title: ( white-space: nowrap; } } + + @include when('is-not-index'){ + height: getCssVar('panel-app-title','not-index-height'); + } } diff --git a/src/panel-component/panel-app-title/panel-app-title.tsx b/src/panel-component/panel-app-title/panel-app-title.tsx index 9d44ee34d1dcfc12c425710b508b4d24806574d0..8eb4d50911f0cbd03dec3efac692a3cc351438eb 100644 --- a/src/panel-component/panel-app-title/panel-app-title.tsx +++ b/src/panel-component/panel-app-title/panel-app-title.tsx @@ -221,11 +221,17 @@ export const PanelAppTitle = defineComponent({ this.ns.b(), this.ns.is('only-img', this.showImgOnly), this.ns.is('collapse', this.isCollapse), + this.ns.is( + 'is-not-index', + this.c.panel.view.model.viewType !== 'APPINDEXVIEW', + ), ...this.controller.containerClass, ]} onClick={this.handleClick} > - {content} + {this.c.panel.view.model.viewType !== 'APPINDEXVIEW' + ? captionNode + : content} ); },