mirror of
https://github.com/MetinSeylan/Vue-Socket.io.git
synced 2025-04-16 15:21:28 +02:00
Merge 3a9c579aa5
into 2f63eebb70
This commit is contained in:
commit
b608d10c9c
4 changed files with 26 additions and 9 deletions
|
@ -87,6 +87,7 @@ new Vue({
|
|||
**Parameters**|**Type's**|**Default**|**Required**|**Description**
|
||||
-----|-----|-----|-----|-----
|
||||
debug|Boolean|`false`|Optional|Enable logging for debug
|
||||
darkMode|Boolean|prefers-color-scheme|Optional|Enable console dark mode for debug
|
||||
connection|String/Socket.io-client|`null`|Required|Websocket server url or socket.io-client instance
|
||||
vuex.store|Vuex|`null`|Optional|Vuex store instance
|
||||
vuex.actionPrefix|String|`null`|Optional|Prefix for emitting server side vuex actions
|
||||
|
|
10
dist/vue-socketio.js
vendored
10
dist/vue-socketio.js
vendored
File diff suppressed because one or more lines are too long
|
@ -11,11 +11,13 @@ export default class VueSocketIO {
|
|||
* @param io
|
||||
* @param vuex
|
||||
* @param debug
|
||||
* @param darkMode
|
||||
* @param options
|
||||
*/
|
||||
constructor({connection, vuex, debug, options}){
|
||||
constructor({connection, vuex, debug, darkMode, options}){
|
||||
|
||||
Logger.debug = debug;
|
||||
Logger.darkMode = darkMode || window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
this.io = this.connect(connection, options);
|
||||
this.emitter = new Emitter(vuex);
|
||||
this.listener = new Listener(this.io, this.emitter);
|
||||
|
|
|
@ -4,13 +4,19 @@
|
|||
export default new class VueSocketIOLogger {
|
||||
|
||||
constructor() {
|
||||
this.darkMode = false;
|
||||
this.debug = false;
|
||||
this.prefix = '%cVue-Socket.io: ';
|
||||
}
|
||||
|
||||
info(text, data = '') {
|
||||
|
||||
if(this.debug) window.console.info(this.prefix+`%c${text}`, 'color: blue; font-weight: 600', 'color: #333333', data);
|
||||
if(this.debug) {
|
||||
if (this.darkMode) {
|
||||
window.console.info(this.prefix+`%c${text}`, 'color: #A9D341; font-weight: 600', 'color: #F7AC15', data);
|
||||
} else {
|
||||
window.console.info(this.prefix+`%c${text}`, 'color: blue; font-weight: 600', 'color: #333333', data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -28,8 +34,14 @@ export default new class VueSocketIOLogger {
|
|||
|
||||
event(text, data = ''){
|
||||
|
||||
if(this.debug) window.console.info(this.prefix+`%c${text}`, 'color: blue; font-weight: 600', 'color: #333333', data);
|
||||
if(this.debug) {
|
||||
if (this.darkMode) {
|
||||
window.console.info(this.prefix+`%c${text}`, 'color: #A9D341; font-weight: 600', 'color: #F7AC15', data);
|
||||
} else {
|
||||
window.console.info(this.prefix+`%c${text}`, 'color: blue; font-weight: 600', 'color: #333333', data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue