first commit
This commit is contained in:
2
tsVue3Decorators/.gitignore
vendored
Normal file
2
tsVue3Decorators/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
src/
|
||||
1
tsVue3Decorators/.pydio
Normal file
1
tsVue3Decorators/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
8d6eef1d-66b6-4fcf-8259-057ee0fb7bda
|
||||
224
tsVue3Decorators/README.md
Normal file
224
tsVue3Decorators/README.md
Normal file
@@ -0,0 +1,224 @@
|
||||
# vue3decorators
|
||||
|
||||
注意这不是一个通用的注解包,这只是脚手架项目
|
||||
|
||||
> Vue3Template:[https://github.com/helpcode/Vue3Template](https://github.com/helpcode/Vue3Template)
|
||||
|
||||
抽离出来的注解,因为每次在项目中使用的时候需要导入太多次,太麻烦。所以将注解处理出来,单独作为包。
|
||||
|
||||
部分注解只能在`Vue3Template`这个脚手架项目中使用,有的是注解通用的!
|
||||
|
||||
**欢迎使用 [Vue3Template](https://github.com/helpcode/Vue3Template) 来快速开发构建您的项目,一起来感受Vue3+Typescript的魅力把..**
|
||||
|
||||
## 1: 安装
|
||||
|
||||
```
|
||||
npm i --save-dev vue3decorators
|
||||
```
|
||||
|
||||
## 2: 使用
|
||||
|
||||
```js
|
||||
import { Injectable, Inject } from 'vue3decorators';
|
||||
|
||||
```
|
||||
|
||||
## 3: 已实现的注解
|
||||
|
||||
注意阅读下面内容的时候请参考 [Vue3Template](https://github.com/helpcode/Vue3Template) 项目来对照看,[Vue3Template](https://github.com/helpcode/Vue3Template) 源码中有更详细的使用和注释!
|
||||
|
||||
### 1:@Directive()
|
||||
|
||||
本注解主要在文件 `directive/index.directive.ts`的类`DirectiveList`中使用,加在类`DirectiveList`的方法上,让方法成为Vue的自定义指令,方法名就是指令名。例如方法`public index() {}`,那么Vue组件中指令则为:`v-index`。
|
||||
|
||||
示例:
|
||||
|
||||
```js
|
||||
# 文件:directive/index.directive.ts
|
||||
|
||||
import { Directive } from 'vue3decorators';
|
||||
export class DirectiveList {
|
||||
@Directive()
|
||||
public index() {
|
||||
return {
|
||||
bind: (el: Element, binding: VNodeDirective, vnode: VNode) => {
|
||||
// console.log(el)
|
||||
// console.log(binding)
|
||||
console.log("v-index 指令接收到的数值:", binding.value);
|
||||
// console.log(vnode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
Vue组件中使用:
|
||||
|
||||
```pug
|
||||
h2(v-index='200') {{title}}
|
||||
```
|
||||
|
||||
### 2:@Injectable(),@Inject() 依赖注入
|
||||
|
||||
注解`@Injectable()`加在类,主要作用是收集依赖,而`@Inject()`加在类的属性上,会把`@Injectable()`的类注入到属性上。
|
||||
|
||||
示例:
|
||||
|
||||
```js
|
||||
import { Injectable, Inject } from 'vue3decorators';
|
||||
|
||||
@Injectable()
|
||||
class Demo1 {
|
||||
public hello: string = "我是Demo1类"
|
||||
}
|
||||
|
||||
class Demo2 {
|
||||
|
||||
@Inject()
|
||||
public test!: Demo1;
|
||||
|
||||
public GetTest(): string {
|
||||
return this.test.hello // 返回:"我是Demo1类"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 3:@GET、@POST、@PUT、@DELETE
|
||||
|
||||
主要在文件 `service/impl` 中使用,加在类的方法上,注解不需要参数。遵守约定:
|
||||
|
||||
被注解的方法名和`index.config.ts` 中 `ApiList` 的key名称一样即可。
|
||||
|
||||
设计思路:
|
||||
|
||||
- 1: `index.dao.ts` 的类 `Axios` 上有注解 `@Injectable()`,当程序通过`init.run.ts`运行的时候,注解`@Injectable()`会将类给存储到公共数组中。
|
||||
- 2: 然后在使用注解`@Inject()`的时候会从数组中将`axios`取出来,然后进行 `new axios()` 实例化,之后保存到专门的`Model`中存放。
|
||||
- 3: 当用户在使用`@GET`、`@POST`、`@PUT`、`@DELETE`这些注解的时候,这些注解会从`Model`取出`axios`的实例,然后调用 `axios`类中的方法进行网络请求。
|
||||
- 4: 请求到的数据会作为`@GET`、`@POST`、`@PUT`、`@DELETE`这些注解所注解方法的返回值,直接返回给方法调用者
|
||||
|
||||
设计的原因:
|
||||
|
||||
注解内部会自动保存并调用,用户配置好的`Axios`实例!而不是使用注解内置自己配置的`Axios`,如果使用注解自身的那么会导致用户的一些自定义请求拦截,自定义请求基地址,自定义请求头都不存在。所以这边注解内部必须使用用户配置好的实例,把自由权交给使用者...
|
||||
|
||||
示例:
|
||||
|
||||
```js
|
||||
import { HomeService } from "../Home.service";
|
||||
import { GET, POST, GlobalMethod } from 'vue3decorators';
|
||||
|
||||
class HomeServiceImpl implements HomeService {
|
||||
|
||||
/**
|
||||
* @GET 被打上这些注解的Service可以在Vue组件中使用。
|
||||
* 1: 方法内部不需要任何的处理逻辑,留空即可。
|
||||
* 2: 方法调用的时候只接受请求需要的参数
|
||||
* 3: 现在V3版本的注解例如@GET()是不需要传入请求地址参数的,方法名就是接口地址的key名称
|
||||
* 例如:index.config.ts 中 ApiList 的key名称
|
||||
* {
|
||||
* DevUrl: 'http://localhost:9000',
|
||||
* ProdUrl: 'http://127.0.0.1:3000',
|
||||
* ApiList: {
|
||||
* index: '/test',
|
||||
* haha: '/haha'
|
||||
* },
|
||||
* }
|
||||
* 这里的key名称:index,haha,直接作为 ServiceImpl 的方法名即可。
|
||||
* 注解内部会自动去根据方法名,例如 index 去寻找 ApiList 下的key,从而拿到请求地址 /test
|
||||
* 然后注解会自动调用用户配置好的Axios,来发送请求,注意请求处理的所有逻辑交给用户。注解只负责
|
||||
* 调用用户配置好的Axios而已。请求成功后,注解会自动调用被注解的方法,然后直接将数据返回给Vue组
|
||||
* 件调用者,这也就是这里为什么方法内部不需要处理逻辑的原因。因为一切都在注解内部实现,并遵守
|
||||
* 约定大于配置 的原则。
|
||||
* @param data object 请求参数
|
||||
*/
|
||||
@GET()
|
||||
public async index(data: object): Promise<any> {}
|
||||
|
||||
@POST()
|
||||
public async haha(data: object): Promise<any> {}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
Vue组件中调用:
|
||||
|
||||
```vue
|
||||
<template lang="pug">
|
||||
// .....
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import HomeServiceImpl from '@impl/home.service.impl'
|
||||
export default createComponent({
|
||||
setup(props: PropOptions, ctx: SetupContext) {
|
||||
onMounted(async ()=> {
|
||||
let data = await HomeServiceImpl.index({ id: 1,page: 1 });
|
||||
console.log("ajax请求到的数据为:", data)
|
||||
})
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
// .....
|
||||
</style>
|
||||
```
|
||||
|
||||
|
||||
### 4:@Mixin()
|
||||
|
||||
主要在文件 `mixin/index.mixin.ts` 中使用,加在类的方法上,会让类的方法自动成为Vue的全局mixin。
|
||||
|
||||
示例:
|
||||
|
||||
```js
|
||||
@Injectable()
|
||||
export class MixinList {
|
||||
|
||||
@Mixin()
|
||||
public Router() {
|
||||
return {
|
||||
beforeCreate: setRuntimeVM
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 5:@GlobalMethod()
|
||||
|
||||
`@GlobalMethod()`可以随意加在类的方法上,不过个人推荐加在`utils/`文件夹的类的方法上。类的方法一旦被加上这个注解那么这个方法将成为全局方法,可以在`Vue`组件中直接是使用,注意组件内调用的时候是:`$方法名()`,之所以加上`$`是为了防止和组件内方法名冲突!!
|
||||
|
||||
示例:
|
||||
|
||||
```js
|
||||
export class Utils {
|
||||
/**
|
||||
* 动态设置网页title
|
||||
* @param title
|
||||
*/
|
||||
@GlobalMethod()
|
||||
public setTitle(title: string): void {
|
||||
document.title = title;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Vue组件中调用:
|
||||
|
||||
```vue
|
||||
<template lang="pug">
|
||||
// .....
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
export default createComponent({
|
||||
setup(props: PropOptions, ctx: SetupContext) {
|
||||
onMounted(async ()=> {
|
||||
console.log("全部方法:", (ctx.root as any).$setTitle("测试"));
|
||||
})
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
// .....
|
||||
</style>
|
||||
```
|
||||
1
tsVue3Decorators/dist/.pydio
vendored
Normal file
1
tsVue3Decorators/dist/.pydio
vendored
Normal file
@@ -0,0 +1 @@
|
||||
52a7ae51-44a0-4fb8-b228-ee992c3329f8
|
||||
1
tsVue3Decorators/dist/decorators/.pydio
vendored
Normal file
1
tsVue3Decorators/dist/decorators/.pydio
vendored
Normal file
@@ -0,0 +1 @@
|
||||
bbffd310-9271-4614-9543-bad796bc6bd6
|
||||
52
tsVue3Decorators/dist/decorators/Ioc.decorators.js
vendored
Normal file
52
tsVue3Decorators/dist/decorators/Ioc.decorators.js
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Inject = exports.Injectable = void 0;
|
||||
var tslib_1 = require("tslib");
|
||||
require("reflect-metadata");
|
||||
var ajax_model_1 = require("../model/ajax.model");
|
||||
//ioc容器 用于存放被依赖的类
|
||||
var classPool = [];
|
||||
// 收集依赖
|
||||
function Injectable() {
|
||||
return function (_constructor) {
|
||||
if (classPool.indexOf(_constructor) !== -1) {
|
||||
throw new Error('无需重复注册');
|
||||
return;
|
||||
}
|
||||
else {
|
||||
//注册
|
||||
classPool.push(_constructor);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.Injectable = Injectable;
|
||||
// 注入依赖
|
||||
function Inject() {
|
||||
return function (_constructor, propertyName) {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var propertyType;
|
||||
return tslib_1.__generator(this, function (_a) {
|
||||
propertyType = Reflect.getMetadata('design:type', _constructor, propertyName);
|
||||
if (classPool.indexOf(propertyType) == -1) {
|
||||
throw new Error(propertyType + " \u6CA1\u6709\u88AB\u6CE8\u518C");
|
||||
return [2 /*return*/];
|
||||
}
|
||||
else {
|
||||
if (propertyName === "config") {
|
||||
ajax_model_1.ajaxModel.urlModelContainer = classPool[classPool.indexOf(propertyType)].AjaxConfig.ApiList;
|
||||
}
|
||||
if (propertyName === "axios") {
|
||||
_constructor[propertyName] = new classPool[classPool.indexOf(propertyType)]();
|
||||
ajax_model_1.ajaxModel.AjaxModelContainer = _constructor[propertyName];
|
||||
}
|
||||
else {
|
||||
_constructor[propertyName] = new classPool[classPool.indexOf(propertyType)]();
|
||||
}
|
||||
return [2 /*return*/, _constructor[propertyName]];
|
||||
}
|
||||
return [2 /*return*/];
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
exports.Inject = Inject;
|
||||
16
tsVue3Decorators/dist/decorators/directive.decorators.js
vendored
Normal file
16
tsVue3Decorators/dist/decorators/directive.decorators.js
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Directive = void 0;
|
||||
require("reflect-metadata");
|
||||
var directive_model_1 = require("../model/directive.model");
|
||||
/**
|
||||
* 收集存储Vue的指令
|
||||
* n: 指令名就是方法名
|
||||
* f: 调用方法后的返回值是个对象
|
||||
*/
|
||||
function Directive() {
|
||||
return function (target, propertyKey) {
|
||||
directive_model_1.directiveModel.DirectiveContainer = { n: propertyKey, f: target[propertyKey]() };
|
||||
};
|
||||
}
|
||||
exports.Directive = Directive;
|
||||
16
tsVue3Decorators/dist/decorators/global.decorators.js
vendored
Normal file
16
tsVue3Decorators/dist/decorators/global.decorators.js
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GlobalMethod = void 0;
|
||||
require("reflect-metadata");
|
||||
var global_method_model_1 = require("../model/global.method.model");
|
||||
/**
|
||||
* 收集存储Vue的指令
|
||||
* n: 指令名就是方法名
|
||||
* f: 调用方法后的返回值是个对象
|
||||
*/
|
||||
function GlobalMethod() {
|
||||
return function (target, propertyKey) {
|
||||
global_method_model_1.globalMethodModel.GlobalMethod = { n: "$" + propertyKey, f: target[propertyKey] };
|
||||
};
|
||||
}
|
||||
exports.GlobalMethod = GlobalMethod;
|
||||
14
tsVue3Decorators/dist/decorators/mixin.decorators.js
vendored
Normal file
14
tsVue3Decorators/dist/decorators/mixin.decorators.js
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Mixin = void 0;
|
||||
require("reflect-metadata");
|
||||
var mixin_model_1 = require("../model/mixin.model");
|
||||
/**
|
||||
* 收集存储mixin
|
||||
*/
|
||||
function Mixin() {
|
||||
return function (target, propertyKey) {
|
||||
mixin_model_1.mixinModel.MixinContainer = target[propertyKey]();
|
||||
};
|
||||
}
|
||||
exports.Mixin = Mixin;
|
||||
166
tsVue3Decorators/dist/decorators/request.decorators.js
vendored
Normal file
166
tsVue3Decorators/dist/decorators/request.decorators.js
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DELETE = exports.PUT = exports.POST = exports.GET = void 0;
|
||||
var tslib_1 = require("tslib");
|
||||
require("reflect-metadata");
|
||||
var ajax_model_1 = require("../model/ajax.model");
|
||||
function GET(RequestParams) {
|
||||
return function (target, propertyKey, descriptor) {
|
||||
var URL = checkUrl(propertyKey), handle = false;
|
||||
(RequestParams && RequestParams.url)
|
||||
? URL = RequestParams.url
|
||||
: (RequestParams && RequestParams.useHandle)
|
||||
? handle = RequestParams.useHandle
|
||||
: '';
|
||||
var OldMethods = descriptor.value;
|
||||
if (handle) {
|
||||
// @ts-ignore
|
||||
descriptor.value = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var result;
|
||||
return tslib_1.__generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, ajax_model_1.ajaxModel.AjaxModelContainer.get({
|
||||
url: URL,
|
||||
data: args[0]
|
||||
})];
|
||||
case 1:
|
||||
result = _a.sent();
|
||||
return [4 /*yield*/, OldMethods.apply(new target.constructor, result)];
|
||||
case 2:
|
||||
_a.sent();
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
return descriptor;
|
||||
}
|
||||
else {
|
||||
descriptor.value = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
return tslib_1.__generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, ajax_model_1.ajaxModel.AjaxModelContainer.get({
|
||||
url: URL,
|
||||
data: args[0]
|
||||
})];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
return descriptor;
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.GET = GET;
|
||||
function POST() {
|
||||
return function (target, propertyKey, descriptor) {
|
||||
var URL = checkUrl(propertyKey);
|
||||
var method = descriptor.value;
|
||||
descriptor.value = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var result;
|
||||
return tslib_1.__generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, ajax_model_1.ajaxModel.AjaxModelContainer.post({
|
||||
url: URL,
|
||||
data: args[0]
|
||||
})];
|
||||
case 1:
|
||||
result = _a.sent();
|
||||
return [4 /*yield*/, method.apply(new target.constructor, result)];
|
||||
case 2:
|
||||
_a.sent();
|
||||
return [2 /*return*/, result];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
exports.POST = POST;
|
||||
function PUT() {
|
||||
return function (target, propertyKey, descriptor) {
|
||||
var URL = checkUrl(propertyKey);
|
||||
var method = descriptor.value;
|
||||
descriptor.value = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var result;
|
||||
return tslib_1.__generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, ajax_model_1.ajaxModel.AjaxModelContainer.put({
|
||||
url: URL,
|
||||
data: args[0]
|
||||
})];
|
||||
case 1:
|
||||
result = _a.sent();
|
||||
return [4 /*yield*/, method.apply(new target.constructor, result)];
|
||||
case 2:
|
||||
_a.sent();
|
||||
return [2 /*return*/, result];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
exports.PUT = PUT;
|
||||
function DELETE() {
|
||||
return function (target, propertyKey, descriptor) {
|
||||
var URL = checkUrl(propertyKey);
|
||||
var method = descriptor.value;
|
||||
descriptor.value = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var result;
|
||||
return tslib_1.__generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, ajax_model_1.ajaxModel.AjaxModelContainer.delete({
|
||||
url: URL,
|
||||
data: args[0]
|
||||
})];
|
||||
case 1:
|
||||
result = _a.sent();
|
||||
return [4 /*yield*/, method.apply(new target.constructor, result)];
|
||||
case 2:
|
||||
_a.sent();
|
||||
return [2 /*return*/, result];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
exports.DELETE = DELETE;
|
||||
function checkUrl(URL) {
|
||||
if (ajax_model_1.ajaxModel.urlModelContainer[URL] == undefined) {
|
||||
throw new Error("\uD83E\uDD2A\u6CE8\u89E3\u4F20\u5165\u53C2\u6570\u7684key\u540D\u79F0\uFF1A" + URL + "\uFF0C\u5728 config.AjaxConfig.ApiList \u5BF9\u8C61\u4E0A\u4E0D\u5B58\u5728\uFF01\uFF01");
|
||||
return '';
|
||||
}
|
||||
else {
|
||||
return ajax_model_1.ajaxModel.urlModelContainer[URL];
|
||||
}
|
||||
}
|
||||
24
tsVue3Decorators/dist/decorators/startboot.decorators.js
vendored
Normal file
24
tsVue3Decorators/dist/decorators/startboot.decorators.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.StartBoot = void 0;
|
||||
var tslib_1 = require("tslib");
|
||||
function StartBoot(closeWelcome) {
|
||||
if (closeWelcome === void 0) { closeWelcome = true; }
|
||||
return function (_constructor) {
|
||||
return /** @class */ (function (_super) {
|
||||
tslib_1.__extends(class_1, _super);
|
||||
function class_1() {
|
||||
var _this = _super.call(this) || this;
|
||||
closeWelcome ? _this.WelcomeUser() : '';
|
||||
return _this;
|
||||
}
|
||||
class_1.prototype.WelcomeUser = function () {
|
||||
console.clear();
|
||||
console.info("🎉 欢迎使用脚手架模板 Vue3Template\n🎉 基于Vue-cli3+Vue3+TypeScript开发,一起感受Vue3+TypeScript的魅力吧\n📦 项目地址:https://github.com/helpcode/Vue3Template\n📦 注解包地址:https://www.npmjs.com/package/vue3decorators");
|
||||
console.log("");
|
||||
};
|
||||
return class_1;
|
||||
}(_constructor));
|
||||
};
|
||||
}
|
||||
exports.StartBoot = StartBoot;
|
||||
1
tsVue3Decorators/dist/model/.pydio
vendored
Normal file
1
tsVue3Decorators/dist/model/.pydio
vendored
Normal file
@@ -0,0 +1 @@
|
||||
67991ae4-3d3c-4efe-ae47-832c0548118d
|
||||
29
tsVue3Decorators/dist/model/ajax.model.js
vendored
Normal file
29
tsVue3Decorators/dist/model/ajax.model.js
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ajaxModel = void 0;
|
||||
var AjaxModel = /** @class */ (function () {
|
||||
function AjaxModel() {
|
||||
}
|
||||
Object.defineProperty(AjaxModel.prototype, "urlModelContainer", {
|
||||
get: function () {
|
||||
return this._urlModelContainer;
|
||||
},
|
||||
set: function (AjaxUrl) {
|
||||
this._urlModelContainer = AjaxUrl;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(AjaxModel.prototype, "AjaxModelContainer", {
|
||||
get: function () {
|
||||
return this._AjaxModelContainer;
|
||||
},
|
||||
set: function (AjaxObjecy) {
|
||||
this._AjaxModelContainer = AjaxObjecy;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return AjaxModel;
|
||||
}());
|
||||
exports.ajaxModel = new AjaxModel();
|
||||
20
tsVue3Decorators/dist/model/directive.model.js
vendored
Normal file
20
tsVue3Decorators/dist/model/directive.model.js
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.directiveModel = void 0;
|
||||
var DirectiveModel = /** @class */ (function () {
|
||||
function DirectiveModel() {
|
||||
this._DirectiveContainer = [];
|
||||
}
|
||||
Object.defineProperty(DirectiveModel.prototype, "DirectiveContainer", {
|
||||
get: function () {
|
||||
return this._DirectiveContainer;
|
||||
},
|
||||
set: function (Directive) {
|
||||
this._DirectiveContainer.push(Directive);
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return DirectiveModel;
|
||||
}());
|
||||
exports.directiveModel = new DirectiveModel();
|
||||
20
tsVue3Decorators/dist/model/global.method.model.js
vendored
Normal file
20
tsVue3Decorators/dist/model/global.method.model.js
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.globalMethodModel = void 0;
|
||||
var GlobalMethod = /** @class */ (function () {
|
||||
function GlobalMethod() {
|
||||
this._GlobalMethod = [];
|
||||
}
|
||||
Object.defineProperty(GlobalMethod.prototype, "GlobalMethod", {
|
||||
get: function () {
|
||||
return this._GlobalMethod;
|
||||
},
|
||||
set: function (globalMethod) {
|
||||
this._GlobalMethod.push(globalMethod);
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return GlobalMethod;
|
||||
}());
|
||||
exports.globalMethodModel = new GlobalMethod();
|
||||
19
tsVue3Decorators/dist/model/injectable.model.js
vendored
Normal file
19
tsVue3Decorators/dist/model/injectable.model.js
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var InjectableModel = /** @class */ (function () {
|
||||
function InjectableModel() {
|
||||
this._InjectableModelContainer = [];
|
||||
}
|
||||
Object.defineProperty(InjectableModel.prototype, "InjectableModel", {
|
||||
get: function () {
|
||||
return this._InjectableModelContainer;
|
||||
},
|
||||
set: function (constructor) {
|
||||
this._InjectableModelContainer.push(constructor);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return InjectableModel;
|
||||
}());
|
||||
exports.InjectModel = new InjectableModel();
|
||||
20
tsVue3Decorators/dist/model/mixin.model.js
vendored
Normal file
20
tsVue3Decorators/dist/model/mixin.model.js
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.mixinModel = void 0;
|
||||
var MixinModel = /** @class */ (function () {
|
||||
function MixinModel() {
|
||||
this._MixinContainer = [];
|
||||
}
|
||||
Object.defineProperty(MixinModel.prototype, "MixinContainer", {
|
||||
get: function () {
|
||||
return this._MixinContainer;
|
||||
},
|
||||
set: function (Mixin) {
|
||||
this._MixinContainer.push(Mixin);
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return MixinModel;
|
||||
}());
|
||||
exports.mixinModel = new MixinModel();
|
||||
19
tsVue3Decorators/dist/model/startboot.model.js
vendored
Normal file
19
tsVue3Decorators/dist/model/startboot.model.js
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var StartbootModel = /** @class */ (function () {
|
||||
function StartbootModel() {
|
||||
this._StartbootModelContainer = [];
|
||||
}
|
||||
Object.defineProperty(StartbootModel.prototype, "StartbootModelContainer", {
|
||||
get: function () {
|
||||
return this._StartbootModelContainer;
|
||||
},
|
||||
set: function (constructor) {
|
||||
this._StartbootModelContainer.push(constructor);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return StartbootModel;
|
||||
}());
|
||||
exports.ajaxModel = new StartbootModel();
|
||||
29
tsVue3Decorators/index.js
Normal file
29
tsVue3Decorators/index.js
Normal file
@@ -0,0 +1,29 @@
|
||||
const { Injectable, Inject } = require("./dist/decorators/Ioc.decorators");
|
||||
const { Directive } = require('./dist/decorators/directive.decorators');
|
||||
const { GlobalMethod } = require('./dist/decorators/global.decorators');
|
||||
const { Mixin } = require('./dist/decorators/mixin.decorators');
|
||||
const { GET, POST, PUT, DELETE } = require('./dist/decorators/request.decorators');
|
||||
const { StartBoot } = require('./dist/decorators/startboot.decorators');
|
||||
|
||||
|
||||
const { directiveModel } = require('./dist/model/directive.model');
|
||||
const { mixinModel } = require('./dist/model/mixin.model');
|
||||
const { globalMethodModel } = require('./dist/model/global.method.model');
|
||||
const { ajaxModel } = require('./dist/model/ajax.model');
|
||||
|
||||
module.exports = {
|
||||
Injectable,
|
||||
Inject,
|
||||
Directive,
|
||||
GlobalMethod,
|
||||
Mixin,
|
||||
GET,
|
||||
POST,
|
||||
PUT,
|
||||
DELETE,
|
||||
StartBoot,
|
||||
directiveModel,
|
||||
mixinModel,
|
||||
globalMethodModel,
|
||||
ajaxModel
|
||||
};
|
||||
20
tsVue3Decorators/package.json
Normal file
20
tsVue3Decorators/package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "vue3decorators",
|
||||
"version": "1.2.8",
|
||||
"description": "基于Vue3+TypeScript写的注解,推荐搭配Vue3Template使用",
|
||||
"main": "index.js",
|
||||
"typings": "types/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"tslib": "^1.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^13.7.1"
|
||||
}
|
||||
}
|
||||
40
tsVue3Decorators/tsconfig.json
Normal file
40
tsVue3Decorators/tsconfig.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "dist/",
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"strict": true,
|
||||
"jsx": "preserve",
|
||||
"importHelpers": true,
|
||||
"moduleResolution": "node",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"declaration": true,
|
||||
"declarationDir": "types",
|
||||
"sourceMap": false,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"src/*"
|
||||
]
|
||||
},
|
||||
"lib": [
|
||||
"esnext",
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"scripthost"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx",
|
||||
"src/**/*.vue",
|
||||
"tests/**/*.ts",
|
||||
"tests/**/*.tsx", "test.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
1
tsVue3Decorators/types/.pydio
Normal file
1
tsVue3Decorators/types/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
3e0e68cc-2a37-4abb-9d84-be7c0039fe78
|
||||
1
tsVue3Decorators/types/decorators/.pydio
Normal file
1
tsVue3Decorators/types/decorators/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
5e424772-d2d2-4c07-946f-0f474faf539b
|
||||
3
tsVue3Decorators/types/decorators/Ioc.decorators.d.ts
vendored
Normal file
3
tsVue3Decorators/types/decorators/Ioc.decorators.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import "reflect-metadata";
|
||||
export declare function Injectable(): (_constructor: Function) => void;
|
||||
export declare function Inject(): (_constructor: any, propertyName: string) => any;
|
||||
7
tsVue3Decorators/types/decorators/directive.decorators.d.ts
vendored
Normal file
7
tsVue3Decorators/types/decorators/directive.decorators.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import "reflect-metadata";
|
||||
/**
|
||||
* 收集存储Vue的指令
|
||||
* n: 指令名就是方法名
|
||||
* f: 调用方法后的返回值是个对象
|
||||
*/
|
||||
export declare function Directive(): (target: any, propertyKey: string) => void;
|
||||
7
tsVue3Decorators/types/decorators/global.decorators.d.ts
vendored
Normal file
7
tsVue3Decorators/types/decorators/global.decorators.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import "reflect-metadata";
|
||||
/**
|
||||
* 收集存储Vue的指令
|
||||
* n: 指令名就是方法名
|
||||
* f: 调用方法后的返回值是个对象
|
||||
*/
|
||||
export declare function GlobalMethod(): (target: any, propertyKey: string) => void;
|
||||
5
tsVue3Decorators/types/decorators/mixin.decorators.d.ts
vendored
Normal file
5
tsVue3Decorators/types/decorators/mixin.decorators.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import "reflect-metadata";
|
||||
/**
|
||||
* 收集存储mixin
|
||||
*/
|
||||
export declare function Mixin(): (target: any, propertyKey: string) => void;
|
||||
8
tsVue3Decorators/types/decorators/request.decorators.d.ts
vendored
Normal file
8
tsVue3Decorators/types/decorators/request.decorators.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import "reflect-metadata";
|
||||
export declare function GET(RequestParams?: {
|
||||
url?: string;
|
||||
useHandle?: boolean;
|
||||
}): (target: any, propertyKey: string, descriptor: any) => any;
|
||||
export declare function POST(): (target: any, propertyKey: string, descriptor: any) => void;
|
||||
export declare function PUT(): (target: any, propertyKey: string, descriptor: any) => void;
|
||||
export declare function DELETE(): (target: any, propertyKey: string, descriptor: any) => void;
|
||||
7
tsVue3Decorators/types/decorators/startboot.decorators.d.ts
vendored
Normal file
7
tsVue3Decorators/types/decorators/startboot.decorators.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export declare function StartBoot(closeWelcome?: boolean): (_constructor: any) => {
|
||||
new (): {
|
||||
[x: string]: any;
|
||||
WelcomeUser(): void;
|
||||
};
|
||||
[x: string]: any;
|
||||
};
|
||||
79
tsVue3Decorators/types/index.d.ts
vendored
Normal file
79
tsVue3Decorators/types/index.d.ts
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
/** Declaration file generated by dts-gen */
|
||||
|
||||
/**
|
||||
* 存储Vue全局指令的容器
|
||||
*/
|
||||
export const directiveModel: {
|
||||
DirectiveContainer: any[];
|
||||
};
|
||||
|
||||
/**
|
||||
* 存储全局方法的容器
|
||||
*/
|
||||
export const globalMethodModel: {
|
||||
GlobalMethod: any[];
|
||||
};
|
||||
|
||||
/**
|
||||
* 存储Vue全局Mixin的容器
|
||||
*/
|
||||
export const mixinModel: {
|
||||
MixinContainer: any[];
|
||||
};
|
||||
|
||||
export const ajaxModel: {
|
||||
AjaxModelContainer: any;
|
||||
};
|
||||
|
||||
/**
|
||||
* 发送 DELETE 请求
|
||||
*/
|
||||
export function DELETE(...args: any[]): any;
|
||||
|
||||
/**
|
||||
* 保存ajax实例
|
||||
* @param args
|
||||
*/
|
||||
export function SaveApi(...args: any[]): any;
|
||||
|
||||
/**
|
||||
* 收集存储指令
|
||||
*/
|
||||
export function Directive(): any;
|
||||
|
||||
/**
|
||||
* 发送 GET 请求
|
||||
*/
|
||||
export function GET(...args: any[]): any;
|
||||
|
||||
/**
|
||||
* 收集全局方法
|
||||
*/
|
||||
export function GlobalMethod(): any;
|
||||
|
||||
/**
|
||||
* 向类的属性注入依赖
|
||||
*/
|
||||
export function Inject(): any;
|
||||
|
||||
/**
|
||||
* 收集依赖
|
||||
*/
|
||||
export function Injectable(): any;
|
||||
|
||||
export function StartBoot(b?: boolean): any;
|
||||
|
||||
/**
|
||||
* 收集全局Mixin
|
||||
*/
|
||||
export function Mixin(): any;
|
||||
|
||||
/**
|
||||
* 发送 POST 请求
|
||||
*/
|
||||
export function POST(...args: any[]): any;
|
||||
|
||||
/**
|
||||
* 发送 PUT 请求
|
||||
*/
|
||||
export function PUT(...args: any[]): any;
|
||||
1
tsVue3Decorators/types/model/.pydio
Normal file
1
tsVue3Decorators/types/model/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
4ae5a038-3437-460d-ba8f-db070e2678d8
|
||||
10
tsVue3Decorators/types/model/ajax.model.d.ts
vendored
Normal file
10
tsVue3Decorators/types/model/ajax.model.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
declare class AjaxModel {
|
||||
private _AjaxModelContainer;
|
||||
private _urlModelContainer;
|
||||
get urlModelContainer(): object;
|
||||
set urlModelContainer(AjaxUrl: object);
|
||||
get AjaxModelContainer(): any;
|
||||
set AjaxModelContainer(AjaxObjecy: any);
|
||||
}
|
||||
export declare const ajaxModel: AjaxModel;
|
||||
export {};
|
||||
7
tsVue3Decorators/types/model/directive.model.d.ts
vendored
Normal file
7
tsVue3Decorators/types/model/directive.model.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
declare class DirectiveModel {
|
||||
private _DirectiveContainer;
|
||||
get DirectiveContainer(): object;
|
||||
set DirectiveContainer(Directive: object);
|
||||
}
|
||||
export declare const directiveModel: DirectiveModel;
|
||||
export {};
|
||||
7
tsVue3Decorators/types/model/global.method.model.d.ts
vendored
Normal file
7
tsVue3Decorators/types/model/global.method.model.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
declare class GlobalMethod {
|
||||
private _GlobalMethod;
|
||||
get GlobalMethod(): any;
|
||||
set GlobalMethod(globalMethod: any);
|
||||
}
|
||||
export declare const globalMethodModel: GlobalMethod;
|
||||
export {};
|
||||
7
tsVue3Decorators/types/model/mixin.model.d.ts
vendored
Normal file
7
tsVue3Decorators/types/model/mixin.model.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
declare class MixinModel {
|
||||
private _MixinContainer;
|
||||
get MixinContainer(): object;
|
||||
set MixinContainer(Mixin: object);
|
||||
}
|
||||
export declare const mixinModel: MixinModel;
|
||||
export {};
|
||||
Reference in New Issue
Block a user