Release 0.1.45: member phone locations and people-first family navigation
This commit is contained in:
@@ -3,7 +3,7 @@ import {ref,computed,watch,onBeforeUnmount} from 'vue'
|
||||
import {snapshot,bridge} from '../composables/bridge.js'
|
||||
import LocalChart from './LocalChart.vue'
|
||||
const result=ref(null),error=ref(''),consent=ref(false),days=ref(7),code=ref(''),expires=ref(0),busy=ref(false),selected=ref('')
|
||||
const memberId=ref(''),viewerIds=ref([]),displayIds=ref([])
|
||||
const memberId=ref(''),viewerIds=ref([]),displayIds=ref([]),phoneIds=ref([]),viewOnly=ref(true)
|
||||
const binding=computed(()=>result.value?.bindings?.find(x=>x.memberId===memberId.value))
|
||||
const active=computed(()=>snapshot.value.loggedIn&&snapshot.value.page==='overview')
|
||||
const home=computed(()=>snapshot.value.state.households?.find(x=>x.id===snapshot.value.state.familyId))
|
||||
@@ -22,11 +22,11 @@ async function load(){const e=epoch,r=++requestId;if(!active.value)return
|
||||
finally{if(e===epoch&&r===requestId&&active.value)timer=setTimeout(load,30000)}
|
||||
}
|
||||
async function action(name){if(busy.value)return;busy.value=true;error.value='';const e=epoch;requestId++;clearTimeout(timer)
|
||||
try{const value=await bridge().api('/api/locations',{action:name,memberId:memberId.value,viewerIds:viewerIds.value,displayIds:displayIds.value,days:days.value});if(e!==epoch)return;code.value=value.code||'';expires.value=value.expires||0;if(name==='stop')consent.value=false;clearTimeout(timer);await load()}
|
||||
try{const value=await bridge().api('/api/locations',{action:name,memberId:memberId.value,viewerIds:viewerIds.value,displayIds:displayIds.value,phoneIds:phoneIds.value,viewOnly:viewOnly.value,days:days.value});if(e!==epoch)return;code.value=value.code||'';expires.value=value.expires||0;if(name==='stop')consent.value=false;clearTimeout(timer);await load()}
|
||||
catch(err){if(e===epoch)error.value=err.message}finally{if(e===epoch){busy.value=false;clearTimeout(timer);if(active.value)timer=setTimeout(load,30000)}}
|
||||
}
|
||||
watch([active,()=>snapshot.value.state.familyId,()=>snapshot.value.session],()=>{epoch++;clearTimeout(timer);result.value=null;code.value='';memberId.value='';viewerIds.value=[];displayIds.value=[];selected.value='';consent.value=false;busy.value=false;if(active.value)load()},{immediate:true})
|
||||
watch([memberId,viewerIds,displayIds,days],()=>{code.value=''}, {deep:true})
|
||||
watch([active,()=>snapshot.value.state.familyId,()=>snapshot.value.session],()=>{epoch++;clearTimeout(timer);result.value=null;code.value='';memberId.value='';viewerIds.value=[];displayIds.value=[];phoneIds.value=[];viewOnly.value=true;selected.value='';consent.value=false;busy.value=false;if(active.value)load()},{immediate:true})
|
||||
watch([memberId,viewerIds,displayIds,phoneIds,viewOnly,days],()=>{code.value=''}, {deep:true})
|
||||
onBeforeUnmount(()=>{epoch++;clearTimeout(timer)})
|
||||
</script>
|
||||
<template><section v-if="active" class="panel family-locations mb-4" aria-label="家庭位置共享">
|
||||
@@ -37,13 +37,13 @@ onBeforeUnmount(()=>{epoch++;clearTimeout(timer)})
|
||||
<details class="mt-3 border-top pt-3"><summary>为家庭成员配对手机</summary>
|
||||
<p class="small text-secondary mt-2">老人和孩子无需登录。先选择真实成员及具体查看人,再将配对码输入本人的手机。本人核对授权内容、允许定位并打开共享后才上传;管理员生成配对码不能代替本人同意。家庭屏需单独勾选。</p>
|
||||
<p v-if="!result?.members?.length" class="alert alert-info">请先在“家庭成员”登记本人或家人;普通账号需关联本人档案。</p>
|
||||
<form v-else @submit.prevent="action('pair')"><div class="row g-3"><label class="col-sm-8">绑定的家庭成员<select v-model="memberId" required class="form-select" :disabled="busy"><option value="">请选择成员</option><option v-for="m in result.members" :key="m.id" :value="m.id" :disabled="m.status==='historical'||m.lifeStatus==='deceased'">{{m.name}} {{m.label?`· ${m.label}`:''}}</option></select></label><label class="col-sm-4">共享有效期<select v-model.number="days" class="form-select" :disabled="busy"><option :value="1">1 天</option><option :value="7">7 天</option><option :value="30">30 天</option></select></label></div>
|
||||
<fieldset class="mt-3"><legend class="fs-6">允许哪些账号查看</legend><label v-for="u in result.viewers" :key="u.id" class="d-inline-flex gap-2 me-4 mb-2"><input type="checkbox" v-model="viewerIds" :value="u.id" :disabled="busy">{{u.name}}({{u.username}})</label></fieldset>
|
||||
<fieldset class="mt-3"><legend class="fs-6">允许哪些公共显示终端展示(默认不选)</legend><p v-if="!result.displays.length" class="small text-secondary">尚无已配对显示终端。</p><label v-for="d in result.displays" :key="d.id" class="d-inline-flex gap-2 me-4 mb-2"><input type="checkbox" v-model="displayIds" :value="d.id" :disabled="busy">{{d.name}}</label></fieldset>
|
||||
<form v-else @submit.prevent="action('pair')"><div class="row g-3"><label class="col-sm-8">绑定的家庭成员<select v-model="memberId" required class="form-select" :disabled="busy"><option value="">请选择成员</option><option v-for="m in result.members" :key="m.id" :value="m.id" :disabled="m.status==='historical'||m.lifeStatus==='deceased'">{{m.name}} {{m.label?`· ${m.label}`:''}}</option></select></label><label class="col-sm-4">手机配对有效期<select v-model.number="days" class="form-select" :disabled="busy"><option :value="1">1 天</option><option :value="7">7 天</option><option :value="30">30 天</option></select></label></div>
|
||||
<label class="d-flex gap-2 mt-3"><input type="checkbox" v-model="viewOnly" :disabled="busy">先仅配对手机查看家人,本人可稍后在手机设置自己的共享</label><fieldset v-if="!viewOnly" class="mt-3"><legend class="fs-6">允许哪些账号查看</legend><label v-for="u in result.viewers" :key="u.id" class="d-inline-flex gap-2 me-4 mb-2"><input type="checkbox" v-model="viewerIds" :value="u.id" :disabled="busy">{{u.name}}({{u.username}})</label></fieldset>
|
||||
<fieldset v-if="!viewOnly" class="mt-3"><legend class="fs-6">允许哪些家人手机查看</legend><label v-for="p in result.phones||[]" :key="p.id" class="d-inline-flex gap-2 me-4 mb-2"><input type="checkbox" v-model="phoneIds" :value="p.id" :disabled="busy">{{p.name}}的手机</label></fieldset><fieldset v-if="!viewOnly" class="mt-3"><legend class="fs-6">允许哪些公共显示终端展示(默认不选)</legend><p v-if="!result.displays.length" class="small text-secondary">尚无已配对显示终端。</p><label v-for="d in result.displays" :key="d.id" class="d-inline-flex gap-2 me-4 mb-2"><input type="checkbox" v-model="displayIds" :value="d.id" :disabled="busy">{{d.name}}</label></fieldset>
|
||||
<p v-if="binding">{{binding.enabled?'手机已开启共享':'手机已绑定,共享关闭'}} · {{time(binding.expires)}} 到期</p>
|
||||
<div class="d-flex flex-wrap gap-2 mt-3"><button class="btn btn-primary" :disabled="busy||!memberId||(!viewerIds.length&&!displayIds.length)">生成配对码</button><button v-if="binding||code" type="button" class="btn btn-outline-danger" :disabled="busy" @click="action('stop')">解除该手机授权</button><a class="btn btn-outline-secondary" href="/downloads" target="_blank" rel="noreferrer">下载配套 App</a></div>
|
||||
<div v-if="code" class="alert alert-success mt-3" role="status">配对码 <strong class="font-monospace fs-3">{{code}}</strong> · 10 分钟内使用一次<br>请在成员本人的手机核对姓名与查看名单,共享截至 {{time(expires)}}。重新配对会替换旧手机授权。</div>
|
||||
</form><p class="small text-secondary mt-3">约每 5 分钟更新,仅保存内存中的最新位置。关闭共享后清除;定位或网络中断超过 15 分钟隐藏旧坐标,提示更新中断,不表示人员失联。</p></details>
|
||||
<div class="d-flex flex-wrap gap-2 mt-3"><button class="btn btn-primary" :disabled="busy||!memberId||(!viewOnly&&!viewerIds.length&&!displayIds.length&&!phoneIds.length)">生成配对码</button><button v-if="binding||code" type="button" class="btn btn-outline-danger" :disabled="busy" @click="action('stop')">解除该手机授权</button><a class="btn btn-outline-secondary" href="/downloads" target="_blank" rel="noreferrer">下载配套 App</a></div>
|
||||
<div v-if="code" class="alert alert-success mt-3" role="status">配对码 <strong class="font-monospace fs-3">{{code}}</strong> · 10 分钟内使用一次<br>请在成员本人的手机核对姓名与查看名单,手机授权有效至 {{time(expires)}}。重新配对会替换旧手机授权。</div>
|
||||
</form><p class="small text-secondary mt-3">手机可在“我的位置设置”选择实时(约 10 秒)、1 分钟或 5 分钟上传,默认 5 分钟;仅保存内存中的最新位置。关闭共享后清除;定位或网络中断超过 15 分钟隐藏旧坐标,提示更新中断,不表示人员失联。</p></details>
|
||||
<p v-if="error" class="text-danger mt-2" role="alert">{{error}}</p>
|
||||
</section></template>
|
||||
<style scoped>.family-locations h2{font-size:1.3rem}.location-empty{display:grid;align-content:center;min-height:270px;text-align:center;color:var(--ui-muted,#64776f);padding:1rem}.location-empty>span{font-size:3rem;color:#6c9685}.location-person{display:flex;flex-direction:column;gap:.35rem;background:var(--panel,#fff);border:1px solid var(--ui-line,#d9e3dd);border-radius:12px;padding:14px;margin-bottom:10px;color:var(--ink,#243c32)}.location-person>span,.location-person small{font-size:.85rem}.location-selected{border-color:#257a68;box-shadow:inset 3px 0 #257a68}.family-locations summary{cursor:pointer}.family-locations input[type=checkbox]{min-width:18px;width:18px;min-height:18px}</style>
|
||||
|
||||
Reference in New Issue
Block a user