尝试修复上下页跳转问题和hover显示错误

Signed-off-by: ROOMrepair <twekjz@gmail.com>
This commit is contained in:
ROOMrepair 2024-10-30 22:08:35 +08:00
parent 701c81afce
commit 929519b251
4 changed files with 13 additions and 151 deletions

View File

@ -157,8 +157,6 @@
</div>
</div>
<!-- DEBUG {{ partial "page_navigate" (dict "context" . "prev" true)}} -->
{{ if .IsPage }}
<!-- <div class="page-div common-flex-layout"> -->
{{ partial "pagination" . }}

View File

@ -157,9 +157,6 @@
</div>
</div>
<!-- DEBUG {{ partial "page_navigate" (dict "context" . "prev" true)}} -->
{{ if .IsPage }}
<!-- <div class="page-div common-flex-layout"> -->
{{ partial "pagination" . }}

View File

@ -1,195 +1,73 @@
<!-- !!! todo combine the logic of check ispage and isindex , too many duplicate codes !!! -->
{{ $current := .context }}
<!-- DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: blue;">gcurrent {{ $current }}</div> -->
<!-- is page -->
{{ if $current.IsPage}}
{{ $g_parent := $current.Parent.Parent }}
<!-- choose different bottom up step -->
<!-- in this case page.parent is index -->
{{ $g_parent := "" }}
{{ if $current.IsPage }}
{{ $g_parent = $current.Parent.Parent }}
{{ else }}
{{ $g_parent = $current.Parent}}
{{ end }}
<!-- DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: blue;">
{{ $g_parent}}--{{$g_parent.FirstSection }}
{{ $g_parent.InSection $g_parent.FirstSection }}
</div> -->
<!-- SECTION1 -->
<!-- important! here we need call .Pages to include both pure page and _index -->
{{ $p_section := $g_parent.Pages.ByWeight }}
{{ $length := len $p_section }}
<!-- page prev -->
{{ if .prev }}
{{ $first := index $p_section 0}}
<!-- DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: red;">
first {{ $first }} <br>
first section {{ $first.CurrentSection }} <br>
current section {{ $current.CurrentSection }}
</div> -->
<!-- check if is already the first section (为第二级目录的第一个 section) -->
<!-- if is first section,we need to bottom up -->
{{ if $current.InSection $first.CurrentSection }}
<!--DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: red;">
prev true
</div> -->
<!-- bottom up -->
{{ partial "page_navigate" (dict "context" $g_parent "prev" true)}}
<!--if not the first section just go to pre section last page (last page of pre section of p_section)-->
{{else}}
<!-- DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: red;">
prev false
</div> -->
<!-- find current page's section position -->
{{ $curIndex := 0 }}
{{ range $i, $p_sec := $p_section}}
<!-- DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: green;">
gparent_section {{ . }}
</div> -->
{{ if eq $p_sec $current.CurrentSection}}
{{ $curIndex = $i }}
{{ end }}
{{ end }}
<!-- DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: pink;">
{{ $curIndex }}
</div> -->
{{ $prevPage := index $p_section (sub $curIndex 1) }}
{{ partial "findLastInSection" $prevPage}}
{{ end }} <!-- close of check page prev bottom up -->
<!-- SECTION1 -->
<!-- page next -->
{{ else }}
<!-- SECTION2 -->
{{ $last := index $p_section (sub $length 1)}}
<!--DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: red;">
last {{ $last }} <br>
last section {{ $last.CurrentSection }} <br>
current section {{ $current.CurrentSection }}
</div> -->
<!-- if is last section,we need to bottom up -->
{{ if $current.InSection $last.CurrentSection }}
<!--DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: red;">
next true
</div> -->
<!-- bottom up -->
{{ partial "page_navigate" (dict "context" $g_parent "prev" false)}}
<!--if not the last section just go to next section -->
{{ else }}
<!-- DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: red;">
next false
</div> -->
{{ $curIndex := 0 }}
{{ range $i, $p_sec := $p_section}}
<!-- DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: green;">
gparent_section {{ . }}
</div> -->
{{ if eq $p_sec $current.CurrentSection}}
{{ $curIndex = $i }}
{{ end }}
{{ end }}
<!--DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: pink;">
{{ $curIndex }}
</div> -->
{{ $nextPage := index $p_section (add $curIndex 1) }}
{{ partial "findFirstInSection" $nextPage}}
{{ end }} <!-- close of check page next bottom up -->
{{ end }} <!-- close of check next bottom up -->
<!-- SECTION2 -->
{{ end }} <!-- close of page prev next-->
<!-------------------------------------------------------------------->
<!-- is Index -->
{{ else }}
{{ $g_parent := $current.Parent}}
{{ $p_section := $g_parent.Pages.ByWeight }}
{{ $length := len $p_section }}
<!-- index prev -->
{{ if .prev}}
{{ $first := index $p_section 0}}
<!--DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: blue;">
{{ $g_parent}}--{{$g_parent.FirstSection }}
index {{ $g_parent.InSection $g_parent.FirstSection }} <br>
index first {{ $first}}
</div> -->
<!-- keep bottom up -->
{{ if $current.InSection $first.CurrentSection }}
<!-- DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: red;">
index true
</div> -->
{{ partial "page_navigate" (dict "context" $g_parent "prev" true)}}
<!-- find current index's section position -->
{{ else }}
{{ $curIndex := 0 }}
{{ range $i, $p_sec := $p_section}}
<!-- DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: green;">
gparent_section {{ . }}
</div> -->
{{ if eq $p_sec $current.CurrentSection}}
{{ $curIndex = $i }}
{{ end }}
{{ end }}
<!-- DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: pink;">
{{ $curIndex }}
</div> -->
{{ $prevPage := index $p_section (sub $curIndex 1) }}
{{ partial "findLastInSection" $prevPage}}
{{ end }} <!-- close of check index prev bottom up -->
<!-- index next -->
{{ else }}
{{ $last := index $p_section (sub $length 1)}}
<!-- if is last section,we need to bottom up -->
{{ if $current.InSection $last.CurrentSection }}
<!-- DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: red;">
next true
</div> -->
<!-- bottom up -->
{{ partial "page_navigate" (dict "context" $g_parent "prev" false)}}
<!--if not the last section just go to next section -->
{{ else }}
<!-- DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: red;">
next false
</div> -->
{{ $curIndex := 0 }}
{{ range $i, $p_sec := $p_section}}
<!-- DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: green;">
gparent_section {{ . }}
</div> -->
{{ if eq $p_sec $current.CurrentSection}}
{{ $curIndex = $i }}
{{ end }}
{{ end }}
<!-- DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: pink;">
{{ $curIndex }}
</div> -->
{{ $nextPage := index $p_section (add $curIndex 1) }}
{{ partial "findFirstInSection" $nextPage}}
{{ end }} <!-- close of check index next bottom up -->
{{ end }} <!-- close of index prev next-->
{{ end }}

View File

@ -1,5 +1,3 @@
<!-- {{ partial "page_navigate" (dict "context" . "prev" false)}} -->
<div class="page-div common-flex-layout">
<!-- if not each page in a section is pure page we can't simply use prev/nextInsection -->
{{ $current := .}}
@ -10,20 +8,11 @@
<!-- find current page's section position -->
{{ $curIndex := 0 }}
{{ range $i, $p_sec := $p}}
<!-- DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: darkblue;">
gparent_section {{ $p_sec }}
</div> -->
{{ if eq $p_sec $current}}
{{ $curIndex = $i }}
{{ end }}
{{ end }}
<!-- DEBUG <div style="position: relative ;z-index: 99;top:0;width: 100;height: 100;color: pink;">
cur {{ $current }}
{{ $curIndex }}
</div> -->
<!-- prev -->
{{ if gt $curIndex 0}}