@@ -10,8 +10,11 @@ import { log } from "../moreOnLog";
10
10
import { StatsView } from "src/statsView" ;
11
11
import InvioPlugin from "src/main" ;
12
12
import { Utils } from "src/utils/utils" ;
13
- import { WMS_FOOTER , WMS_FOOTER_STYLE } from './wms-footer' ;
14
13
14
+ export interface ICustomPageSettings {
15
+ footer ?: string ;
16
+ style ?: string ;
17
+ }
15
18
const LogoSVGDefault = `<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="svg238067" height="768px" width="1024px" version="1.1" viewBox="0 0 100 100" class="svg-icon invio-sync-wait"><g fill-rule="evenodd" style="transform: scale3d(0.89, 0.99, 1.5);"><path d="M27 97.93A56.08 56.08 0 0 1 9.29 19.08 55.77 55.77 0 0 0 23.59 50l.07.07c.53.58 1.06 1.14 1.62 1.7s1.12 1.09 1.72 1.62L45.54 72a14.93 14.93 0 0 1 4.53 10.93v1.59a15.12 15.12 0 0 1-8 13.52A15.09 15.09 0 0 1 27 97.93z" style="fill: var(--icon-color);"></path><path d="M23.59 50a55.77 55.77 0 0 1-14.3-30.92A56.46 56.46 0 0 1 27 2.08 15.08 15.08 0 0 1 42.11 2a15.12 15.12 0 0 1 8 13.52v1.59A15 15 0 0 1 45.55 28l-22 22z" fill="#999999" opacity=".8"></path><path d="M85.16 2.08a56.08 56.08 0 0 1 17.67 78.84A55.77 55.77 0 0 0 88.53 50l-.08-.07c-.52-.58-1.06-1.14-1.62-1.7s-1.12-1.09-1.69-1.62L66.58 28a14.93 14.93 0 0 1-4.53-10.93v-1.55A15.12 15.12 0 0 1 70 2a15.08 15.08 0 0 1 15.15.08z" style="fill: var(--icon-color);"></path><path d="M88.53 50a55.77 55.77 0 0 1 14.3 30.92 56.35 56.35 0 0 1-17.67 17 15.46 15.46 0 0 1-23.11-13.44v-1.59A15 15 0 0 1 66.57 72l22-22z" fill="#999999" opacity=".8"></path></g></svg>`
16
19
17
20
export interface IMetaConfig {
@@ -77,11 +80,12 @@ export class HTMLGenerator {
77
80
rootPath : Path ,
78
81
view : StatsView ,
79
82
remoteDomain ?: string , // website assets file's host domain
83
+ customPageSettings ?: ICustomPageSettings
80
84
) : Promise < ExportFile > {
81
85
await this . getDocumentHTML ( file , rootPath , false , view , remoteDomain ) ;
82
86
let usingDocument = file . document ;
83
87
84
- let sidebars = this . generateSideBars ( file . contentElement , file ) ;
88
+ let sidebars = this . generateSideBars ( file . contentElement , file , customPageSettings ) ;
85
89
this . generateSideBarBtns ( file , sidebars ) ;
86
90
let rightSidebar = sidebars . right ;
87
91
let leftSidebar = sidebars . left ;
@@ -146,6 +150,7 @@ export class HTMLGenerator {
146
150
file . downloads . push ( new Downloadable ( '_common-left-tree.html' , fileTree . outerHTML , rootDir ) ) ;
147
151
// TODO: 摆脱includeFileTree限制,定制优化index首页UI样式
148
152
if ( InvioSettingTab . settings . generateIndexPage ) {
153
+ const customFooter = customPageSettings . footer ? `<div class="tree-footer">${ customPageSettings . footer } </div>` : ''
149
154
const indexPageHTML = `<!DOCTYPE html><html lang="zh"><head>
150
155
<title>${ prefix } </title>
151
156
<style>
@@ -171,9 +176,9 @@ export class HTMLGenerator {
171
176
display: none;
172
177
}
173
178
.tree-scroll-area>.tree-item>.tree-item-contents { padding: 1rem; text-align: center; }
174
- ${ WMS_FOOTER_STYLE }
179
+ ${ customPageSettings . style || '' }
175
180
</style>
176
- </head><body>${ fileTree . outerHTML } <div class="tree-footer"> ${ WMS_FOOTER } </div> </body></html>` ;
181
+ </head><body>${ fileTree . outerHTML } ${ customFooter } </body></html>` ;
177
182
file . downloads . push ( new Downloadable ( 'index.html' , indexPageHTML , rootDir ) ) ;
178
183
}
179
184
}
@@ -331,7 +336,7 @@ export class HTMLGenerator {
331
336
}
332
337
}
333
338
334
- private static generateSideBars ( middleContent : HTMLElement , file : ExportFile ) : { container : HTMLElement , left : HTMLElement , leftScroll : HTMLElement , right : HTMLElement , rightScroll : HTMLElement , center : HTMLElement } {
339
+ private static generateSideBars ( middleContent : HTMLElement , file : ExportFile , customPageSettings : ICustomPageSettings ) : { container : HTMLElement , left : HTMLElement , leftScroll : HTMLElement , right : HTMLElement , rightScroll : HTMLElement , center : HTMLElement } {
335
340
let docEl = file . document ;
336
341
337
342
/*
@@ -373,12 +378,16 @@ export class HTMLGenerator {
373
378
374
379
documentContainer . appendChild ( middleContent ) ;
375
380
376
- const tmpDiv = document . createElement ( 'div' ) ;
377
- tmpDiv . innerHTML = WMS_FOOTER ;
378
- const footerStyle = document . createElement ( 'style' ) ;
379
- footerStyle . innerHTML = WMS_FOOTER_STYLE ;
380
- documentContainer . appendChild ( footerStyle ) ;
381
- documentContainer . appendChild ( tmpDiv . firstChild ) ;
381
+ if ( customPageSettings ?. style ) {
382
+ const footerStyle = document . createElement ( 'style' ) ;
383
+ footerStyle . innerHTML = customPageSettings . style ;
384
+ documentContainer . appendChild ( footerStyle ) ;
385
+ }
386
+ if ( customPageSettings ?. footer ) {
387
+ const tmpDiv = document . createElement ( 'div' ) ;
388
+ tmpDiv . innerHTML = customPageSettings . footer ;
389
+ documentContainer . appendChild ( tmpDiv . firstChild ) ;
390
+ }
382
391
383
392
rightSidebar . classList . add ( "sidebar" ) ;
384
393
rightSidebar . appendChild ( rightContent ) ;
0 commit comments