// worker.js
ws.onmessage = ({data}) => {
if (data[0] !== '{') {
data = pako.ungzip(data.split('').map(x => x.charCodeAt(0)), { to: 'string' });
};
try { data = JSON.parse(data); } catch(e) { return; };
self.postMessage(data);
};
// vue actions.js
WEBSOCKET_SEND_MESSAGE: function({ state }, msg) {
state.socketWorker.postMessage(msg);
},
// Шаблон любого компонента, который может общаться в сокет
<template>
<button @click="WEBSOCKET_SEND_MESSAGE({ a:'someServerAction' })">SomeBtn</button>
</template>
<script>
import { mapActions } from 'vuex';
methods: {
...mapActions(['WEBSOCKET_SEND_MESSAGE']),
},
</script>
var arr1 = [
[ {name: 'Name11', init: 1}, ],
];
var arr2 = [
[ {name: 'Name3', init: 2}, ],
];
arr2.forEach(
i => (
(v = i[0].init),
(b = arr1.findIndex(r => r[0].init === v)),
(!!~b ? (arr1[b] = [...arr1[b], ...i]) : arr1.push([i]))
)
);
console.log(arr1);
var arr1 = [
[
{name: 'Name11', init: 1},
],
];
var arr2 = [
[
{name: 'Name3', init: 2},
]
];
arr2.forEach(
i => (
(v = i[0].init),
(b = arr1.findIndex(r => r[0].init === v)),
(!!~b && (arr1[b] = [...arr1[b], ...i]))
)
);
channel.overwritePermissions([
{
id: message.guild.roles.everyone.id,
deny: ['MANAGE_ROLES', 'MANAGE_CHANNELS', 'MANAGE_MESSAGES', 'MANAGE_WEBHOOKS','ATTACH_FILES', 'EMBED_LINKS', 'SEND_TTS_MESSAGES', 'SEND_MESSAGES'],
allow: ['VIEW_CHANNEL', 'READ_MESSAGE_HISTORY'],
},
]);