continua upgrade Vue 3
This commit is contained in:
@@ -1,153 +1,167 @@
|
||||
import { Vue, Options } from 'vue-class-component'
|
||||
import { defineComponent, ref } from 'vue'
|
||||
|
||||
import { IMessage } from '@src/model'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
import { tools } from '../store/Modules/tools'
|
||||
import { func_tools } from '../store/Modules/toolsext'
|
||||
|
||||
// You can declare a mixin as the same style as components.
|
||||
export default defineComponent({
|
||||
name: 'MixinUsers',
|
||||
setup(props) {
|
||||
function getUserByUsername(username: string) {
|
||||
const userStore = useUserStore()
|
||||
return userStore.getNameSurnameByUsername(username)
|
||||
}
|
||||
export default function () {
|
||||
function getUserByUsername(username: string) {
|
||||
const userStore = useUserStore()
|
||||
return userStore.getNameSurnameByUsername(username)
|
||||
}
|
||||
|
||||
function getImgByUsername(username: string) {
|
||||
const userStore = useUserStore()
|
||||
return `public/${userStore.getImgByUsername(username)}`
|
||||
}
|
||||
function getImgByUsername(username: string) {
|
||||
const userStore = useUserStore()
|
||||
return `public/${userStore.getImgByUsername(username)}`
|
||||
}
|
||||
|
||||
function isValidUsername(username: string) {
|
||||
return username && username !== 'nessuno' && username !== 'none'
|
||||
}
|
||||
function isValidUsername(username: string) {
|
||||
return username && username !== 'nessuno' && username !== 'none'
|
||||
}
|
||||
|
||||
function getMyUsername() {
|
||||
const userStore = useUserStore()
|
||||
return userStore.my.username
|
||||
}
|
||||
function getMyUsername() {
|
||||
const userStore = useUserStore()
|
||||
return userStore.my.username
|
||||
}
|
||||
|
||||
function getUsernameChatByMsg(msg: IMessage) {
|
||||
if (msg) {
|
||||
if (msg.dest) {
|
||||
if (msg.dest.username !== getMyUsername()) return msg.dest.username
|
||||
return msg.origin ? msg.origin.username : {}
|
||||
}
|
||||
} else {
|
||||
return ''
|
||||
function getUsernameChatByMsg(msg: IMessage) {
|
||||
if (msg) {
|
||||
if (msg.dest) {
|
||||
if (msg.dest.username !== getMyUsername()) return msg.dest.username
|
||||
return msg.origin ? msg.origin.username : {}
|
||||
}
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
function getnumItemsCart(): any {
|
||||
// ++Todo: conv
|
||||
/* const arrcart = Products.cart
|
||||
if (!!arrcart) {
|
||||
if (!!arrcart.items) {
|
||||
// @ts-ignore
|
||||
const total = arrcart.items.reduce((sum, item) => sum + item.order.quantity, 0)
|
||||
return total
|
||||
}
|
||||
} */
|
||||
return 0
|
||||
}
|
||||
function getnumItemsCart(): any {
|
||||
// ++Todo: conv
|
||||
/* const arrcart = Products.cart
|
||||
if (!!arrcart) {
|
||||
if (!!arrcart.items) {
|
||||
// @ts-ignore
|
||||
const total = arrcart.items.reduce((sum, item) => sum + item.order.quantity, 0)
|
||||
return total
|
||||
}
|
||||
} */
|
||||
return 0
|
||||
}
|
||||
|
||||
function getImgByMsg(msg: IMessage) {
|
||||
const userStore = useUserStore()
|
||||
// @ts-ignore
|
||||
return `public/${userStore.getImgByUsername(this.getUsernameChatByMsg(msg))}`
|
||||
}
|
||||
function getImgByMsg(msg: IMessage) {
|
||||
const userStore = useUserStore()
|
||||
// @ts-ignore
|
||||
return `public/${userStore.getImgByUsername(this.getUsernameChatByMsg(msg))}`
|
||||
}
|
||||
|
||||
function getMyImg() {
|
||||
const userStore = useUserStore()
|
||||
const ris = userStore.getImgByUsername(userStore.my.username)
|
||||
return (ris !== '') ? `public/${ris}` : ''
|
||||
}
|
||||
function getMyImg() {
|
||||
const userStore = useUserStore()
|
||||
const ris = userStore.getImgByUsername(userStore.my.username)
|
||||
return (ris !== '') ? `public/${ris}` : ''
|
||||
}
|
||||
|
||||
function getMyImgforIcon() {
|
||||
const userStore = useUserStore()
|
||||
const ris = userStore.getImgByUsername(userStore.my.username)
|
||||
return (ris !== '') ? `img:public/${ris}` : 'fas fa-user'
|
||||
}
|
||||
function getMyImgforIcon() {
|
||||
const userStore = useUserStore()
|
||||
const ris = userStore.getImgByUsername(userStore.my.username)
|
||||
return (ris !== '') ? `img:public/${ris}` : 'fas fa-user'
|
||||
}
|
||||
|
||||
function getIconCart() {
|
||||
const iconcart = 'fas fa-shopping-cart'
|
||||
function getIconCart() {
|
||||
const iconcart = 'fas fa-shopping-cart'
|
||||
|
||||
return iconcart
|
||||
}
|
||||
return iconcart
|
||||
}
|
||||
|
||||
function MenuCollapse() {
|
||||
const globalStore = useGlobalStore()
|
||||
return globalStore.menuCollapse
|
||||
// return true
|
||||
}
|
||||
function MenuCollapse() {
|
||||
const globalStore = useGlobalStore()
|
||||
return globalStore.menuCollapse
|
||||
// return true
|
||||
}
|
||||
|
||||
function Username() {
|
||||
const userStore = useUserStore()
|
||||
return userStore.my.username
|
||||
}
|
||||
function Username() {
|
||||
const userStore = useUserStore()
|
||||
return userStore.my.username
|
||||
}
|
||||
|
||||
function myName() {
|
||||
const userStore = useUserStore()
|
||||
return userStore.my.name
|
||||
}
|
||||
function myName() {
|
||||
const userStore = useUserStore()
|
||||
return userStore.my.name
|
||||
}
|
||||
|
||||
function mySurname() {
|
||||
const userStore = useUserStore()
|
||||
return userStore.my.surname
|
||||
}
|
||||
function mySurname() {
|
||||
const userStore = useUserStore()
|
||||
return userStore.my.surname
|
||||
}
|
||||
|
||||
function myCell() {
|
||||
const userStore = useUserStore()
|
||||
return userStore.my.profile.cell
|
||||
}
|
||||
function myCell() {
|
||||
const userStore = useUserStore()
|
||||
return userStore.my.profile.cell
|
||||
}
|
||||
|
||||
function Verificato() {
|
||||
const userStore = useUserStore()
|
||||
return userStore.my.verified_email
|
||||
}
|
||||
function Verificato() {
|
||||
const userStore = useUserStore()
|
||||
return userStore.my.verified_email
|
||||
}
|
||||
|
||||
function MadeGift() {
|
||||
const userStore = useUserStore()
|
||||
return userStore.my.made_gift
|
||||
}
|
||||
function paotest() {
|
||||
return 'Ciaoooooooooooooooo!'
|
||||
}
|
||||
|
||||
function Email() {
|
||||
const userStore = useUserStore()
|
||||
return userStore.my.email
|
||||
}
|
||||
function MadeGift() {
|
||||
const userStore = useUserStore()
|
||||
return userStore.my.made_gift
|
||||
}
|
||||
|
||||
function getNumMsg() {
|
||||
// ++Todo: conv
|
||||
/*
|
||||
return MessageStore.getlasts_messages().length
|
||||
*/
|
||||
function Email() {
|
||||
const userStore = useUserStore()
|
||||
return userStore.my.email
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
function getNumMsg() {
|
||||
// ++Todo: conv
|
||||
/*
|
||||
return MessageStore.getlasts_messages().length
|
||||
*/
|
||||
|
||||
function getNumMsgUnread() {
|
||||
// return userStore.getlasts_messages().length
|
||||
// ++Todo: conv
|
||||
// return MessageStore.getnumMsgUnread()
|
||||
return 0
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
function getMsgText(msg: IMessage, inarray: boolean) {
|
||||
let add = ''
|
||||
if (msg.origin && msg.origin.username === getMyUsername()) add = 'Tu: '
|
||||
function getNumMsgUnread() {
|
||||
// return userStore.getlasts_messages().length
|
||||
// ++Todo: conv
|
||||
// return MessageStore.getnumMsgUnread()
|
||||
return 0
|
||||
}
|
||||
|
||||
const ris = add + msg.message
|
||||
if (inarray) return [ris]
|
||||
return ris
|
||||
}
|
||||
function getMsgText(msg: IMessage, inarray: boolean) {
|
||||
let add = ''
|
||||
if (msg.origin && msg.origin.username === getMyUsername()) add = 'Tu: '
|
||||
|
||||
return {
|
||||
getUsernameChatByMsg,
|
||||
getMyUsername,
|
||||
}
|
||||
},
|
||||
})
|
||||
const ris = add + msg.message
|
||||
if (inarray) return [ris]
|
||||
return ris
|
||||
}
|
||||
|
||||
return {
|
||||
getUsernameChatByMsg,
|
||||
getMyUsername,
|
||||
Username,
|
||||
myName,
|
||||
mySurname,
|
||||
myCell,
|
||||
Verificato,
|
||||
MadeGift,
|
||||
Email,
|
||||
getMyImg,
|
||||
getMyImgforIcon,
|
||||
getImgByMsg,
|
||||
getnumItemsCart,
|
||||
getUserByUsername,
|
||||
getImgByUsername,
|
||||
isValidUsername,
|
||||
getNumMsg,
|
||||
getNumMsgUnread,
|
||||
getMsgText,
|
||||
paotest,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user