@@ -16,7 +16,7 @@ $.html = $.name
1616 }
1717 // 处理 App 请求 => /app
1818 else if ( / ^ \/ a p p / . test ( path ) ) {
19- handleApp ( )
19+ handleApp ( path . split ( '/app/' ) [ 1 ] )
2020 }
2121 // 处理 Api 请求 => /api
2222 else if ( / ^ \/ a p i / . test ( path ) ) {
@@ -237,18 +237,38 @@ function handleApi() {
237237 }
238238}
239239
240- function handleHome ( ) {
241- const data = JSON . stringify ( {
240+ function handleApp ( appId ) {
241+ const box = {
242242 sessions : getSessions ( ) ,
243243 sysapps : getSystemApps ( ) ,
244244 userapps : getUserApps ( ) ,
245245 syscfgs : getSystemCfgs ( ) ,
246246 colors : getSystemThemes ( )
247- } )
248- $ . html = `
247+ }
248+ const curapp = appId ? box . sysapps . find ( ( app ) => app . id === appId ) : null
249+ $ . html = printHtml ( JSON . stringify ( box ) , JSON . stringify ( curapp ) )
250+ console . log ( $ . html )
251+ }
252+
253+ function handleHome ( ) {
254+ $ . html = printHtml (
255+ JSON . stringify ( {
256+ sessions : getSessions ( ) ,
257+ sysapps : getSystemApps ( ) ,
258+ userapps : getUserApps ( ) ,
259+ syscfgs : getSystemCfgs ( ) ,
260+ colors : getSystemThemes ( )
261+ } )
262+ )
263+ console . log ( $ . html )
264+ }
265+
266+ function printHtml ( data , curapp = null ) {
267+ return `
249268 <!DOCTYPE html>
250269 <html lang="zh-CN">
251270 <head>
271+ <title>BoxJs</title>
252272 <meta charset="utf-8" />
253273 <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet" />
254274 <link href="https://cdn.jsdelivr.net/npm/@mdi/font@5.x/css/materialdesignicons.min.css" rel="stylesheet" />
@@ -444,7 +464,8 @@ function handleHome() {
444464 ui: {
445465 bfview: 'app',
446466 curview: 'app',
447- curapp: null,
467+ curapp: ${ curapp } ,
468+ curappTabs: { curtab: 'sessions' },
448469 curappSessions: null,
449470 impSessionDialog: { show: false, impval: '' },
450471 snackbar: { show: false, text: '已复制!', timeout: 2000 },
@@ -462,6 +483,9 @@ function handleHome() {
462483 if (newval === 'app') {
463484 this.ui.curapp = null
464485 this.ui.curappSessions = null
486+ var state = { title: 'BoxJs' }
487+ document.title = state.title
488+ history.pushState(state, '', '/home')
465489 }
466490 }
467491 }
@@ -472,6 +496,9 @@ function handleHome() {
472496 this.ui.curapp = app
473497 this.ui.curappSessions = this.box.sessions.filter((s) => s.appId === this.ui.curapp.id)
474498 this.ui.curview = 'appsession'
499+ var state = { title: 'BoxJs - ' + this.ui.curapp.name, url: window.location.href }
500+ history.pushState(state, '', '/app/' + this.ui.curapp.id)
501+ document.title = state.title
475502 },
476503 onSaveSession() {
477504 const session = {
@@ -527,19 +554,20 @@ function handleHome() {
527554 onCopy(e) {
528555 this.ui.snackbar.show = true
529556 }
557+ },
558+ mounted: function () {
559+ if (this.ui.curapp) {
560+ this.goAppSessionView(this.ui.curapp)
561+ }
530562 }
531563 })
532564 </script>
533565 </body>
534566 </html>
535567
536568 `
537- console . log ( $ . html )
538569}
539570
540- function printHtml ( ) {
541- return ''
542- }
543571function printJson ( ) {
544572 return ''
545573}
0 commit comments