@cmstops/pro-compo 0.1.0 → 0.1.2

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.
Files changed (47) hide show
  1. package/dist/index.css +90 -0
  2. package/dist/index.min.css +1 -1
  3. package/es/appCenter/component.d.ts +0 -0
  4. package/es/appCenter/component.js +186 -0
  5. package/es/appCenter/index.d.ts +2 -0
  6. package/es/appCenter/index.js +7 -0
  7. package/es/appCenter/script/api.d.ts +10 -0
  8. package/es/appCenter/script/api.js +27 -0
  9. package/es/appCenter/script/apps.d.ts +23 -0
  10. package/es/appCenter/script/apps.js +122 -0
  11. package/es/appCenter/script/permissionMap.d.ts +6 -0
  12. package/es/appCenter/script/permissionMap.js +19 -0
  13. package/es/appCenter/script/routeMap.d.ts +4 -0
  14. package/es/appCenter/script/routeMap.js +109 -0
  15. package/es/appCenter/style/css.js +1 -0
  16. package/es/appCenter/style/index.css +90 -0
  17. package/es/appCenter/style/index.d.ts +1 -0
  18. package/es/appCenter/style/index.js +1 -0
  19. package/es/appCenter/style/index.less +100 -0
  20. package/es/button/style/css.js +1 -1
  21. package/es/button/style/index.js +1 -1
  22. package/es/index.css +90 -0
  23. package/es/index.d.ts +1 -0
  24. package/es/index.js +1 -0
  25. package/es/index.less +1 -0
  26. package/es/utils/auth.d.ts +5 -0
  27. package/es/utils/auth.js +9 -0
  28. package/es/utils/request.d.ts +9 -0
  29. package/es/utils/request.js +36 -0
  30. package/lib/appCenter/component.js +187 -0
  31. package/lib/appCenter/index.js +8 -0
  32. package/lib/appCenter/script/api.js +32 -0
  33. package/lib/appCenter/script/apps.js +123 -0
  34. package/lib/appCenter/script/permissionMap.js +20 -0
  35. package/lib/appCenter/script/routeMap.js +110 -0
  36. package/lib/appCenter/style/css.js +2 -0
  37. package/lib/appCenter/style/index.css +90 -0
  38. package/lib/appCenter/style/index.js +2 -0
  39. package/lib/appCenter/style/index.less +100 -0
  40. package/lib/button/style/css.js +1 -1
  41. package/lib/button/style/index.js +1 -1
  42. package/lib/index.css +90 -0
  43. package/lib/index.js +2 -0
  44. package/lib/index.less +1 -0
  45. package/lib/utils/auth.js +12 -0
  46. package/lib/utils/request.js +41 -0
  47. package/package.json +1 -1
