@ajaxjs/ui 1.3.11 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -30
- package/dist/ajaxjs-ui.cjs.js +1 -0
- package/dist/ajaxjs-ui.es.js +33 -0
- package/dist/ajaxjs-ui.umd.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/utils.d.ts +18 -0
- package/package.json +54 -49
- package/.browserslistrc +0 -3
- package/.eslintrc.js +0 -26
- package/babel.config.js +0 -5
- package/deprecated/api-helper.zip +0 -0
- package/deprecated/api-helper2.zip +0 -0
- package/deprecated/api-selector.zip +0 -0
- package/deprecated/common-ui.zip +0 -0
- package/deprecated/data-source.zip +0 -0
- package/deprecated/table-selector.zip +0 -0
- package/deprecated/utils.js +0 -220
- package/dist/@ajaxjs/ui.common.js +0 -4321
- package/dist/@ajaxjs/ui.common.js.map +0 -1
- package/dist/@ajaxjs/ui.css +0 -1
- package/dist/@ajaxjs/ui.umd.js +0 -4332
- package/dist/@ajaxjs/ui.umd.js.map +0 -1
- package/dist/@ajaxjs/ui.umd.min.js +0 -2
- package/dist/@ajaxjs/ui.umd.min.js.map +0 -1
- package/dist/demo.html +0 -1
- package/examples/App.vue +0 -137
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -17
- package/src/data-source/data-source.less +0 -46
- package/src/data-source/data-source.ts +0 -97
- package/src/data-source/data-source.vue +0 -59
- package/src/iam/iam.ts +0 -65
- package/src/iam/user.vue +0 -53
- package/src/index.js +0 -52
- package/src/iview-ext/fast-iview-table.ts +0 -133
- package/src/iview-ext/fast-iview-table.vue +0 -67
- package/src/iview-ext/list.ts +0 -108
- package/src/iview-ext/table-selector.vue +0 -185
- package/src/iview-ext/tips.vue +0 -17
- package/src/libs/api-helper.d.ts +0 -194
- package/src/libs/api-list.d.ts +0 -15
- package/src/libs/common.d.ts +0 -201
- package/src/libs/entity.ts +0 -31
- package/src/libs/iview-widgets.ts +0 -73
- package/src/main.ts +0 -7
- package/src/shims-tsx.d.ts +0 -11
- package/src/shims-vue.d.ts +0 -4
- package/src/style/common-functions.less +0 -286
- package/src/style/reset.less +0 -19
- package/src/style/reset2.less +0 -49
- package/tsconfig.json +0 -40
- package/vue.config.js +0 -14
package/examples/App.vue
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="demo">
|
|
3
|
-
<menu>
|
|
4
|
-
<a href="#" @click="show = 'intro'">简介</a> |
|
|
5
|
-
<!-- <a href="#" @click="show = 'baseFn'">基础函数</a> | -->
|
|
6
|
-
<a href="#" @click="show = 'widget'">页面 widget</a> |
|
|
7
|
-
<a href="#" @click="show = 'form'">表单组件</a> |
|
|
8
|
-
<a href="#" @click="show = 'html-editor'">HTML 编辑器</a> |
|
|
9
|
-
<a href="#" @click="show = 'calendar'">日历选择器</a> |
|
|
10
|
-
<a href="#" @click="show = 'play-ground'">试验场</a>
|
|
11
|
-
</menu>
|
|
12
|
-
<table class="all-center" v-if="show == 'intro'">
|
|
13
|
-
<tr>
|
|
14
|
-
<td>
|
|
15
|
-
<h1>ajaxjs.js 前端组件库</h1>
|
|
16
|
-
<Tips text="Foo" />
|
|
17
|
-
<ul>
|
|
18
|
-
<li>
|
|
19
|
-
这是一个个人练手项目,组件不是很全,只有顶部导航列出那些。要求大而全的请参考
|
|
20
|
-
element/ant/iview
|
|
21
|
-
</li>
|
|
22
|
-
<li>
|
|
23
|
-
轻量级,原先打算做一个纯原生的 UI 库,啥都不依赖,后面入坑 vue 才只依赖 vue 2
|
|
24
|
-
</li>
|
|
25
|
-
<li>
|
|
26
|
-
简单易懂的代码,不折腾。当然了,是 typescript。不过我没有用 class 风格,只是加入参数类型、返回值类型,这就足够了
|
|
27
|
-
</li>
|
|
28
|
-
<li>CSS 基于 less.js</li>
|
|
29
|
-
</ul>
|
|
30
|
-
<p class="p">安装 npm i @ajaxjs/ui</p>
|
|
31
|
-
|
|
32
|
-
<p>
|
|
33
|
-
<a href="https://www.npmjs.com/package/@ajaxjs/ui">npm</a>
|
|
34
|
-
|
|
|
35
|
-
<a href="https://gitee.com/sp42_admin/ajaxjs/tree/master/aj-ui-widget/aj">源码</a>
|
|
36
|
-
|
|
|
37
|
-
<a target="_blank" href="//shang.qq.com/wpa/qunwpa?idkey=3877893a4ed3a5f0be01e809e7ac120e346102bd550deb6692239bb42de38e22">QQ 群:3150067</a>
|
|
38
|
-
|
|
|
39
|
-
<a href="mailto:frank@ajaxjs.com">Email</a> |
|
|
40
|
-
<a target="_blank" href="http://blog.csdn.net/zhangxin09">作者博客</a>
|
|
41
|
-
<center>©1999-2022 Frank Cheung</center>
|
|
42
|
-
</p>
|
|
43
|
-
</td>
|
|
44
|
-
</tr>
|
|
45
|
-
</table>
|
|
46
|
-
</div>
|
|
47
|
-
</template>
|
|
48
|
-
|
|
49
|
-
<script>
|
|
50
|
-
import Tips from "../src/iview-ext/tips.vue";
|
|
51
|
-
|
|
52
|
-
export default {
|
|
53
|
-
components: { Tips },
|
|
54
|
-
data() {
|
|
55
|
-
return {
|
|
56
|
-
show: "intro",
|
|
57
|
-
};
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
</script>
|
|
61
|
-
|
|
62
|
-
<style lang="less">
|
|
63
|
-
@import "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css";
|
|
64
|
-
|
|
65
|
-
a {
|
|
66
|
-
color: gray;
|
|
67
|
-
}
|
|
68
|
-
a:hover {
|
|
69
|
-
color: black;
|
|
70
|
-
}
|
|
71
|
-
.demo {
|
|
72
|
-
font-size: 11pt;
|
|
73
|
-
menu {
|
|
74
|
-
margin: 0;
|
|
75
|
-
padding: 0;
|
|
76
|
-
line-height: 40px;
|
|
77
|
-
height: 40px;
|
|
78
|
-
// width: 300px;
|
|
79
|
-
text-align: center;
|
|
80
|
-
border-bottom: 1px solid lightgray;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
table.all-center {
|
|
85
|
-
width: 100%;
|
|
86
|
-
font-size: 11pt;
|
|
87
|
-
td {
|
|
88
|
-
vertical-align: middle;
|
|
89
|
-
text-align: center;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
h1 {
|
|
94
|
-
margin: 20px;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.home {
|
|
98
|
-
& > h2 {
|
|
99
|
-
margin: 30px auto;
|
|
100
|
-
}
|
|
101
|
-
& > h2,
|
|
102
|
-
& > p {
|
|
103
|
-
margin: 20px auto;
|
|
104
|
-
width: 600px;
|
|
105
|
-
text-align: justify;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
</style>
|
|
109
|
-
|
|
110
|
-
<style lang="less" scoped>
|
|
111
|
-
h1 {
|
|
112
|
-
margin: 30px;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
ul {
|
|
116
|
-
max-width: 500px;
|
|
117
|
-
margin: 20px auto;
|
|
118
|
-
color: gray;
|
|
119
|
-
li {
|
|
120
|
-
text-align: left;
|
|
121
|
-
list-style-type: initial;
|
|
122
|
-
padding-bottom: 10px;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
p.p {
|
|
127
|
-
// .aj-text-function();
|
|
128
|
-
max-width: 500px;
|
|
129
|
-
margin: 20px auto;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
center {
|
|
133
|
-
margin: 20px;
|
|
134
|
-
font-size: 9pt;
|
|
135
|
-
color: lightgray;
|
|
136
|
-
}
|
|
137
|
-
</style>
|
package/public/favicon.ico
DELETED
|
Binary file
|
package/public/index.html
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
-
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
7
|
-
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
|
8
|
-
<title>Demo Page</title>
|
|
9
|
-
</head>
|
|
10
|
-
<body>
|
|
11
|
-
<noscript>
|
|
12
|
-
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
|
13
|
-
</noscript>
|
|
14
|
-
<div id="app"></div>
|
|
15
|
-
<!-- built files will be auto injected -->
|
|
16
|
-
</body>
|
|
17
|
-
</html>
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
.datasource {
|
|
2
|
-
.left {
|
|
3
|
-
float: left;
|
|
4
|
-
width: 28%;
|
|
5
|
-
height: 300px;
|
|
6
|
-
border-right: 1px solid #f5f5f5;
|
|
7
|
-
|
|
8
|
-
ul {
|
|
9
|
-
margin: 0 2%;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
li {
|
|
13
|
-
border-bottom: 1px solid #eaeaea;
|
|
14
|
-
padding: 5px 8px;
|
|
15
|
-
cursor: pointer;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
li:hover {
|
|
19
|
-
border-bottom-color: lightgray;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
li.actived {
|
|
23
|
-
font-weight: bold;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.right {
|
|
28
|
-
float: right;
|
|
29
|
-
width: 70%;
|
|
30
|
-
padding-left: 10px;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.add {
|
|
34
|
-
display: block;
|
|
35
|
-
padding: 5px 10px;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.del-icon {
|
|
39
|
-
float: right;
|
|
40
|
-
margin-top: 3px
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.del-icon:hover {
|
|
44
|
-
color: brown;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { Xhr } from "@ajaxjs/util";
|
|
2
|
-
import Vue from "vue";
|
|
3
|
-
|
|
4
|
-
const DBType = { 'MY_SQL': 'MySQL', 'ORACLE': 'Oracle', 'SQL_SERVER': 'Sql Server', 'SPARK': 'Spark', 'SQLITE': 'SQLite', DB2: 'DB2' };
|
|
5
|
-
// @ts-ignore xxxxxxxx
|
|
6
|
-
const DATASOURCE_API = window.API_ROOT ? API_ROOT + '/data_service/datasource' : '../../data_service/datasource';
|
|
7
|
-
// @ts-ignore xxxxxxxxxx
|
|
8
|
-
const DATA_SERVICE_API = window.API_ROOT ? API_ROOT + '/data_service/admin' : '../../data_service/admin';
|
|
9
|
-
|
|
10
|
-
export default Vue.extend({
|
|
11
|
-
name: 'DataSource',
|
|
12
|
-
data(): object {
|
|
13
|
-
return {
|
|
14
|
-
isCreate: true,
|
|
15
|
-
datasources: [
|
|
16
|
-
{
|
|
17
|
-
id: 1,
|
|
18
|
-
name: '加载中……'
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
activedItem: null,
|
|
22
|
-
editing: {},
|
|
23
|
-
form: {
|
|
24
|
-
data: {},
|
|
25
|
-
rules: {
|
|
26
|
-
name: [
|
|
27
|
-
{ required: true, message: '数据源名称不能为空', trigger: 'blur' }
|
|
28
|
-
],
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
DBType: DBType
|
|
32
|
-
};
|
|
33
|
-
},
|
|
34
|
-
mounted(): void {
|
|
35
|
-
this.getList();
|
|
36
|
-
},
|
|
37
|
-
methods: {
|
|
38
|
-
active(item): void {
|
|
39
|
-
this.activedItem = item.id;
|
|
40
|
-
this.form.data = item;
|
|
41
|
-
},
|
|
42
|
-
getList(cb): void {
|
|
43
|
-
// @ts-ignore xxxx
|
|
44
|
-
xhr_get(`${window.config.dsApiRoot}/datasource`, (j: RepsonseResult) => {
|
|
45
|
-
this.datasources = j.data;
|
|
46
|
-
}, { start: 0, limit: 99 });
|
|
47
|
-
},
|
|
48
|
-
add(): void {
|
|
49
|
-
this.activedItem = null;
|
|
50
|
-
this.form.data = {
|
|
51
|
-
name: ''
|
|
52
|
-
};
|
|
53
|
-
},
|
|
54
|
-
create(): void {
|
|
55
|
-
this.$refs.editForm.validate((valid) => {
|
|
56
|
-
if (valid) {
|
|
57
|
-
Xhr.xhr_post(DATASOURCE_API, this.form.data, j => {
|
|
58
|
-
if (j.status === 1) {
|
|
59
|
-
const newlyId = j.data;
|
|
60
|
-
this.getList(() => this.activedItem = newlyId);
|
|
61
|
-
this.$Message.success('创建数据源成功');
|
|
62
|
-
this.form.data.id = newlyId;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
} else
|
|
66
|
-
this.$Message.error('表单验证不通过');
|
|
67
|
-
});
|
|
68
|
-
},
|
|
69
|
-
update(): void {
|
|
70
|
-
const entity = Object.assign({}, this.form.data);
|
|
71
|
-
Xhr.xhr_put(DATASOURCE_API, entity, j => {
|
|
72
|
-
if (j.status === 1) {
|
|
73
|
-
this.$Message.success('修改数据源成功');
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
},
|
|
77
|
-
del(id, name): void {
|
|
78
|
-
this.$Modal.confirm({
|
|
79
|
-
title: '删除数据源',
|
|
80
|
-
content: `是否删除数据源 #${name}?`,
|
|
81
|
-
onOk: () => {
|
|
82
|
-
Xhr.xhr_del(DATASOURCE_API + id, j => {
|
|
83
|
-
this.$Message.success('删除数据源成功');
|
|
84
|
-
this.getList(() => this.add());
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
},
|
|
89
|
-
test(): void {
|
|
90
|
-
// @ts-ignore xxxxxx
|
|
91
|
-
xhr_get(`${window.config.dsApiRoot}/datasource/test/` + this.activedItem, (j: RepsonseResult) => {
|
|
92
|
-
if (j.status)
|
|
93
|
-
this.$Modal.success({ title: '连接数据源成功' });
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
});
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="datasource" style="overflow: hidden">
|
|
3
|
-
<div class="left">
|
|
4
|
-
<ul>
|
|
5
|
-
<li v-for="datasource in datasources" :key="datasource.id" @click="active(datasource)" :class="{ actived: activedItem == datasource.id }">
|
|
6
|
-
<span>
|
|
7
|
-
<Icon type="md-trash" class="del-icon" title="删除此数据源" @click="del(datasource.id, datasource.name)" />
|
|
8
|
-
</span>
|
|
9
|
-
{{datasource.name}}
|
|
10
|
-
</li>
|
|
11
|
-
</ul>
|
|
12
|
-
<a class="add" @click="add">+ 新建……</a>
|
|
13
|
-
</div>
|
|
14
|
-
<div class="right">
|
|
15
|
-
<i-Form ref="editForm" :model="form.data" :rules="form.rules" :label-width="120" style="margin-right:100px">
|
|
16
|
-
<form-item label="数据源名称" prop="name">
|
|
17
|
-
<i-Input v-model="form.data.name" placeholder="数据源名称" />
|
|
18
|
-
</form-item>
|
|
19
|
-
<form-item label="数据源编码" prop="urlDir">
|
|
20
|
-
<i-Input v-model="form.data.urlDir" placeholder="数据源编码全局唯一不重复" />
|
|
21
|
-
</form-item>
|
|
22
|
-
<form-item label="数据库类型" prop="type">
|
|
23
|
-
<i-Select v-model="form.data.type">
|
|
24
|
-
<i-Option v-for="(value, key) in DBType" :value="key" :key="key">{{ value }}</i-Option>
|
|
25
|
-
</i-Select>
|
|
26
|
-
</form-item>
|
|
27
|
-
<form-item label="连接地址" prop="url">
|
|
28
|
-
<i-Input v-model="form.data.url" maxlength="200" show-word-limit type="textarea" :rows="4" placeholder="数据库连接 URL,注意无须携带用户名和密码,且不需要 URL 转义" />
|
|
29
|
-
</form-item>
|
|
30
|
-
<form-item label="登录用户" prop="username">
|
|
31
|
-
<i-Input v-model="form.data.username" placeholder="请输入数据库用户账号" />
|
|
32
|
-
</form-item>
|
|
33
|
-
<form-item label="登录密码" prop="password">
|
|
34
|
-
<i-Input v-model="form.data.password" type="password" password placeholder="请输入账号密码" />
|
|
35
|
-
</form-item>
|
|
36
|
-
<form-item label="是否跨库" prop="crossDb">
|
|
37
|
-
<i-switch v-model="form.data.crossDb" />
|
|
38
|
-
</form-item>
|
|
39
|
-
</i-Form>
|
|
40
|
-
|
|
41
|
-
<div align="center">
|
|
42
|
-
<i-Button v-if="!activedItem" icon="md-checkmark" @click="create">保存新建</i-Button>
|
|
43
|
-
<i-Button v-if="activedItem" @click="update">保存</i-Button>
|
|
44
|
-
<i-Button v-if="activedItem" @click="test">测试连接</i-Button>
|
|
45
|
-
<i-Button v-if="activedItem" @click="$emit('change_datasource', form.data)">切换</i-Button>
|
|
46
|
-
</div>
|
|
47
|
-
<!-- <i-Input v-model="editing.name" ref="inputName">
|
|
48
|
-
<span slot="prepend">环境名称</span>
|
|
49
|
-
</i-Input>
|
|
50
|
-
<br />
|
|
51
|
-
<i-Input v-model="editing.urlPrefix">
|
|
52
|
-
<span slot="prepend">URL前缀</span>
|
|
53
|
-
</i-Input> -->
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
</template>
|
|
57
|
-
|
|
58
|
-
<script lang="ts" src="./data-source.ts"></script>
|
|
59
|
-
<style lang="less" scoped src="./data-source.less"></style>
|
package/src/iam/iam.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { Xhr } from "@ajaxjs/util";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 获取登录信息
|
|
5
|
-
*
|
|
6
|
-
* @returns 用户 JWT
|
|
7
|
-
*/
|
|
8
|
-
export default {
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @param loginUrl 登录页面地址
|
|
13
|
-
* @param thisPageUrl 前端页面的地址,最后返回这里
|
|
14
|
-
* @returns
|
|
15
|
-
*/
|
|
16
|
-
getLoginInfo(loginUrl: string, thisPageUrl: string): any {
|
|
17
|
-
const token = getQueryParam("token", false);
|
|
18
|
-
let accessToken: string = localStorage.getItem("accessToken");
|
|
19
|
-
|
|
20
|
-
if (!accessToken && !token) {
|
|
21
|
-
console.log('你未登录!');
|
|
22
|
-
const target = `${loginUrl}?web_url=${encodeURIComponent(thisPageUrl)}`;
|
|
23
|
-
|
|
24
|
-
confirm('你未登录。是否跳转到登录页面?') && location.assign(target);
|
|
25
|
-
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (token) {
|
|
30
|
-
accessToken = decodeURIComponent(token);
|
|
31
|
-
localStorage.setItem("accessToken", accessToken);
|
|
32
|
-
|
|
33
|
-
// 只需要第一次的参数,之后不需要,现在清除
|
|
34
|
-
const url: URL = new URL(location.href); // 创建一个包含查询参数的URL
|
|
35
|
-
const params: URLSearchParams = new URLSearchParams(url.search);// 获取URL中的查询参数
|
|
36
|
-
params.delete('token');// 删除名为'b'的参数
|
|
37
|
-
url.search = params.toString();// 更新URL的查询参数
|
|
38
|
-
|
|
39
|
-
location.assign(url.href);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// window.JWT_TOKEN = JSON.parse(accessToken);
|
|
43
|
-
Xhr.setBaseHeadParams({ Authorization: 'Bearer ' + accessToken });
|
|
44
|
-
|
|
45
|
-
// 将 JWT Token 拆分为三个部分
|
|
46
|
-
const tokenParts: string[] = accessToken.split('.')
|
|
47
|
-
const payload = JSON.parse(atob(tokenParts[1])); // 解析载荷
|
|
48
|
-
|
|
49
|
-
return payload;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
function getQueryParam(variable: string, isParent: boolean): string | null {
|
|
54
|
-
const query: string = (isParent ? parent.location : window.location).search.substring(1);
|
|
55
|
-
const vars: string[] = query.split("&");
|
|
56
|
-
|
|
57
|
-
for (let i = 0; i < vars.length; i++) {
|
|
58
|
-
const pair: string[] = vars[i].split("=");
|
|
59
|
-
|
|
60
|
-
if (pair[0] == variable)
|
|
61
|
-
return pair[1];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return null;
|
|
65
|
-
}
|
package/src/iam/user.vue
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<a @click="showUserInfo">{{ state }}</a>
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script lang="ts">
|
|
6
|
-
import { Utils } from "@ajaxjs/util";
|
|
7
|
-
import Vue from "vue";
|
|
8
|
-
|
|
9
|
-
const logout = "localStorage.removeItem('accessToken');location.reload();";
|
|
10
|
-
|
|
11
|
-
export default Vue.extend({
|
|
12
|
-
name: 'IamUser',
|
|
13
|
-
data() {
|
|
14
|
-
return {
|
|
15
|
-
state: "未登录",
|
|
16
|
-
isShowInfo: false,
|
|
17
|
-
payload: null,
|
|
18
|
-
};
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
mounted(): void {
|
|
22
|
-
// localStorage.setItem("accessToken", 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxIiwibmFtZSI6ImFkbWluIiwiYXVkIjoiREVGQVVMVF9TQ09QRTt0ZW5hbnRJZD0wIiwiZXhwIjoxNzIxMjMzMTE0LCJpc3MiOiJmb29AYmFyLm5ldCIsImlhdCI6MTcyMTE0NjcxNH0.mykPFQv2fkqmEk1UJs6vErtwATIdUmmbNvJDCMP4pMI');
|
|
23
|
-
let accessToken: string = localStorage.getItem("accessToken");
|
|
24
|
-
|
|
25
|
-
if (accessToken) {
|
|
26
|
-
// 将 JWT Token 拆分为三个部分
|
|
27
|
-
const tokenParts: string[] = accessToken.split(".");
|
|
28
|
-
const payload = JSON.parse(atob(tokenParts[1])); // 解析载荷
|
|
29
|
-
|
|
30
|
-
this.payload = payload;
|
|
31
|
-
this.state = payload.name + "已登录";
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
methods: {
|
|
35
|
-
showUserInfo(): void {
|
|
36
|
-
if (this.state === "未登录") {
|
|
37
|
-
// @ts-ignore xxx
|
|
38
|
-
location.assign(window.config.loginUrl);
|
|
39
|
-
} else {
|
|
40
|
-
this.$Modal.info({
|
|
41
|
-
title: "当前用户信息",
|
|
42
|
-
content: `<p>用户名: ${
|
|
43
|
-
this.payload.name
|
|
44
|
-
}</p><p>Token 过期时间:${Utils.dateFormat.call(
|
|
45
|
-
new Date(this.payload.exp * 1000),
|
|
46
|
-
"yyyy-MM-dd hh:mm:ss"
|
|
47
|
-
)}</p><p><a href="#" onclick="${logout}">用户登出</a></p>`,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
</script>
|
package/src/index.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// 动态引入组件
|
|
2
|
-
const requireComponent = require.context('./', true, /\.vue$/);
|
|
3
|
-
import List from './iview-ext/list';
|
|
4
|
-
import IAM from './iam/iam';
|
|
5
|
-
|
|
6
|
-
const components = {};
|
|
7
|
-
|
|
8
|
-
requireComponent.keys().forEach(fileName => {
|
|
9
|
-
if (fileName != './App.vue') {
|
|
10
|
-
const cmp = requireComponent(fileName).default || requireComponent(fileName);
|
|
11
|
-
if (cmp.extendOptions)
|
|
12
|
-
components[cmp.extendOptions.name] = cmp;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
// 插件
|
|
17
|
-
const install = (Vue) => {
|
|
18
|
-
if (install.installed)
|
|
19
|
-
return install.installed;
|
|
20
|
-
|
|
21
|
-
requireComponent.keys().forEach(fileName => {
|
|
22
|
-
if (fileName != './App.vue') {
|
|
23
|
-
// 第i个组件
|
|
24
|
-
const cmp = requireComponent(fileName).default || requireComponent(fileName);
|
|
25
|
-
|
|
26
|
-
if (cmp.extendOptions && cmp.extendOptions.name) {
|
|
27
|
-
// console.log(fileName, cmp.extendOptions.name);
|
|
28
|
-
|
|
29
|
-
// 注册组件(组件名,组件)
|
|
30
|
-
Vue.component(cmp.extendOptions.name, cmp);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// 全局自定义指令
|
|
36
|
-
Vue.directive('focus', {
|
|
37
|
-
inserted: function (el) {
|
|
38
|
-
el.focus();
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// 环境检测
|
|
44
|
-
if (typeof window !== 'undefined' && window.Vue)
|
|
45
|
-
install(window.Vue);
|
|
46
|
-
|
|
47
|
-
export default {
|
|
48
|
-
install,
|
|
49
|
-
List,
|
|
50
|
-
IAM,
|
|
51
|
-
...components//组件也一样要暴露
|
|
52
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import Vue from "vue";
|
|
2
|
-
import List from "./list";
|
|
3
|
-
import { Xhr } from '@ajaxjs/util';
|
|
4
|
-
|
|
5
|
-
export default Vue.extend({
|
|
6
|
-
name: "FastViewTable",
|
|
7
|
-
props: {
|
|
8
|
-
widgetName: { type: String, required: false },
|
|
9
|
-
apiUrl: { type: String, required: false }, // 接口地址
|
|
10
|
-
columnsDef: { type: Array, required: false }, // 列定义
|
|
11
|
-
listApiUrl: { type: String, required: true },
|
|
12
|
-
createRoute: { type: String, required: false }, // 新建事件触发时候,进入的路由地址
|
|
13
|
-
editRoute: { type: String, required: false }, // 编辑事件触发时候,进入的路由地址
|
|
14
|
-
pickup: { type: Boolean, required: false }, // 编辑事件触发时候,进入的路由地址
|
|
15
|
-
},
|
|
16
|
-
data() {
|
|
17
|
-
return {
|
|
18
|
-
widgetName_: this.widgetName,
|
|
19
|
-
listApiUrl_: this.listApiUrl,
|
|
20
|
-
colDefId: 0,
|
|
21
|
-
list: {
|
|
22
|
-
columns: this.columnsDef || [],
|
|
23
|
-
data: [],
|
|
24
|
-
total: 0,
|
|
25
|
-
start: 0,
|
|
26
|
-
limit: 9,
|
|
27
|
-
pageNo: 1,
|
|
28
|
-
pageSize: 9,
|
|
29
|
-
loading: false,
|
|
30
|
-
search: {
|
|
31
|
-
name: ''
|
|
32
|
-
},
|
|
33
|
-
} as TableListConfig
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
mounted() {
|
|
37
|
-
this.getData();
|
|
38
|
-
},
|
|
39
|
-
methods: {
|
|
40
|
-
getData(): void {
|
|
41
|
-
this.list.loading = true;
|
|
42
|
-
const params: any = { pageNo: this.list.pageNo, pageSize: this.list.pageSize };
|
|
43
|
-
|
|
44
|
-
// if (this.list.search.name)
|
|
45
|
-
// params.where = `name LIKE '%${this.list.search.name}%'`;
|
|
46
|
-
|
|
47
|
-
this.listApiUrl_ && Xhr.xhr_get(this.listApiUrl_, (j: RepsonseResult) => {
|
|
48
|
-
this.list.loading = false;
|
|
49
|
-
|
|
50
|
-
if (j.status) {
|
|
51
|
-
this.list.data = j.data.rows;
|
|
52
|
-
this.list.total = j.data.total;
|
|
53
|
-
} else
|
|
54
|
-
this.$Message.warning(j.message || '获取列表失败');
|
|
55
|
-
}, params);
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* 分页记录数
|
|
60
|
-
*/
|
|
61
|
-
handleChangePageSize(pageSize: number): void {
|
|
62
|
-
this.list.limit = pageSize;
|
|
63
|
-
this.getData();
|
|
64
|
-
},
|
|
65
|
-
reset(): void {
|
|
66
|
-
for (const i in this.search)
|
|
67
|
-
this.search[i] = "";
|
|
68
|
-
|
|
69
|
-
this.getData();
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* 新建
|
|
74
|
-
*/
|
|
75
|
-
onCreate(): void {
|
|
76
|
-
if (this.createRoute)
|
|
77
|
-
this.$router.push({ path: this.createRoute }); // 进入详情页,采用相对路径
|
|
78
|
-
else {
|
|
79
|
-
if (!this.$parent.onCreate)
|
|
80
|
-
throw '请设置父组件的 onCreate 事件处理器';
|
|
81
|
-
|
|
82
|
-
this.$parent.onCreate();
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* 编辑
|
|
88
|
-
*/
|
|
89
|
-
onEdit(id: number): void {
|
|
90
|
-
if (this.editRoute)
|
|
91
|
-
this.$router.push({ path: this.editRoute, query: { id } }); // 进入详情页,采用相对路径
|
|
92
|
-
else {
|
|
93
|
-
if (!this.$parent.onEdit)
|
|
94
|
-
throw '请设置父组件的 onEdit 事件处理器';
|
|
95
|
-
|
|
96
|
-
this.$parent.onEdit(id);
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
doPickup(data: any): void {
|
|
101
|
-
this.$emit("on-select", data);
|
|
102
|
-
},
|
|
103
|
-
deleteInfo(id: number, index: number): void {
|
|
104
|
-
this.list.loading = true;
|
|
105
|
-
Xhr.xhr_del(`${this.apiUrl}/${id}`, List.afterDelete(() => {
|
|
106
|
-
this.list.data.splice(index, 1);
|
|
107
|
-
this.list.total--;
|
|
108
|
-
this.list.loading = false;
|
|
109
|
-
}).bind(this));
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
watch: {
|
|
113
|
-
listApiUrl(v: string): void {
|
|
114
|
-
// debugger
|
|
115
|
-
this.listApiUrl_ = v;
|
|
116
|
-
this.getData();
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* 分页
|
|
121
|
-
*
|
|
122
|
-
* @param v
|
|
123
|
-
*/
|
|
124
|
-
current(v: number): void {
|
|
125
|
-
this.start = (v - 1) * this.list.limit;
|
|
126
|
-
this.getData();
|
|
127
|
-
},
|
|
128
|
-
'list.pageNo'(v: number): void {
|
|
129
|
-
this.list.start = (v - 1) * this.list.limit;
|
|
130
|
-
this.getData();
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
});
|