diff --git a/packages/global-util-design/src/index.ts b/packages/global-util-design/src/index.ts index 93d5e75fd19d9ea67b0d34da205cfc4c42d401c1..d22ddabb935cf2a8449be9073d0bbd72b3337392 100644 --- a/packages/global-util-design/src/index.ts +++ b/packages/global-util-design/src/index.ts @@ -1,9 +1,11 @@ import { App } from 'vue'; import Views from './views'; +import Platform from './platform'; import './style/index.scss'; export default { install(app: App): void { app.use(Views); + app.use(Platform); }, }; diff --git a/packages/global-util-design/src/platform/browser-platform-provider.ts b/packages/global-util-design/src/platform/browser-platform-provider.ts new file mode 100644 index 0000000000000000000000000000000000000000..0caa1746b4ebacb7a398c7e384bb8092787b07a7 --- /dev/null +++ b/packages/global-util-design/src/platform/browser-platform-provider.ts @@ -0,0 +1,36 @@ +import { PlatformProviderBase } from '@ibiz-template/runtime'; + +/** + * 浏览器搭载平台适配器 + * + * @author zk + * @date 2023-11-20 03:11:25 + * @export + * @class BrowserPlatformProvider + * @extends {PlatformProviderBase} + */ +export class BrowserPlatformProvider extends PlatformProviderBase { + /** + * 设置浏览器标签页标题 + * + * @param {string} title + * @memberof BrowserPlatformProvider + */ + setBrowserTitle(_title: string): void { + const app = ibiz.hub.getApp(); + const appContext = ibiz.appData?.context; + let tabTitle: string = ''; + if (ibiz.env.AppLabel) { + tabTitle = ibiz.env.AppLabel; + } else if (app.model.title) { + tabTitle = app.model.title; + } else { + tabTitle = this.sourceTitle; + } + if (appContext?.srfpssyslogicname) + tabTitle += ` - ${appContext.srfpssyslogicname}${ + appContext.srfpssysname ? ` (${appContext.srfpssysname})` : '' + }`; + document.title = tabTitle; + } +} diff --git a/packages/global-util-design/src/platform/index.ts b/packages/global-util-design/src/platform/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..57b1b3c241d7858bde49bf9995a873e140e9778a --- /dev/null +++ b/packages/global-util-design/src/platform/index.ts @@ -0,0 +1,16 @@ +import { + PlatformType, + getPlatformProvider, + registerPlatformProvider, +} from '@ibiz-template/runtime'; +import { BrowserPlatformProvider } from './browser-platform-provider'; + +export default { + install(): void { + registerPlatformProvider( + PlatformType.BROWSER, + () => new BrowserPlatformProvider(), + ); + ibiz.platform = getPlatformProvider(); + }, +};