@@ -0,0 +1,90 @@
1
+ .reference-btn {
2
+ border: none;
3
+ padding: 12px 16px;
4
+ border-radius: 4px;
5
+ color: #5f5f5f;
6
+ }
7
+ .app-list-wrap {
8
+ position: relative;
9
+ padding: 10px;
10
+ }
11
+ .app-title {
12
+ font-size: 16px;
13
+ font-weight: bold;
14
+ padding: 0px 15px;
15
+ }
16
+ .ul-list {
17
+ list-style: none;
18
+ overflow: hidden;
19
+ width: 435px !important;
20
+ text-align: center;
21
+ padding: 0;
22
+ margin: 0;
23
+ }
24
+ .ul-list .li_item {
25
+ float: left;
26
+ width: 85px;
27
+ height: 90px;
28
+ text-align: center;
29
+ margin: 13px 0;
30
+ position: relative;
31
+ }
32
+ .ul-list .li_item .icon-logo .svg-icon {
33
+ width: 4em;
34
+ height: 3.5em;
35
+ }
36
+ .ul-list .li_item:hover {
37
+ background: rgba(0, 0, 0, 0.05);
38
+ border-radius: 4px;
39
+ cursor: pointer;
40
+ }
41
+ .ul-list .li_item:hover .icon-gengduo {
42
+ display: block;
43
+ }
44
+ .ul-list .li_item .wrap_icon {
45
+ width: 70px;
46
+ display: inline-block;
47
+ margin-top: 6px;
48
+ }
49
+ .ul-list .li_item .wrap_icon .wrap_ .icon-logo {
50
+ width: 70px;
51
+ height: 50px;
52
+ margin-bottom: 4px;
53
+ }
54
+ .ul-list .li_item .wrap_icon .wrap_ .icon-logo img {
55
+ max-width: 100%;
56
+ max-height: 100%;
57
+ }
58
+ .ul-list .li_item .wrap_icon .wrap_ .shortcut-logo {
59
+ line-height: 77px;
60
+ }
61
+ .ul-list .li_item .wrap_icon .wrap_ .shortcut-logo img {
62
+ width: 35px;
63
+ height: 35px;
64
+ }
65
+ .ul-list .li_item .wrap_icon .wrap_ .icon_title {
66
+ width: 73px;
67
+ height: 20px;
68
+ overflow: hidden;
69
+ text-overflow: ellipsis;
70
+ white-space: nowrap;
71
+ }
72
+ .ul-list .li_item .wrap_icon .quick-add .icon-logo {
73
+ width: 40px;
74
+ height: 40px;
75
+ margin: 5px auto 9px;
76
+ text-align: center;
77
+ background-color: rgba(0, 0, 0, 0.12);
78
+ border-radius: 50%;
79
+ }
80
+ .ul-list .li_item .wrap_icon .quick-add .icon-logo i {
81
+ line-height: 40px;
82
+ color: rgba(0, 0, 0, 0.85);
83
+ font-size: 14px;
84
+ }
85
+ .ul-list .li_item .icon-gengduo {
86
+ display: none;
87
+ position: absolute;
88
+ top: 2px;
89
+ right: 4px;
90
+ }
@@ -0,0 +1 @@
1
+ import './index.less';
@@ -0,0 +1 @@
1
+ import "./index.less";
@@ -0,0 +1,100 @@
1
+ .reference-btn {
2
+ border: none;
3
+ padding: 12px 16px;
4
+ border-radius: 4px;
5
+ color: #5f5f5f;
6
+ }
7
+ .app-list-wrap {
8
+ position: relative;
9
+ padding: 10px;
10
+ }
11
+ .app-title {
12
+ font-size: 16px;
13
+ font-weight: bold;
14
+ padding: 0px 15px;
15
+ }
16
+ .ul-list {
17
+ list-style: none;
18
+ overflow: hidden;
19
+ width: 435px !important;
20
+ text-align: center;
21
+ padding: 0;
22
+ margin: 0;
23
+ .li_item {
24
+ float: left;
25
+ width: 85px;
26
+ height: 90px;
27
+ text-align: center;
28
+ // margin-left: 16px;
29
+ margin: 13px 0;
30
+ position: relative;
31
+ .icon-logo {
32
+ .svg-icon {
33
+ width: 4em;
34
+ height: 3.5em;
35
+ }
36
+ }
37
+ &:hover {
38
+ // transition: ease-out 0.2s;
39
+ // transform: scale(1.1);
40
+ background: rgba(0, 0, 0, 0.05);
41
+ border-radius: 4px;
42
+ cursor: pointer;
43
+ .icon-gengduo {
44
+ display: block;
45
+ }
46
+ }
47
+ .wrap_icon {
48
+ width: 70px;
49
+ display: inline-block;
50
+ margin-top: 6px;
51
+ .wrap_ {
52
+ .icon-logo {
53
+ width: 70px;
54
+ height: 50px;
55
+ margin-bottom: 4px;
56
+ img {
57
+ max-width: 100%;
58
+ max-height: 100%;
59
+ }
60
+ }
61
+ .shortcut-logo {
62
+ line-height: 77px;
63
+ img {
64
+ width: 35px;
65
+ height: 35px;
66
+ }
67
+ }
68
+ .icon_title {
69
+ width: 73px;
70
+ height: 20px;
71
+ overflow: hidden;
72
+ text-overflow: ellipsis;
73
+ white-space: nowrap;
74
+ }
75
+ }
76
+ .quick-add {
77
+ .icon-logo {
78
+ width: 40px;
79
+ height: 40px;
80
+ margin: 5px auto 9px;
81
+ text-align: center;
82
+ background-color: rgba(0, 0, 0, 0.12);
83
+ border-radius: 50%;
84
+ i {
85
+ line-height: 40px;
86
+ color: rgba(0, 0, 0, 0.85);
87
+ font-size: 14px;
88
+ }
89
+ }
90
+ }
91
+ }
92
+ .icon-gengduo {
93
+ display: none;
94
+ position: absolute;
95
+ top: 2px;
96
+ right: 4px;
97
+ }
98
+ }
99
+ }
100
+
@@ -1 +1 @@
1
- import "../../index.css";
1
+ import "./index.css";
@@ -1 +1 @@
1
- import "../../index.less";
1
+ import "./index.less";
package/es/index.css CHANGED
@@ -2,3 +2,93 @@
2
2
  height: auto;
