修改昵称和oc在地图上的显示

linfangfang_branch
pb4ustkri 2 months ago
parent 5060dfbf2d
commit 9778069cf5

@ -95,13 +95,14 @@
</template>
<script setup>
import { ref, computed, onMounted, onUnmounted } from 'vue'
import { ref, computed, onMounted, onUnmounted, watch } from 'vue'
import { User, Avatar, Phone } from '@element-plus/icons-vue'
import PhoneWidget from './PhoneWidget.vue'
import UserCenterDialog from './UserCenterDialog.vue'
import OCListDialog from './OCListDialog.vue'
import OCInfoDialog from './OCInfoDialog.vue'
import { ocList } from '../stores/ocStore.js'
import { ocList, loadOCFromStorage } from '../stores/ocStore.js'
import { currentUser } from '../stores/userStore.js'
//
const defaultAvatar = 'https://i.pravatar.cc/100?img=1'
@ -125,6 +126,8 @@ const locationCoords = {
const ocPositions = ref([])
// oc
const locationStatuses = ref([])
// ocList
const ocLoadedForUser = ref(false)
const computePositions = () => {
const now = new Date()
@ -135,7 +138,14 @@ const computePositions = () => {
Object.keys(locationCoords).forEach(k => {
locMap[k] = { name: k, x: locationCoords[k].x, y: locationCoords[k].y, count: 0, ocs: [] }
})
ocList.value.forEach(oc => {
// OC 使使 owner OC
const sourceList = ocLoadedForUser.value
? ocList.value
: (currentUser.value && currentUser.value.username)
? ocList.value.filter(o => o.owner && o.owner === currentUser.value.username)
: []
sourceList.forEach(oc => {
let loc = ''
if (oc.schedule && oc.schedule.length) {
// <= now
@ -163,6 +173,19 @@ const computePositions = () => {
let posTimer = null
onMounted(() => {
// OC
if (currentUser.value && currentUser.value.username) {
try {
loadOCFromStorage(currentUser.value.username)
ocLoadedForUser.value = true
} catch (e) {
console.error('Failed to load user-specific OC list:', e)
ocLoadedForUser.value = false
}
} else {
ocLoadedForUser.value = false
}
computePositions()
posTimer = setInterval(computePositions, 60 * 1000)
document.addEventListener('click', closePopoverOnClickOutside)
@ -172,6 +195,24 @@ onUnmounted(() => {
document.removeEventListener('click', closePopoverOnClickOutside)
})
// OC OC
watch(currentUser, (val) => {
if (val && val.username) {
try {
loadOCFromStorage(val.username)
ocLoadedForUser.value = true
} catch (e) {
console.error('Failed to load OC list for user on change:', e)
ocLoadedForUser.value = false
}
} else {
ocLoadedForUser.value = false
// OC
loadOCFromStorage()
}
computePositions()
})
// OC /
const showOCInfo = ref(false)
const selectedOC = ref(null)
@ -230,7 +271,7 @@ const closePopoverOnClickOutside = (event) => {
.community-container {
display: flex;
height: 100vh;
background: linear-gradient(135deg, #ffc6c6 0%, #7486c0 100%);
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
position: relative;
overflow: hidden;
}

@ -30,6 +30,9 @@
<div class="personal-info">
<h4>个人信息</h4>
<el-form :model="userInfo" label-width="80px" size="small">
<el-form-item label="昵称">
<el-input v-model="userInfo.nickname" placeholder="请输入昵称" />
</el-form-item>
<el-form-item label="生日">
<el-date-picker
v-model="userInfo.birthday"

Loading…
Cancel
Save