parent
199509f72e
commit
93056d6b7b
29
index.html
29
index.html
|
|
@ -422,7 +422,7 @@ header{display:flex;align-items:center;justify-content:space-between;padding:0 1
|
|||
<!-- UNIT VIEW -->
|
||||
<div x-show="currentUnit">
|
||||
<div class="unit-header">
|
||||
<button class="unit-back" @click="currentUnit=null;quizState={}">
|
||||
<button class="unit-back" @click="goHome()">
|
||||
<i data-lucide="arrow-left" style="width:12px;height:12px"></i>
|
||||
一覧
|
||||
</button>
|
||||
|
|
@ -790,12 +790,38 @@ function bokiApp(){
|
|||
catch{ this.scores = {}; }
|
||||
const t = localStorage.getItem('posimai-boki-theme')||'system';
|
||||
this.isDark = t==='dark'||(t==='system'&&matchMedia('(prefers-color-scheme:dark)').matches);
|
||||
const uid=(new URLSearchParams(location.search).get('unit')||'').trim().toLowerCase();
|
||||
if(uid){
|
||||
const u=this.allUnits().find(x=>x.id===uid);
|
||||
if(u){ this.currentUnit=u; this.quizState={}; }
|
||||
else{ try{ const url=new URL(window.location.href); url.searchParams.delete('unit'); const q=url.searchParams.toString(); history.replaceState(null,'',url.pathname+(q?'?'+q:'')+url.hash); }catch(e){} }
|
||||
}
|
||||
this.syncUnitToUrl();
|
||||
this.$nextTick(()=>{ if(window.lucide) lucide.createIcons(); });
|
||||
if('serviceWorker' in navigator){
|
||||
navigator.serviceWorker.register('/sw.js').catch(()=>{});
|
||||
}
|
||||
},
|
||||
|
||||
syncUnitToUrl(){
|
||||
try{
|
||||
const url=new URL(window.location.href);
|
||||
if(this.currentUnit&&this.currentUnit.id) url.searchParams.set('unit',this.currentUnit.id);
|
||||
else url.searchParams.delete('unit');
|
||||
const q=url.searchParams.toString();
|
||||
const path=url.pathname+(q?'?'+q:'')+url.hash;
|
||||
if(path!==window.location.pathname+window.location.search+window.location.hash)
|
||||
history.replaceState(null,'',path);
|
||||
}catch(e){}
|
||||
},
|
||||
|
||||
goHome(){
|
||||
this.currentUnit=null;
|
||||
this.quizState={};
|
||||
this.syncUnitToUrl();
|
||||
this.$nextTick(()=>{ if(window.lucide) lucide.createIcons(); });
|
||||
},
|
||||
|
||||
get filteredCats(){
|
||||
if(!this.search) return this.categories;
|
||||
const q=this.search.toLowerCase();
|
||||
|
|
@ -872,6 +898,7 @@ function bokiApp(){
|
|||
openUnit(unit){
|
||||
this.currentUnit=unit;
|
||||
this.quizState={};
|
||||
this.syncUnitToUrl();
|
||||
this.$nextTick(()=>{
|
||||
if(window.lucide) lucide.createIcons();
|
||||
const m=document.getElementById('main');
|
||||
|
|
|
|||
Loading…
Reference in New Issue