import { defineStore } from 'pinia' import { ref, computed } from 'vue' export const useStaffStore = defineStore('staff', () => { const token = ref(uni.getStorageSync('staffToken') || '') const nickname = ref(uni.getStorageSync('staffNickname') || '') const staffId = ref(uni.getStorageSync('staffId') || '') const unread = ref(0) const isLoggedIn = computed(() => !!token.value) function login(t, nick, id) { token.value = t nickname.value = nick staffId.value = id uni.setStorageSync('staffToken', t) uni.setStorageSync('staffNickname', nick) uni.setStorageSync('staffId', id) } function logout() { token.value = '' nickname.value = '' staffId.value = '' uni.removeStorageSync('staffToken') uni.removeStorageSync('staffNickname') uni.removeStorageSync('staffId') } return { token, nickname, staffId, unread, isLoggedIn, login, logout } })