hzerojs-plugin-yqcloud-jssdk 1.0.21 → 1.0.23

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/lib/index.js CHANGED
@@ -128,23 +128,27 @@ var src_default = (props) => {
128
128
  urlParam = `&fieldData=${fieldData}${authParam}`;
129
129
  }
130
130
  const modal = import_modal.default.open({
131
- // title: '测试',
132
131
  maskClosable: true,
133
132
  bodyStyle: {
134
- width: (openFunction == null ? void 0 : openFunction.viewSize) || 800,
135
- padding: 0,
133
+ width: "100%",
136
134
  height: "100%",
137
- overflow: "hidden"
135
+ position: "relative",
136
+ maxHeight: "100vh",
137
+ padding: "0",
138
+ margin: "0"
138
139
  },
139
140
  style: {
140
141
  // top: 50,
141
142
  },
142
143
  contentStyle: {
144
+ position: "relative",
143
145
  width: (openFunction == null ? void 0 : openFunction.viewSize) || 800,
144
- height: "calc(100vh - 100px)"
146
+ height: "calc(100vh - 100px)",
147
+ padding: "0",
148
+ margin: "0"
145
149
  },
146
150
  header: null,
147
- children: /* @__PURE__ */ import_react.default.createElement("iframe", { id: "yq-sdk-frame", style: { width: "100%", height: "100%" }, src: `${openFunction.link}${urlParam}`, frameBorder: "0" }),
151
+ children: /* @__PURE__ */ import_react.default.createElement("div", { style: { position: "absolute", width: "100%", height: "calc(100% - 40px)", bottom: "0" } }, /* @__PURE__ */ import_react.default.createElement("div", { style: { position: "absolute", top: "-30px", right: "10px" } }, /* @__PURE__ */ import_react.default.createElement("svg", { width: "24", height: "24", viewBox: "0 0 48 48", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react.default.createElement("path", { d: "M8 8L40 40", stroke: "#333", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ import_react.default.createElement("path", { d: "M8 40L40 8", stroke: "#333", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round" }))), /* @__PURE__ */ import_react.default.createElement("iframe", { id: "yq-sdk-frame", style: { width: "100%", height: "100%" }, src: `${openFunction.link}${urlParam}`, frameBorder: "0" })),
148
152
  footer: null
149
153
  });
150
154
  function closeModal(e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hzerojs-plugin-yqcloud-jssdk",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "main": "lib/index.js",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -9,13 +9,8 @@
9
9
  "peerDependencies": {
10
10
  "axios": "*"
11
11
  },
12
- "dependencies": {
13
- "choerodon-ui": "^1.6.1-yqcloud-alpha.2",
14
- "react": "^16.14.0"
15
- },
16
12
  "files": [
17
13
  "lib",
18
- "browsers",
19
- "src"
14
+ "browsers"
20
15
  ]
21
16
  }
package/src/index.css DELETED
@@ -1,14 +0,0 @@
1
- .yqcloud-hzero-jssdk-popover .c7n-popover-inner-content{
2
- padding: 0;
3
- }
4
- .yq-hzero-jssdk-btn:hover {
5
- color: #0840f8;
6
- }
7
- .yq-hzero-jssdk-btn {
8
- font-size: 13px;
9
- color: #0f1358;
10
- cursor: pointer;
11
- }
12
- .yqcloud-hzero-jssdk-popover.c7n-popover.c7n-popover .c7n-popover-content .c7n-popover-inner .c7n-popover-inner-content {
13
- padding: 0;
14
- }
package/src/index.tsx DELETED
@@ -1,184 +0,0 @@
1
- import React, {useEffect} from 'react';
2
- import Modal from 'choerodon-ui/pro/es/modal';
3
- import Menu from 'choerodon-ui/pro/es/menu';
4
- import Popover from 'choerodon-ui/es/popover';
5
- import axios from 'axios';
6
- const YQ_API_HOST = 'https://api.test.yqcloud.com';
7
- import './index.css';
8
- // const TOKEN = '10ef346d-85fc-423a-9995-08731db60ba5';
9
- export default (props) => {
10
- const { token, entryDetail, apiHost = YQ_API_HOST, tokenPath = '/iam/v1/zknow/encrypt/quick' } = props;
11
- const eleRef = React.useRef( null);
12
- const tenantIdRef = React.useRef(null);
13
- const [appConfig, setAppConfig] = React.useState(false);
14
- const [isVisible, setIsVisble] = React.useState(false);
15
- React.useEffect(() => {
16
- let observer: any = null;
17
- if (eleRef.current && 'IntersectionObserver' in window &&
18
- 'IntersectionObserverEntry' in window &&
19
- 'intersectionRatio' in window.IntersectionObserverEntry.prototype) {
20
- observer = new IntersectionObserver(entries => {
21
- if (entries[0].intersectionRatio === 1 ) {
22
- setIsVisble(true);
23
- // console.log('进入可视区域');
24
- // do something
25
- } else {
26
- setIsVisble(false);
27
- // console.log('移出可视区域');
28
- // do something
29
- }
30
- });
31
-
32
- observer.observe(eleRef.current);
33
- }
34
- return () => {
35
- if(observer) {
36
- observer.disconnect();
37
- }
38
- };
39
- }, []);
40
- React.useEffect(() => {
41
- if(isVisible) {
42
- console.log('悬浮窗展开了');
43
- } else {
44
- console.log('悬浮窗收起了');
45
- }
46
- }, [isVisible]);
47
-
48
- async function yqRequest(url: string, method: string, data?: any) {
49
- return new Promise<any>((resolve) => {
50
- const xhr = new XMLHttpRequest();
51
- xhr.withCredentials = false;
52
-
53
- xhr.addEventListener('readystatechange', function () {
54
- if (xhr.readyState === 4) {
55
- try {
56
- const res = JSON.parse(xhr.responseText);
57
- resolve(res);
58
- } catch (e) {
59
- resolve(xhr.responseText);
60
- // console.log('【YQCloud】xhr请求解析失败:', e, xhr.responseText);
61
- }
62
- }
63
- });
64
- xhr.open(
65
- method,
66
- url
67
- );
68
- xhr.setRequestHeader('Accept', 'application/json');
69
- xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
70
- if (tenantIdRef.current) {
71
- xhr.setRequestHeader('x-tenant-id', tenantIdRef.current);
72
- }
73
- xhr.send(JSON.stringify(data));
74
- });
75
- }
76
-
77
- useEffect(() => {
78
- const url = `${apiHost}/iam/yqc/open_apps/quick/${token}`;
79
-
80
- yqRequest(url, 'GET').then(function(jsonData) {
81
- try {
82
- if (jsonData && jsonData.failed) {
83
- console.log('【YQCloud】:', jsonData.message);
84
- } else {
85
- const appConfig = JSON.parse(jsonData.jsonConfig);
86
- tenantIdRef.current = jsonData.tenantId;
87
- setAppConfig(appConfig);
88
- console.log('【YQCloud】解析配置成功:', appConfig);
89
- // document.body.appendChild(component(appConfig));
90
- }
91
- } catch (e) {
92
- console.log('【YQCloud】解析配置失败:', e);
93
- }
94
- });
95
- }, [isVisible]);
96
- const openModal = async (openFunction) => {
97
-
98
- const secret = await axios.get(tokenPath || '/iam/v1/zknow/encrypt/quick');
99
- const authUrl = `${apiHost}/oauth/public/quick_authentication?token=${token}`;
100
- const res = await yqRequest(authUrl, 'POST',{
101
- secret,
102
- // code,
103
- });
104
-
105
- const authParam = `&redirectFlag&access_token=${res.accessToken}&token_type=bearer&state=&expires_in=86399&scope=default`;
106
- // fields default value, ex: '{userName:"yqcloud"}'
107
- const fieldData = sessionStorage.getItem('YQ_FIELD_DATA');
108
- let urlParam = authParam;
109
- if (fieldData) {
110
- urlParam = `&fieldData=${fieldData}${authParam}`;
111
- }
112
-
113
- const modal = Modal.open({
114
- // title: '测试',
115
- maskClosable: true,
116
- bodyStyle: {
117
- width: openFunction?.viewSize || 800,
118
- padding: 0,
119
- height: '100%',
120
- overflow: 'hidden'
121
- },
122
- style: {
123
- // top: 50,
124
- },
125
- contentStyle: {
126
- width: openFunction?.viewSize || 800,
127
- height: 'calc(100vh - 100px)'
128
- },
129
- header: null,
130
- children: (
131
- <iframe id="yq-sdk-frame" style={{ width: '100%', height: '100%'}} src={`${openFunction.link}${urlParam}`} frameBorder="0"></iframe>
132
- ),
133
- footer: null,
134
- });
135
- function closeModal(e) {
136
- if (e.data === 'yq_close_modal') {
137
- modal.close();
138
- window.removeEventListener('message', closeModal);
139
- }
140
- }
141
- window.addEventListener('message', closeModal);
142
- };
143
- function defaultIcon() {
144
- return <div type="picture" style={{width: 18, height: 18, marginRight: 10, display: 'inline-block'}} />;
145
- }
146
- const menu = (
147
- <Menu>
148
- {appConfig?.openFunctions?.map((openFunction) => {
149
- if (openFunction.enabledFlag) {
150
- return (
151
- <Menu.Item onClick={() => openModal(openFunction)} key={openFunction.id}>
152
- {openFunction.icon ? <img
153
- style={{width: 18, height: 18, marginRight: 10}}
154
- src={`${apiHost}/hfle/yqc/v1/0/files/download-by-key?fileKey=${openFunction.icon}`}
155
- alt=""/> : defaultIcon()}
156
- {openFunction.displayName}
157
- </Menu.Item>
158
- );
159
- }
160
- return null;
161
- })}
162
- </Menu>
163
- );
164
-
165
- const onlyOneButton = (
166
- <div className="yq-hzero-jssdk-btn" style={{ padding: 0 }} onClick={() => openModal(appConfig?.openFunctions[0])}>
167
- {appConfig.icon ? <img style={{width: 18, height: 18, marginRight: 10}} src={`${apiHost}/hfle/yqc/v1/0/files/download-by-key?fileKey=${appConfig.icon}`} alt=""/> : <div type="picture" style={{width: 18, height: 18, marginRight: 10, display: 'inline-block'}} />}
168
- {entryDetail?.entryName || appConfig?.displayName || appConfig?.name}
169
- </div>
170
- );
171
-
172
- return (
173
- <div className="yqcloud-hzero-jssdk" ref={eleRef}>
174
- {appConfig?.openFunctions?.length === 1 ? onlyOneButton : (
175
- <Popover overlayClassName="yqcloud-hzero-jssdk-popover" overlayStyle={{ padding: 0 }} openClassName="yqcloud-hzero-jssdk-popover" content={menu} placement="left">
176
- <div className="yq-hzero-jssdk-btn" style={{ padding: 0 }}>
177
- {appConfig.icon ? <img style={{width: 18, height: 18, marginRight: 10}} src={`${apiHost}/hfle/yqc/v1/0/files/download-by-key?fileKey=${appConfig.icon}`} alt=""/> : <div type="picture" style={{width: 18, height: 18, marginRight: 10, display: 'inline-block'}} />}
178
- {entryDetail?.entryName || appConfig?.displayName || appConfig?.name}
179
- </div>
180
- </Popover>
181
- )}
182
- </div>
183
- );
184
- };
package/src/util.ts DELETED
@@ -1,4 +0,0 @@
1
-
2
- export function sayHello() {
3
- console.log('Hello World.')
4
- }