3
3
  padding: 20px;
4
4
  }
5
+ .reference-btn {
6
+ border: none;
7
+ padding: 12px 16px;
8
+ border-radius: 4px;
9
+ color: #5f5f5f;
10
+ }
11
+ .app-list-wrap {
12
+ position: relative;
13
+ padding: 10px;
14
+ }
15
+ .app-title {
16
+ font-size: 16px;
17
+ font-weight: bold;
18
+ padding: 0px 15px;
19
+ }
20
+ .ul-list {
21
+ list-style: none;
22
+ overflow: hidden;
23
+ width: 435px !important;
24
+ text-align: center;
25
+ padding: 0;
26
+ margin: 0;
27
+ }
28
+ .ul-list .li_item {
29
+ float: left;
30
+ width: 85px;
31
+ height: 90px;
32
+ text-align: center;
33
+ margin: 13px 0;
34
+ position: relative;
35
+ }
36
+ .ul-list .li_item .icon-logo .svg-icon {
37
+ width: 4em;
38
+ height: 3.5em;
39
+ }
40
+ .ul-list .li_item:hover {
41
+ background: rgba(0, 0, 0, 0.05);
42
+ border-radius: 4px;
43
+ cursor: pointer;
44
+ }
45
+ .ul-list .li_item:hover .icon-gengduo {
46
+ display: block;
47
+ }
48
+ .ul-list .li_item .wrap_icon {
49
+ width: 70px;
50
+ display: inline-block;
51
+ margin-top: 6px;
52
+ }
53
+ .ul-list .li_item .wrap_icon .wrap_ .icon-logo {
54
+ width: 70px;
55
+ height: 50px;
56
+ margin-bottom: 4px;
57
+ }
58
+ .ul-list .li_item .wrap_icon .wrap_ .icon-logo img {
59
+ max-width: 100%;
60
+ max-height: 100%;
61
+ }
62
+ .ul-list .li_item .wrap_icon .wrap_ .shortcut-logo {
63
+ line-height: 77px;
64
+ }
65
+ .ul-list .li_item .wrap_icon .wrap_ .shortcut-logo img {
66
+ width: 35px;
67
+ height: 35px;
68
+ }
69
+ .ul-list .li_item .wrap_icon .wrap_ .icon_title {
70
+ width: 73px;
71
+ height: 20px;
72
+ overflow: hidden;
73
+ text-overflow: ellipsis;
74
+ white-space: nowrap;
75
+ }
76
+ .ul-list .li_item .wrap_icon .quick-add .icon-logo {
77
+ width: 40px;
78
+ height: 40px;
79
+ margin: 5px auto 9px;
80
+ text-align: center;
81
+ background-color: rgba(0, 0, 0, 0.12);
82
+ border-radius: 50%;
83
+ }
84
+ .ul-list .li_item .wrap_icon .quick-add .icon-logo i {
85
+ line-height: 40px;
86
+ color: rgba(0, 0, 0, 0.85);
87
+ font-size: 14px;
88
+ }
89
+ .ul-list .li_item .icon-gengduo {
90
+ display: none;
91
+ position: absolute;
92
+ top: 2px;
93
+ right: 4px;
94
+ }
package/es/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { default } from './components';
2
2
  export { default as button } from './button';
