hzerojs-plugin-yqcloud-jssdk 1.0.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.
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+
3
+ const TestLayoutHeaderExtra = () => {
4
+ return <div style={{color: '#fff', border: '1px solid red'}}>testLayoutHeaderExtra</div>
5
+ }
6
+
7
+ export default TestLayoutHeaderExtra;
@@ -0,0 +1,61 @@
1
+ // @ts-ignore
2
+ import { useModel } from 'umi';
3
+ import React, { useMemo } from 'react';
4
+ import { Layout } from 'choerodon-ui';
5
+ // import { useLayoutController } from '@hzerojs/plugin-layout/lib/clients/HzeroLayout/hooks';
6
+ // @ts-ignore
7
+ import layoutCommonStyles from './styles.less';
8
+ // import { Mode } from '../../../src';
9
+
10
+ export interface HorizontalLayoutProps {
11
+ children: JSX.Element;
12
+ /** 完整路由表 */
13
+ // routes: IRoute[];
14
+ /** 当前层级路由表 */
15
+ // route: IRoute;
16
+ }
17
+
18
+ export default function HorizontalLayout(props: HorizontalLayoutProps) {
19
+ const { children } = props;
20
+
21
+ const layoutController = useModel('hzeroLayout');
22
+
23
+ const routes = useMemo(() => layoutController.getRoutes(), [
24
+ layoutController.routerData,
25
+ ]);
26
+
27
+ return (
28
+ <Layout style={{ height: '100vh' }}>
29
+ <Layout.Sider width={220}>
30
+ <Layout>
31
+ <Layout.Header
32
+ className={layoutCommonStyles['layout-header']}
33
+ style={{ padding: '0' }}
34
+ >
35
+ <h2 style={{ height: '100%', color: '#fff' }}>
36
+ 🚀 hzerojs3 horizontal 布局
37
+ </h2>
38
+ </Layout.Header>
39
+ <Layout.Content className={layoutCommonStyles['layout-content']}>
40
+ <div style={{ height: '100%', overflowY: 'scroll' }}>
41
+ 路由菜单组件
42
+ </div>
43
+ </Layout.Content>
44
+ </Layout>
45
+ </Layout.Sider>
46
+ <Layout.Content style={{ zIndex: 1 }}>
47
+ <Layout>
48
+ <Layout.Header
49
+ className={layoutCommonStyles['layout-header']}
50
+ style={{ color: '#fff', padding: '0' }}
51
+ >
52
+ header
53
+ </Layout.Header>
54
+ <Layout.Content className={layoutCommonStyles['layout-content']}>
55
+ {children}
56
+ </Layout.Content>
57
+ </Layout>
58
+ </Layout.Content>
59
+ </Layout>
60
+ );
61
+ }
@@ -0,0 +1,14 @@
1
+
2
+ .layout-content {
3
+ height: calc(100vh - 48px);
4
+ background-color: #f0f2f5;
5
+ overflow-x: visible;
6
+ // overflow-y: visible;
7
+ // z-index: 0;
8
+ // overflow-x: hidden;
9
+ }
10
+
11
+ .layout-header {
12
+ height: 48px;
13
+ line-height: 48px;
14
+ }
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+
3
+ const TestPage2 = () => {
4
+ return <div>TestPage2</div>
5
+ }
6
+
7
+ export default TestPage2;
package/lib/index.css ADDED
@@ -0,0 +1,3 @@
1
+ .yqcloud-hzero-jssdk-popover .c7n-popover-inner-content{
2
+ padding: 0;
3
+ }
package/lib/index.js ADDED
@@ -0,0 +1,131 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/index.tsx
30
+ var src_exports = {};
31
+ __export(src_exports, {
32
+ default: () => src_default
33
+ });
34
+ module.exports = __toCommonJS(src_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_modal = __toESM(require("choerodon-ui/pro/es/modal"));
37
+ var import_menu = __toESM(require("choerodon-ui/pro/es/menu"));
38
+ var import_popover = __toESM(require("choerodon-ui/es/popover"));
39
+ var import_button = __toESM(require("choerodon-ui/pro/es/button"));
40
+ var import_axios = __toESM(require("axios"));
41
+ var import_index = require("./index.css");
42
+ var YQ_API_HOST = "https://api.test.yqcloud.com";
43
+ var src_default = (props) => {
44
+ var _a, _b;
45
+ const { token, entryDetail, apiHost = YQ_API_HOST } = props;
46
+ debugger;
47
+ const eleRef = import_react.default.useRef(null);
48
+ const [appConfig, setAppConfig] = import_react.default.useState(false);
49
+ const [isVisible, setIsVisble] = import_react.default.useState(false);
50
+ import_react.default.useEffect(() => {
51
+ let observer = null;
52
+ if (eleRef.current && "IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype) {
53
+ observer = new IntersectionObserver((entries) => {
54
+ if (entries[0].intersectionRatio === 1) {
55
+ setIsVisble(true);
56
+ } else {
57
+ setIsVisble(false);
58
+ }
59
+ });
60
+ ;
61
+ observer.observe(eleRef.current);
62
+ }
63
+ return () => {
64
+ if (observer) {
65
+ observer.disconnect();
66
+ }
67
+ };
68
+ }, []);
69
+ import_react.default.useEffect(() => {
70
+ if (isVisible) {
71
+ console.log("悬浮窗展开了");
72
+ } else {
73
+ console.log("悬浮窗收起了");
74
+ }
75
+ }, [isVisible]);
76
+ (0, import_react.useEffect)(() => {
77
+ const url = `${apiHost}/iam/yqc/open_apps/quick/${token}`;
78
+ (0, import_axios.default)(url).then(function(jsonData) {
79
+ try {
80
+ if (jsonData && jsonData.failed) {
81
+ console.log("【YQCloud】:", jsonData.message);
82
+ } else {
83
+ const appConfig2 = JSON.parse(jsonData.jsonConfig);
84
+ setAppConfig(appConfig2);
85
+ console.log("【YQCloud】解析配置成功:", appConfig2);
86
+ }
87
+ } catch (e) {
88
+ console.log("【YQCloud】解析配置失败:", e, res);
89
+ }
90
+ });
91
+ }, [isVisible]);
92
+ const openModal = async (openFunction) => {
93
+ const secret = await import_axios.default.get("/iam/v1/zknow/encrypt/quick");
94
+ const authUrl = `${apiHost}/oauth/public/quick_authentication?token=${token}`;
95
+ const res2 = await import_axios.default.post(authUrl, {
96
+ secret
97
+ // code,
98
+ });
99
+ const modal = import_modal.default.open({
100
+ // title: '测试',
101
+ maskClosable: true,
102
+ bodyStyle: {
103
+ width: (openFunction == null ? void 0 : openFunction.viewSize) || 800,
104
+ padding: 0,
105
+ height: "100%",
106
+ overflow: "hidden"
107
+ },
108
+ style: {
109
+ // top: 50,
110
+ },
111
+ contentStyle: {
112
+ width: (openFunction == null ? void 0 : openFunction.viewSize) || 800,
113
+ height: "calc(100vh - 100px)"
114
+ },
115
+ header: null,
116
+ children: /* @__PURE__ */ import_react.default.createElement("iframe", { id: "yq-sdk-frame", style: { width: "100%", height: "100%" }, src: `${openFunction.link}&redirectFlag&access_token=${res2.accessToken}&token_type=bearer`, frameborder: "0" }),
117
+ footer: null
118
+ });
119
+ function closeModal(e) {
120
+ if (e.data === "yq_close_modal") {
121
+ modal.close();
122
+ window.removeEventListener("message", closeModal);
123
+ }
124
+ }
125
+ window.addEventListener("message", closeModal);
126
+ };
127
+ const menu = /* @__PURE__ */ import_react.default.createElement(import_menu.default, null, (_a = appConfig == null ? void 0 : appConfig.openFunctions) == null ? void 0 : _a.map((openFunction) => /* @__PURE__ */ import_react.default.createElement(import_menu.default.Item, { onClick: () => openModal(openFunction) }, /* @__PURE__ */ import_react.default.createElement("img", { style: { width: 18, height: 18, marginRight: 10 }, src: `${apiHost}/hfle/yqc/v1/0/files/download-by-key?fileKey=${openFunction.icon}`, alt: "" }), openFunction.displayName)));
128
+ return /* @__PURE__ */ import_react.default.createElement("div", { className: "yqcloud-hzero-jssdk", ref: eleRef }, ((_b = appConfig == null ? void 0 : appConfig.openFunctions) == null ? void 0 : _b.length) === 1 ? /* @__PURE__ */ import_react.default.createElement(import_button.default, { onClick: () => openModal(appConfig == null ? void 0 : appConfig.openFunctions[0]) }, (appConfig == null ? void 0 : appConfig.displayName) || (appConfig == null ? void 0 : appConfig.name)) : /* @__PURE__ */ import_react.default.createElement(import_popover.default, { overlayClassName: "yqcloud-hzero-jssdk-popover", overlayStyle: { padding: 0 }, openClassName: "yqcloud-hzero-jssdk-popover", content: menu, placement: "left" }, /* @__PURE__ */ import_react.default.createElement(import_button.default, { style: { padding: 0 } }, /* @__PURE__ */ import_react.default.createElement("img", { style: { width: 18, height: 18, marginRight: 10 }, src: `${apiHost}/hfle/yqc/v1/0/files/download-by-key?fileKey=${appConfig.icon}`, alt: "" }), entryDetail.entryName || (appConfig == null ? void 0 : appConfig.displayName) || (appConfig == null ? void 0 : appConfig.name))));
129
+ };
130
+ // Annotate the CommonJS export names for ESM import in node:
131
+ 0 && (module.exports = {});
package/lib/util.js ADDED
@@ -0,0 +1,31 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/util.ts
20
+ var util_exports = {};
21
+ __export(util_exports, {
22
+ sayHello: () => sayHello
23
+ });
24
+ module.exports = __toCommonJS(util_exports);
25
+ function sayHello() {
26
+ console.log("Hello World.");
27
+ }
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ sayHello
31
+ });
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "hzerojs-plugin-yqcloud-jssdk",
3
+ "version": "1.0.0",
4
+ "main": "lib/index.js",
5
+ "license": "MIT",
6
+ "scripts": {
7
+ "build": "npx father build"
8
+ },
9
+ "dependencies": {
10
+ "choerodon-ui": "^1.6.1-yqcloud-alpha.2",
11
+ "react": "^16.14.0"
12
+ },
13
+ "files": [
14
+ "lib",
15
+ "browsers"
16
+ ]
17
+ }