Browse Source

KERNEL-14512 refact: router

es6
Treecat 1 year ago
parent
commit
1e31ad0ffa
  1. 12
      src/bundle.js
  2. 72
      src/core/decorator.js
  3. 2
      src/core/index.js
  4. 2
      src/core/system.js
  5. 7
      src/index.js
  6. 1224
      src/router/0.router.js
  7. 2
      src/router/index.js
  8. 5951
      src/router/router.js
  9. 2
      template/index.html

12
src/bundle.js

@ -1,4 +1,14 @@
import * as fineui from "./index";
import { shortcut, provider } from "@/core/5.inject";
import { _global } from "@/core/0.foundation";
import * as Decorators from "@/core/decorator";
Object.assign(BI, fineui, { shortcut, provider });
_global.BI = _global.BI || {};
_global.BI.Decorators = Decorators;
_global.Fix = fineui.Fix;
_global._ = fineui._;
_global.$ = fineui.$;
Object.assign(_global.BI, fineui, { shortcut, provider });

72
src/core/decorator.js

@ -1,6 +1,11 @@
// export * from "../../typescript/core/decorator/decorator.ts";
import { shortcut as biShortcut, provider as biProvider } from "./5.inject";
import {
shortcut as biShortcut,
provider as biProvider,
model as biModel,
Models
} from "./5.inject";
/**
* 注册widget
@ -19,3 +24,68 @@ export function provider() {
biProvider(Target.xtype, Target);
};
}
/**
* 注册model
*/
export function model() {
return function decorator(Target) {
biModel(Target.xtype, Target);
};
}
/**
* 类注册_store属性
* @param Model model类
* @param opts 额外条件
*/
export function store(Model, opts) {
return function classDecorator(constructor) {
return class extends constructor {
_store() {
const props = opts.props ? opts.props.apply(this) : undefined;
return Models.getModel(Model.xtype, props);
}
};
};
}
/**
* 注册mixin
* ie8下不能使用
*/
export function mixin() {
return function decorator(Target) {
const mixin = {};
Object.getOwnPropertyNames(Target.prototype).forEach(name => {
if (name === "constructor") {
return;
}
mixin[name] = Target.prototype[name];
});
Fix.mixin(Target.xtype, mixin);
};
}
/**
* 类注册mixins属性
* ie8下不能使用
* @param Mixins
*/
export function mixins(...Mixins) {
return function classDecorator(constructor) {
const mixins = [];
Mixins.forEach(mixin => {
mixin.xtype && mixins.push(mixin.xtype);
});
return class extends constructor {
mixins = mixins;
};
};
}

2
src/core/index.js

@ -22,7 +22,7 @@ export * from "./5.inject";
export * from "./6.plugin";
export * from "./system";
export * from "./action";
export * from "./behavior";
// export * from "./behavior";
// export * from "./controller";
export * from "./func";
export * from "./structure";

2
src/core/system.js

@ -4,7 +4,7 @@
* Created by windy on 2021/6/30
*/
import { prepares } from "./0.foundation";
import { deepExtend, extend, inherit, object } from "./2.base";
import { deepExtend, extend } from "./2.base";
import { OB } from "./3.ob";
import { Providers } from "./5.inject";
import { provider } from "./decorator";

7
src/index.js

@ -1,8 +1,13 @@
import "./polyfill";
import _jquery from "jquery";
export * from "./core";
export * from "./base";
export * from "./case";
export * from "./widget";
export * from "./component";
export * from "./fix";
export * from "./router";
export const jQuery = _jquery;
export const $ = _jquery;

1224
src/router/0.router.js

File diff suppressed because it is too large Load Diff

2
src/router/index.js

@ -1,2 +1,2 @@
export * from "./0.router";
export * from "./router";
export * from "./router";

5951
src/router/router.js

File diff suppressed because it is too large Load Diff

2
template/index.html

@ -38,7 +38,7 @@
<div id="wrapper"></div>
</body>
<script src="../dist/router.js"></script>
<!-- <script src="../dist/router.js"></script> -->
<script>
BI.pixUnit = "rem";
BI.pixRatio = 10;

Loading…
Cancel
Save