3
+ export { default as appCenter } from './appCenter';
package/es/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { default } from "./components.js";
2
2
  export { default as button } from "./button/index.js";
3
+ export { default as appCenter } from "./appCenter/index.js";
package/es/index.less CHANGED
@@ -1,2 +1,3 @@
1
1
  @import './style/index.less';
2
2
  @import './button/style/index.less';
3
+ @import './appCenter/style/index.less';
@@ -0,0 +1,5 @@
1
+ export declare function getToken(): string | null;
2
+ export declare function setToken(token: string): void;
3
+ export declare function getRID(): string | null;
4
+ export declare function setRID(rid: string | number): void;
5
+ export declare function removeToken(): void;
@@ -0,0 +1,9 @@
1
+ const TokenKey = "cmstop_admin_template_token";
2
+ const RIDKey = "cmstop_admin_template_rid";
3
+ function getToken() {
4
+ return window.sessionStorage.getItem(TokenKey);
5
+ }
6
+ function getRID() {
7
+ return window.sessionStorage.getItem(RIDKey);
8
+ }
9
+ export { getRID, getToken };
@@ -0,0 +1,9 @@
1
+ declare module 'axios' {
2
+ interface AxiosResponse<T = any> {
3
+ code: number;
4
+ data: T;
5
+ message: T;
6
+ }
7
+ function create(config?: AxiosRequestConfig): AxiosInstance;
8
+ }
9
+ export default function (BASE_API: string, options: any): import("axios").AxiosPromise<any>;
@@ -0,0 +1,36 @@
1
+ import axios from "axios";
2
+ import { getToken } from "./auth.js";
3
+ function request(BASE_API, options) {
4
+ const service = axios.create({
5
+ baseURL: BASE_API,
6
+ timeout: 5e3,
7
+ withCredentials: true
8
+ });
9
+ service.interceptors.request.use(
10
+ (config) => {
11
+ if (getToken()) {
12
+ config.headers.Authorization = `Bearer ${getToken()}`;
13
+ }
14
+ return config;
15
+ },
16
+ (error) => {
17
+ console.log(error);
18
+ return Promise.reject(error);
19
+ }
20
+ );
21
+ service.interceptors.response.use(
22
+ (response) => {
23
+ const res = response.data;
24
+ if (res.code !== 0) {
25
+ return Promise.reject(new Error(res.message || "Error"));
26
+ }
27
+ return res;
28
+ },
29
+ (error) => {
30
+ console.log("err" + error);
31
+ return Promise.reject(error);
32
+ }
33
+ );
34
+ return service(options);
35
+ }
36
+ export { request as default };
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ var vue = require("vue");
3
+ var webVue = require("@arco-design/web-vue");
4
+ var routeMap = require("./script/routeMap.js");
5
+ var permissionMap = require("./script/permissionMap.js");
6
+ var apps = require("./script/apps.js");
7
+ var api = require("./script/api.js");
8
+ var auth = require("../utils/auth.js");
9
+ const _hoisted_1 = {
10
+ key: 1,
11
+ class: "reference-btn"
12
+ };
13
+ const _hoisted_2 = { class: "app-list-wrap apps-popover" };
14
+ const _hoisted_3 = {
15
+ key: 0,
16
+ class: "app-title"
17
+ };
18
+ const _hoisted_4 = { class: "ul-list" };
19
+ const _hoisted_5 = ["onClick"];
20
+ const _hoisted_6 = { class: "wrap_icon" };
21
+ const _hoisted_7 = { class: "wrap_" };
22
+ const _hoisted_8 = { class: "icon-logo" };
23
+ const _hoisted_9 = ["src"];
24
+ const _hoisted_10 = { class: "icon_title" };
25
+ const _hoisted_11 = {
26
+ key: 1,
27
+ class: "app-title"
28
+ };
29
+ const _hoisted_12 = { class: "ul-list" };
30
+ const _hoisted_13 = ["onClick"];
31
+ const _hoisted_14 = { class: "wrap_icon" };
32
+ const _hoisted_15 = { class: "wrap_" };
33
+ const _hoisted_16 = { class: "icon-logo" };
34
+ const _hoisted_17 = ["src"];
35
+ const _hoisted_18 = { class: "icon_title" };
36
+ const _sfc_main = vue.defineComponent({
37
+ ...{ name: "appCenter" },
38
+ __name: "component",
39
+ props: {
40
+ BASE_API: {}
41
+ },
42
+ setup(__props) {
43
+ const props = __props;
44
+ const StorePubApplication = vue.ref([]);
45
+ const resentApp = vue.ref([]);
46
+ const permissions = vue.ref([]);
47
+ const slotTest = !!vue.useSlots().reference;
48
+ const rid = auth.getRID() || "4";
49
+ const BASE_API = props.BASE_API || "https://site.cmstop.xyz";
50
+ const navList = vue.computed(() => {
51
+ const appList2 = [];
52
+ StorePubApplication.value.map((item) => {
53
+ item.actions.map((app) => {
54
+ if (!app.icon.includes("http") && !app.icon.includes("data:image") && !app.icon.includes(".svg")) {
55
+ app.icon = `${BASE_API}/static/icon/${app.icon}.svg`;
56
+ }
57
+ const hide = [];
58
+ if (!hide.includes(app.key) && (app.type === 3 || app.subscribed) && hasRight(app)) {
59
+ appList2.push(app);
60
+ }
61
+ return app;
62
+ });
63
+ return item;
64
+ });
65
+ return appList2;
66
+ });
67
+ const resentList = vue.computed(() => {
68
+ return navList.value.filter((item) => {
69
+ return resentApp.value.includes(item.id);
70
+ });
71
+ });
72
+ const remainList = vue.computed(() => {
73
+ return navList.value.filter((item) => {
74
+ return !resentApp.value.includes(item.id);
75
+ });
76
+ });
77
+ const routeRedirect = (item) => {
78
+ if (hasRight(item)) {
79
+ setResent(item);
80
+ routeMap(BASE_API, rid, item.key, item);
81
+ } else {
82
+ webVue.Message.warning({ content: "\u6682\u65E0\u6743\u9650\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458" });
83
+ }
84
+ };
85
+ const hasRight = (item) => {
86
+ return permissionMap(permissions.value, item);
87
+ };
88
+ const getUserActs = async () => {
89
+ const { code, message } = await api.getUserRepoActs(BASE_API);
90
+ if (code === 0 && message) {
91
+ permissions.value = message || [];
92
+ }
93
+ };
94
+ const getResent = async () => {
95
+ const { code, message } = await api.getResentApp(BASE_API, { repo_id: rid });
96
+ if (code === 0 && message) {
97
+ resentApp.value = message.map((item) => parseInt(item, 10));
98
+ }
99
+ };
100
+ const setResent = async (item) => {
101
+ await api.setResentApp(BASE_API, { repo_id: rid, app_id: item.id });
102
+ };
103
+ const load = async () => {
104
+ const result = await api.getPubApps(BASE_API, { rid, type: "2,3" });
105
+ if (result.code === 0) {
106
+ StorePubApplication.value = result.data.concat(apps);
107
+ setTimeout(() => {
108
+ getResent();
109
+ getUserActs();
110
+ }, 500);
111
+ }
112
+ };
113
+ vue.onMounted(() => {
114
+ load();
115
+ });
116
+ return (_ctx, _cache) => {
117
+ return vue.openBlock(), vue.createElementBlock("div", null, [
118
+ vue.createVNode(vue.unref(webVue.Popover), {
119
+ trigger: "hover",
120
+ position: "bottom",
121
+ "arrow-style": { display: "none" },
122
+ "content-style": { padding: 0, minWidth: "400px" }
123
+ }, {
124
+ content: vue.withCtx(() => [
125
+ vue.createElementVNode("div", _hoisted_2, [
126
+ resentList.value.length > 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3, "\u6700\u8FD1\u4F7F\u7528")) : vue.createCommentVNode("v-if", true),
127
+ vue.createElementVNode("ul", _hoisted_4, [
128
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(resentList.value, (item, index) => {
129
+ return vue.openBlock(), vue.createElementBlock("li", {
130
+ key: index,
131
+ class: "li_item"
132
+ }, [
133
+ vue.createElementVNode("div", {
134
+ onClick: ($event) => routeRedirect(item)
135
+ }, [
136
+ vue.createElementVNode("div", _hoisted_6, [
137
+ vue.createElementVNode("div", _hoisted_7, [
138
+ vue.createElementVNode("div", _hoisted_8, [
139
+ vue.createElementVNode("img", {
140
+ src: item.icon,
141
+ class: "icon"
142
+ }, null, 8, _hoisted_9)
143
+ ]),
144
+ vue.createElementVNode("div", _hoisted_10, vue.toDisplayString(item.alias), 1)
145
+ ])
146
+ ])
147
+ ], 8, _hoisted_5)
148
+ ]);
149
+ }), 128))
150
+ ]),
151
+ resentList.value.length > 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_11, "\u76F8\u5173\u5E94\u7528")) : vue.createCommentVNode("v-if", true),
152
+ vue.createElementVNode("ul", _hoisted_12, [
153
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(remainList.value, (item, index) => {
154
+ return vue.openBlock(), vue.createElementBlock("li", {
155
+ key: index,
156
+ class: "li_item"
157
+ }, [
158
+ vue.createElementVNode("div", {
159
+ onClick: ($event) => routeRedirect(item)
160
+ }, [
161
+ vue.createElementVNode("div", _hoisted_14, [
162
+ vue.createElementVNode("div", _hoisted_15, [
163
+ vue.createElementVNode("div", _hoisted_16, [
164
+ vue.createElementVNode("img", {
165
+ src: item.icon,
166
+ class: "icon"
167
+ }, null, 8, _hoisted_17)
168
+ ]),
169
+ vue.createElementVNode("div", _hoisted_18, vue.toDisplayString(item.alias), 1)
170
+ ])
171
+ ])
172
+ ], 8, _hoisted_13)
173
+ ]);
174
+ }), 128))
175
+ ])
176
+ ])
177
+ ]),
178
+ default: vue.withCtx(() => [
179
+ slotTest ? vue.renderSlot(_ctx.$slots, "reference", { key: 0 }) : (vue.openBlock(), vue.createElementBlock("button", _hoisted_1, "\u5E94\u7528\u4E2D\u5FC3"))
180
+ ]),
181
+ _: 3
182
+ })
183
+ ]);
184
+ };
185
+ }
186
+ });
187
+ module.exports = _sfc_main;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var component = require("./component.js");
3
+ const appCenter = Object.assign(component, {
4
+ install: (app) => {
5
+ app.component(component.name, component);
6
+ }
7
+ });
8
+ module.exports = appCenter;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ var request = require("../../utils/request.js");
4
+ function getUserRepoActs(BASE_API) {
5
+ return request(BASE_API, {
6
+ url: `/poplar/v3/ac/account/rules`,
7
+ method: "get"
8
+ });
9
+ }
10
+ function getPubApps(BASE_API, params) {
11
+ return request(BASE_API, {
12
+ url: "/leaf/v1/market/apps",
13
+ method: "get",
14
+ params
15
+ });
16
+ }
17
+ function getResentApp(BASE_API, params) {
18
+ return request(BASE_API, {
19
+ url: `/poplar/v2/repo/${params.repo_id}/common/apps`,
20
+ method: "get"
21
+ });
22
+ }
23
+ function setResentApp(BASE_API, params) {
24
+ return request(BASE_API, {
25
+ url: `/poplar/v2/repo/${params.repo_id}/app/${params.app_id}/access`,
26
+ method: "post"
27
+ });
28
+ }
29
+ exports.getPubApps = getPubApps;
30
+ exports.getResentApp = getResentApp;
31
+ exports.getUserRepoActs = getUserRepoActs;
32
+ exports.setResentApp = setResentApp;