cushax-client
Advanced tools
Comparing version 0.1.18 to 0.1.19
@@ -13,2 +13,3 @@ /// <reference types="socket.io-client" /> | ||
installed: boolean; | ||
mounted: boolean; | ||
verified: boolean; | ||
@@ -15,0 +16,0 @@ install: (Vue: VueConstructor) => void; |
@@ -36,2 +36,3 @@ import io from "socket.io-client"; | ||
options: options, | ||
mounted: false, | ||
}; | ||
@@ -38,0 +39,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { matchPage, existPage } from "./utils"; | ||
import { matchPage, existPage, buildPage } from "./utils"; | ||
import { Page } from "./page"; | ||
@@ -14,23 +14,30 @@ import { Cushax } from "./cushax"; | ||
var route = $vue.$route; | ||
var pageName = matchPage(route); | ||
var cushax = new Cushax(socket, $vue, cushaxObject); | ||
var page = existPage(schema, pageName) | ||
? new Page(pageName, schema, socket, $vue) | ||
: undefined; | ||
for (var _i = 0, _b = $vue.$root.$children; _i < _b.length; _i++) { | ||
var component = _b[_i]; | ||
component.$cushax = cushax; | ||
component.$getCushax = function () { return cushax; }; | ||
} | ||
for (var _c = 0, _d = (_a = route === null || route === void 0 ? void 0 : route.matched) !== null && _a !== void 0 ? _a : []; _c < _d.length; _c++) { | ||
var instances = _d[_c].instances; | ||
for (var _e = 0, _f = Object.values(instances); _e < _f.length; _e++) { | ||
var instance = _f[_e]; | ||
if (!instance) { | ||
continue; | ||
$vue.$cushax = cushax; | ||
$vue.$getCushax = function () { return cushax; }; | ||
for (var _i = 0, _b = (_a = route === null || route === void 0 ? void 0 : route.matched) !== null && _a !== void 0 ? _a : []; _i < _b.length; _i++) { | ||
var instances = _b[_i].instances; | ||
var _loop_1 = function (instance) { | ||
if (!instance || !instance._uid === $vue._uid) { | ||
return "continue"; | ||
} | ||
instance.$cushax = cushax; | ||
instance.$getCushax = function () { return cushax; }; | ||
// hack first loaded page | ||
if (!cushaxObject.mounted) { | ||
cushaxObject.mounted = true; | ||
setTimeout(function () { | ||
socket.emit("page:sync", { | ||
enter: buildPage(route, instance.$store), | ||
}); | ||
}); | ||
} | ||
var pageName = matchPage(route); | ||
var page = existPage(schema, pageName) | ||
? new Page(pageName, schema, socket, $vue) | ||
: undefined; | ||
instance.$page = page; | ||
instance.$getPage = function () { return page; }; | ||
}; | ||
for (var _c = 0, _d = Object.values(instances); _c < _d.length; _c++) { | ||
var instance = _d[_c]; | ||
_loop_1(instance); | ||
} | ||
@@ -37,0 +44,0 @@ } |
{ | ||
"name": "cushax-client", | ||
"version": "0.1.18", | ||
"version": "0.1.19", | ||
"author": "boenfu <1997@boenfu.cn>", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
17809
399