@tuya-sat/micro-dev-loader 0.0.1-beta.3 → 0.0.4

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/.swcrc ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "jsc": {
3
+ "parser": {
4
+ "syntax": "typescript"
5
+ },
6
+ "target": "es2015"
7
+ },
8
+ "module": {
9
+ "type": "commonjs"
10
+ }
11
+ }
package/dist/index.js CHANGED
@@ -1,23 +1,36 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.LayoutMockPlugin = void 0;
7
- const loader_utils_1 = require("loader-utils");
8
- const transform_1 = __importDefault(require("./transform"));
9
- const parseManifest_1 = __importDefault(require("./utils/parseManifest"));
10
- const manifestDom_1 = __importDefault(require("./manifestDom"));
11
- const layoutMock_1 = __importDefault(require("./plugins/layoutMock"));
12
- exports.LayoutMockPlugin = layoutMock_1.default;
13
- const addjsLoader = function (sourceCode) {
14
- const { authedCode = [], microFramework } = (0, loader_utils_1.getOptions)(this);
15
- const { privileges } = (0, parseManifest_1.default)();
16
- const codeMaker = new transform_1.default({ sourceCode, microFramework });
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "LayoutMockPlugin", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _layoutMock.default;
9
+ }
10
+ });
11
+ exports.default = void 0;
12
+ var _loaderUtils = require("loader-utils");
13
+ var _transform = _interopRequireDefault(require("./transform"));
14
+ var _parseManifest = _interopRequireDefault(require("./utils/parseManifest"));
15
+ var _manifestDom = _interopRequireDefault(require("./manifestDom"));
16
+ var _layoutMock = _interopRequireDefault(require("./plugins/layoutMock"));
17
+ function _interopRequireDefault(obj) {
18
+ return obj && obj.__esModule ? obj : {
19
+ default: obj
20
+ };
21
+ }
22
+ var addjsLoader = function addjsLoader(sourceCode) {
23
+ var ref = (0, _loaderUtils).getOptions(this), _authedCode = ref.authedCode, authedCode = _authedCode === void 0 ? [] : _authedCode, microFramework = ref.microFramework;
24
+ var privileges = (0, _parseManifest).default().privileges;
25
+ var codeMaker = new _transform.default({
26
+ sourceCode: sourceCode,
27
+ microFramework: microFramework
28
+ });
17
29
  codeMaker.changeAst({
18
- privileges,
19
- authedCode,
30
+ privileges: privileges,
31
+ authedCode: authedCode
20
32
  });
21
- return codeMaker.gtAst() + manifestDom_1.default;
33
+ return codeMaker.gtAst() + _manifestDom.default;
22
34
  };
23
- exports.default = addjsLoader;
35
+ var _default = addjsLoader;
36
+ exports.default = _default;
@@ -1,11 +1,8 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const manifestDom = `
4
- (function ExternalRender() {
5
- const div = document.createElement('div');
6
- const { insertDom } = require("@tuya-sat/micro-dev-component");
7
- insertDom(div)
8
- document.body.appendChild(div);
9
- })();
10
- `;
11
- exports.default = manifestDom;
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.default = void 0;
6
+ var manifestDom = "\n(function ExternalRender() {\n const div = document.createElement('div');\n const { insertDom } = require(\"@tuya-sat/micro-dev-component\");\n insertDom(div)\n document.body.appendChild(div);\n})();\n";
7
+ var _default = manifestDom;
8
+ exports.default = _default;
@@ -1,46 +1,173 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_extra_1 = __importDefault(require("fs-extra"));
7
- const path_1 = __importDefault(require("path"));
8
- const ejs_1 = __importDefault(require("ejs"));
9
- const cheerio_1 = __importDefault(require("cheerio"));
10
- const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
11
- const parseManifest_1 = __importDefault(require("../../utils/parseManifest"));
12
- const manifest = (0, parseManifest_1.default)();
13
- const lang = fs_extra_1.default.readJSONSync(path_1.default.resolve(process.cwd(), "_locales/zh-CN.json"));
14
- const layoutMockTpl = fs_extra_1.default.readFileSync(path_1.default.resolve(__dirname, "./layout-static/index.html"), {
15
- encoding: "utf-8",
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
16
4
  });
17
- class LayoutMockPlugin {
18
- static useLayoutStatic(app) {
19
- app.get("/layout-static/*", function (req, res) {
20
- res.sendFile(path_1.default.join(__dirname, req.path));
5
+ exports.default = void 0;
6
+ var _fsExtra = _interopRequireDefault(require("fs-extra"));
7
+ var _path = _interopRequireDefault(require("path"));
8
+ var _ejs = _interopRequireDefault(require("ejs"));
9
+ var _cheerio = _interopRequireDefault(require("cheerio"));
10
+ var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
11
+ var _parseManifest = _interopRequireDefault(require("../../utils/parseManifest"));
12
+ function _arrayLikeToArray(arr, len) {
13
+ if (len == null || len > arr.length) len = arr.length;
14
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
15
+ return arr2;
16
+ }
17
+ function _arrayWithHoles(arr) {
18
+ if (Array.isArray(arr)) return arr;
19
+ }
20
+ function _classCallCheck(instance, Constructor) {
21
+ if (!(instance instanceof Constructor)) {
22
+ throw new TypeError("Cannot call a class as a function");
23
+ }
24
+ }
25
+ function _defineProperties(target, props) {
26
+ for(var i = 0; i < props.length; i++){
27
+ var descriptor = props[i];
28
+ descriptor.enumerable = descriptor.enumerable || false;
29
+ descriptor.configurable = true;
30
+ if ("value" in descriptor) descriptor.writable = true;
31
+ Object.defineProperty(target, descriptor.key, descriptor);
32
+ }
33
+ }
34
+ function _createClass(Constructor, protoProps, staticProps) {
35
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
36
+ if (staticProps) _defineProperties(Constructor, staticProps);
37
+ return Constructor;
38
+ }
39
+ function _defineProperty(obj, key, value) {
40
+ if (key in obj) {
41
+ Object.defineProperty(obj, key, {
42
+ value: value,
43
+ enumerable: true,
44
+ configurable: true,
45
+ writable: true
21
46
  });
47
+ } else {
48
+ obj[key] = value;
22
49
  }
23
- apply(compiler) {
24
- compiler.hooks.compilation.tap("MyPlugin", (compilation) => {
25
- html_webpack_plugin_1.default.getHooks(compilation).beforeEmit.tapAsync("LayoutMockPlugin", (data, cb) => {
26
- const $ = cheerio_1.default.load(data.html);
27
- const { name, defaultMenuIcon, entries } = manifest;
28
- data.html = ejs_1.default.render(layoutMockTpl, {
29
- appName: (() => {
30
- const [_, key] = name.split(".");
31
- return lang[key] || name;
32
- })(),
33
- appIcon: defaultMenuIcon.url,
34
- menus: entries.map((item) => {
35
- const { name } = item;
36
- const [_, key] = name.split(".");
37
- return Object.assign(Object.assign({}, item), { langName: lang[key] || name });
38
- }),
39
- appHtml: [$("head").html(), $("body").html()].join(""),
40
- });
41
- cb(null, data);
42
- });
50
+ return obj;
51
+ }
52
+ function _interopRequireDefault(obj) {
53
+ return obj && obj.__esModule ? obj : {
54
+ default: obj
55
+ };
56
+ }
57
+ function _iterableToArrayLimit(arr, i) {
58
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
59
+ if (_i == null) return;
60
+ var _arr = [];
61
+ var _n = true;
62
+ var _d = false;
63
+ var _s, _e;
64
+ try {
65
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
66
+ _arr.push(_s.value);
67
+ if (i && _arr.length === i) break;
68
+ }
69
+ } catch (err) {
70
+ _d = true;
71
+ _e = err;
72
+ } finally{
73
+ try {
74
+ if (!_n && _i["return"] != null) _i["return"]();
75
+ } finally{
76
+ if (_d) throw _e;
77
+ }
78
+ }
79
+ return _arr;
80
+ }
81
+ function _nonIterableRest() {
82
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
83
+ }
84
+ function _objectSpread(target) {
85
+ for(var i = 1; i < arguments.length; i++){
86
+ var source = arguments[i] != null ? arguments[i] : {
87
+ };
88
+ var ownKeys = Object.keys(source);
89
+ if (typeof Object.getOwnPropertySymbols === "function") {
90
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
91
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
92
+ }));
93
+ }
94
+ ownKeys.forEach(function(key) {
95
+ _defineProperty(target, key, source[key]);
43
96
  });
44
97
  }
98
+ return target;
99
+ }
100
+ function _slicedToArray(arr, i) {
101
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
102
+ }
103
+ function _unsupportedIterableToArray(o, minLen) {
104
+ if (!o) return;
105
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
106
+ var n = Object.prototype.toString.call(o).slice(8, -1);
107
+ if (n === "Object" && o.constructor) n = o.constructor.name;
108
+ if (n === "Map" || n === "Set") return Array.from(n);
109
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
45
110
  }
111
+ var manifest = (0, _parseManifest).default();
112
+ var lang = _fsExtra.default.readJSONSync(_path.default.resolve(process.cwd(), "_locales/zh-CN.json"));
113
+ var layoutMockTpl = _fsExtra.default.readFileSync(_path.default.resolve(__dirname, "./layout-static/index.html"), {
114
+ encoding: "utf-8"
115
+ });
116
+ var LayoutMockPlugin = /*#__PURE__*/ function() {
117
+ "use strict";
118
+ function LayoutMockPlugin() {
119
+ _classCallCheck(this, LayoutMockPlugin);
120
+ }
121
+ _createClass(LayoutMockPlugin, [
122
+ {
123
+ key: "apply",
124
+ value: function apply(compiler) {
125
+ compiler.hooks.compilation.tap("MyPlugin", function(compilation) {
126
+ _htmlWebpackPlugin.default.getHooks(compilation).beforeEmit.tapAsync("LayoutMockPlugin", function(data, cb) {
127
+ var $ = _cheerio.default.load(data.html);
128
+ var name1 = manifest.name, defaultMenuIcon = manifest.defaultMenuIcon, entries = manifest.entries;
129
+ var nameProcesser = function(name) {
130
+ var ref = _slicedToArray(name.split("."), 2), _ = ref[0], key = ref[1];
131
+ return lang[key] || name;
132
+ };
133
+ data.html = _ejs.default.render(layoutMockTpl, {
134
+ appName: nameProcesser(name1),
135
+ appIcon: defaultMenuIcon.url,
136
+ menus: function() {
137
+ var processer = function(item) {
138
+ return _objectSpread({
139
+ }, item, {
140
+ langName: nameProcesser(item.name)
141
+ });
142
+ };
143
+ var entries$ = entries.length ? entries : [
144
+ {
145
+ name: name1,
146
+ path: "/"
147
+ },
148
+ ];
149
+ return entries$.map(processer);
150
+ }(),
151
+ appHtml: [
152
+ $("head").html(),
153
+ $("body").html()
154
+ ].join("")
155
+ });
156
+ cb(null, data);
157
+ });
158
+ });
159
+ }
160
+ }
161
+ ], [
162
+ {
163
+ key: "useLayoutStatic",
164
+ value: function useLayoutStatic(app) {
165
+ app.get("/layout-static/*", function(req, res) {
166
+ res.sendFile(_path.default.join(__dirname, req.path));
167
+ });
168
+ }
169
+ }
170
+ ]);
171
+ return LayoutMockPlugin;
172
+ }();
46
173
  exports.default = LayoutMockPlugin;
@@ -1,187 +1,181 @@
1
1
  <!DOCTYPE html>
2
- <html lang="en" style="margin: 0; padding: 0;">
3
- <head>
4
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
5
- <meta charset="utf-8">
6
- <link rel="icon" href="favicon.ico">
7
- <meta name="viewport" content="width=device-width,initial-scale=1">
8
- <meta name="theme-color" content="#000000">
9
- <meta name="description" content="Tuya General Management Portal">
10
- <title>IoT SaaS App</title>
11
- <link href="/layout-static/2.c7981cdc.chunk.css" rel="stylesheet">
12
- <link href="/layout-static/main.efdba179.chunk.css" rel="stylesheet">
13
- </head>
14
- <body style="margin: 0; padding: 0;">
2
+ <html lang="en" style="margin: 0; padding: 0">
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
5
+ <meta charset="utf-8" />
6
+ <link rel="icon" href="favicon.ico" />
7
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
8
+ <meta name="theme-color" content="#000000" />
9
+ <meta name="description" content="Tuya General Management Portal" />
10
+ <title><%= appName %></title>
11
+ <style>
12
+ .c-debugger-container {
13
+ width: 100vw;
14
+ height: 100vh;
15
+ display: flex;
16
+ flex-direction: column;
17
+ }
18
+ .c-debugger-header {
19
+ flex: 0 0 auto;
20
+ display: flex;
21
+ align-items: center;
22
+ justify-content: space-between;
23
+ height: 55px;
24
+ padding: 0 16px;
25
+ border-bottom: 1px solid #eee;
26
+ color: rgba(0, 0, 0, 0.85);
27
+ }
28
+ .c-debugger-logo {
29
+ position: relative;
30
+ overflow: hidden;
31
+ display: flex;
32
+ align-items: center;
33
+ }
34
+ .c-debugger-title {
35
+ color: #000;
36
+ font-size: 14px;
37
+ font-weight: 700;
38
+ height: 32px;
39
+ line-height: 32px;
40
+ margin: 0 0 0 12px;
41
+ }
42
+ .c-debugger-main {
43
+ display: flex;
44
+ flex: 1 1 auto;
45
+ }
46
+ .c-debugger-side {
47
+ flex: 0 0 auto;
48
+ width: 208px;
49
+ height: 100%;
50
+ border-right: 1px solid #f0f2f5;
51
+ }
52
+ .c-debugger-content {
53
+ flex: 1 1 auto;
54
+ height: 100%;
55
+ background-color: #f0f2f5;
56
+ }
57
+ #root {
58
+ width: 100%;
59
+ height: 100%;
60
+ }
61
+ .c-debugger-lang-trigger {
62
+ position: relative;
63
+ display: flex;
64
+ align-items: center;
65
+ white-space: nowrap;
66
+ cursor: pointer;
67
+ font-size: 14px;
68
+ font-weight: normal;
69
+ height: 100%;
70
+ }
71
+ .c-debugger-lang-trigger:hover .c-debugger-lang-list {
72
+ display: block;
73
+ line-height: 1.5;
74
+ }
75
+ .c-debugger-lang-trigger .c-debugger-lang-list {
76
+ position: absolute;
77
+ top: 42px;
78
+ right: -5px;
79
+ display: none;
80
+ background: #ffffff;
81
+ border-radius: 2px;
82
+ outline: none;
83
+ box-shadow: 0 3px 6px -4px rgb(0 0 0 / 12%),
84
+ 0 6px 16px 0 rgb(0 0 0 / 8%), 0 9px 28px 8px rgb(0 0 0 / 5%);
85
+ z-index: 100;
86
+ }
87
+ .c-debugger-lang-trigger .c-debugger-lang-list span {
88
+ display: block;
89
+ padding: 5px 12px;
90
+ }
91
+ .c-debugger-lang-trigger .c-debugger-lang-list span:hover {
92
+ background-color: #f5f5f5;
93
+ }
94
+ .c-debugger-menu {
95
+ display: flex;
96
+ justify-content: flex-start;
97
+ align-items: center;
98
+ height: 40px;
99
+ padding: 0 0 0 17px;
100
+ margin: 4px 0 8px;
101
+ cursor: pointer;
102
+ font-size: 14px;
103
+ color: rgba(0, 0, 0, 0.85);
104
+ }
105
+ .c-debugger-menu-name {
106
+ margin-left: 10px;
107
+ }
108
+ .c-debugger-menu:hover {
109
+ color: #1890ff;
110
+ }
111
+ </style>
112
+ </head>
113
+ <body style="margin: 0; padding: 0">
114
+ <div class="c-debugger-container">
115
+ <div class="c-debugger-header">
116
+ <div class="c-debugger-logo">
117
+ <img
118
+ src="https://promotion-static.tuyacn.com/static/242969466160533504.png"
119
+ alt=""
120
+ style="height: 28px"
121
+ />
122
+ <div class="c-debugger-title"><%= appName %></div>
123
+ </div>
15
124
 
16
- <div id="mock-root">
17
- <div>
18
- <div class="pro-layout-master ant-design-pro ant-pro-basicLayout screen-xl ant-pro-basicLayout-fix-siderbar ant-pro-basicLayout-mix">
19
- <section class="ant-layout ant-layout-has-sider" style="min-height: 100%;">
20
- <div id="J_sider-slot" style="width: 208px; overflow: hidden; flex: 0 0 208px; max-width: 208px; min-width: 208px; transition: background-color 0.3s ease 0s, min-width 0.3s ease 0s, max-width 0.3s cubic-bezier(0.645, 0.045, 0.355, 1) 0s;"></div>
21
- <aside
22
- id="J_sider"
23
- class="ant-layout-sider ant-layout-sider-light ant-pro-sider ant-pro-sider-fixed ant-pro-sider-layout-mix ant-pro-sider-light"
24
- style="overflow: hidden; padding-top: 48px; flex: 0 0 208px; max-width: 208px; min-width: 208px; width: 208px;"
25
- >
26
- <div class="ant-layout-sider-children">
27
- <div style="flex: 1 1 0%; overflow: hidden auto;">
28
- <% if (menus.length>0) { %>
29
- <ul class="ant-menu ant-menu-light ant-pro-sider-menu ant-menu-root ant-menu-inline" role="menu" style="width: 100%;">
30
- <li class="ant-menu-submenu ant-menu-submenu-inline ant-menu-submenu-open" role="menuitem">
31
- <div class="ant-menu-submenu-title" role="button" aria-expanded="true" aria-haspopup="true" aria-owns="/apps/1440611125199634515$Menu" style="padding-left: 16px;">
32
- <span class="ant-pro-menu-item" title="工单管理">
33
- <span class="ant-menu-item-icon">
34
- <img src="<%= appIcon %>" alt="" style="width: 16px; height: 16px; margin-top: -2px; margin-right: 10px;">
35
- </span>
36
- <span class="ant-pro-menu-item-title"><%= appName %></span>
37
- </span>
38
- <i class="ant-menu-submenu-arrow"></i>
39
- </div>
40
- <ul id="/apps/1440611125199634515$Menu" class="ant-menu ant-menu-sub ant-menu-inline" role="menu" style="">
41
- <% menus.forEach(function(menu){%>
42
- <li class="ant-menu-item ant-menu-item-only-child" role="menuitem" style="padding-left: 32px;">
43
- <a onclick="toPage('<%=menu.path %>')" style="height: 40px;">
44
- <span class="ant-pro-menu-item">
45
- <span class="ant-pro-menu-item-title"><%=menu.langName %></span>
46
- </span>
47
- </a>
48
- </li>
49
- <% }) %>
50
- </ul>
51
- </li>
52
- </ul>
53
- <%} else { %>
54
- <ul style="width: 100%;" class="ant-menu ant-menu-light ant-pro-sider-menu ant-menu-root ant-menu-inline" role="menu">
55
- <li class="ant-menu-item ant-menu-item-only-child" role="menuitem" style="padding-left: 16px;">
56
- <a style="height: 40px;" href="/">
57
- <span class="ant-pro-menu-item">
58
- <span class="ant-menu-item-icon">
59
- <img src="<%= appIcon %>" alt='' style="width: 16px; height: 16px; margin-top: -2px; margin-right: 10px;">
60
- </span>
61
- <span class="ant-pro-menu-item-title"><%= appName %></span>
62
- </span>
63
- </a>
64
- </li>
65
- </ul>
66
- <% } %>
67
- </div>
68
- <div class="ant-pro-sider-links">
69
- <ul class="ant-menu ant-menu-light ant-pro-sider-link-menu ant-menu-root ant-menu-inline" role="menu">
70
- <li
71
- id="J_sider-trigger"
72
- class="ant-menu-item ant-menu-item-only-child ant-pro-sider-collapsed-button"
73
- role="menuitem"
74
- style="padding-left: 16px;"
75
- >
76
- <span role="img" aria-label="menu-fold" class="anticon anticon-menu-fold">
77
- <svg viewBox="64 64 896 896" focusable="false" data-icon="menu-fold" width="1em" height="1em" fill="currentColor" aria-hidden="true">
78
- <path
79
- d="M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM115.4 518.9L271.7 642c5.8 4.6 14.4.5 14.4-6.9V388.9c0-7.4-8.5-11.5-14.4-6.9L115.4 505.1a8.74 8.74 0 000 13.8z"></path>
80
- </svg>
81
- </span>
82
- </li>
83
- </ul>
84
- </div>
125
+ <div class="c-debugger-lang-trigger">
126
+ <span id="c-debugger-lang-name"></span>
127
+ <div class="c-debugger-lang-list">
128
+ <span onclick="changeLng('en-US')">English</span>
129
+ <span onclick="changeLng('zh-CN')">简体中文</span>
85
130
  </div>
86
- </aside>
87
-
88
- <div style="position: relative;" class="ant-layout">
89
- <header class="ant-layout-header" style="height: 48px;"></header>
90
- <header class="ant-layout-header ant-pro-fixed-header ant-pro-fixed-header-action" style="padding: 0px; height: 48px; line-height: 48px; width: 100%; z-index: 100; right: 0px;">
91
- <div class="ant-pro-global-header">
92
- <div class="ant-pro-global-header-logo" style="flex: 1;">
93
- <a>
94
- <img src="https://images.tuyacn.com/rms-static/3bb090e0-d7e2-11eb-815d-e39234ce96ff-1624865222894.png" alt='' style="height: 28px;">
95
- <h1>IoT SaaS App Demo</h1>
96
- </a>
97
- </div>
98
- <style>
99
- .lang-trigger {
100
- position: relative;
101
- white-space: nowrap;
102
- cursor: pointer;
103
- }
104
- .lang-trigger:hover .lang-list {
105
- display: block;
106
- line-height: 1.5;
107
- }
108
- .lang-trigger .lang-list {
109
- position: absolute;
110
- top: 40px;
111
- right: 0;
112
- display: none;
113
- background: #ffffff;
114
- border-radius: 2px;
115
- outline: none;
116
- box-shadow: 0 3px 6px -4px rgb(0 0 0 / 12%), 0 6px 16px 0 rgb(0 0 0 / 8%), 0 9px 28px 8px rgb(0 0 0 / 5%);
117
- }
118
- .lang-trigger .lang-list span {
119
- display: block;
120
- padding: 5px 12px;
121
- }
122
- .lang-trigger .lang-list span:hover {
123
- background-color: #f5f5f5;
124
- }
125
- </style>
126
- <span class="lang-trigger">
127
- <span id="J_lng-name"></span>
128
- <div class="lang-list">
129
- <span onclick="changeLng('en-US')">English</span>
130
- <span onclick="changeLng('zh-CN')">简体中文</span>
131
- </div>
132
- </span>
133
- <script>
134
- ;(() => {
135
- const lngMap = {
136
- 'en-US': 'English',
137
- 'zh-CN': '简体中文',
138
- };
139
- const lng = localStorage.getItem('i18nextLng') || 'zh-CN';
140
- document.querySelector('#J_lng-name').innerHTML = lngMap[lng];
141
- })();
142
-
143
- function changeLng(lng, name) {
144
- localStorage.setItem('i18nextLng', lng);
145
- location.reload();
146
- }
147
- function toPage(path){
148
- mhistory && mhistory.push(path);
149
- }
150
- </script>
151
- </div>
152
- </header>
153
- <main
154
- class="ant-layout-content ant-pro-basicLayout-content ant-pro-basicLayout-has-header"
155
- style="margin: 0;"
156
- >
157
- <div id="container" style="height: calc(-56px + 100vh);"><div id="__qiankun_microapp_wrapper_for_demo" style="height: 100%">
158
-
159
- <%- appHtml %>
160
-
161
- </div></div>
162
- </main>
163
131
  </div>
164
- </section>
132
+ </div>
133
+ <div class="c-debugger-main">
134
+ <div class="c-debugger-side">
135
+ <% menus.forEach(function(menu){ %>
136
+ <div class="c-debugger-menu" onclick="toPage('<%= menu.path %>')">
137
+ <svg
138
+ viewBox="0 0 1024 1024"
139
+ version="1.1"
140
+ xmlns="http://www.w3.org/2000/svg"
141
+ p-id="2323"
142
+ width="14"
143
+ height="14"
144
+ >
145
+ <path
146
+ d="M192.037 287.953h640.124c17.673 0 32-14.327 32-32s-14.327-32-32-32H192.037c-17.673 0-32 14.327-32 32s14.327 32 32 32zM192.028 543.17h638.608c17.673 0 32-14.327 32-32s-14.327-32-32-32H192.028c-17.673 0-32 14.327-32 32s14.327 32 32 32zM832.161 735.802H192.037c-17.673 0-32 14.327-32 32s14.327 32 32 32h640.124c17.673 0 32-14.327 32-32s-14.327-32-32-32z"
147
+ fill=""
148
+ p-id="2324"
149
+ ></path>
150
+ </svg>
151
+ <div class="c-debugger-menu-name"><%= menu.langName %></div>
152
+ </div>
153
+ <% }); %>
154
+ </div>
155
+ <div class="c-debugger-content"><%- appHtml %></div>
156
+ </div>
165
157
  </div>
166
- </div>
167
- </div>
168
- <script>
169
- ;(function() {
170
- const $$ = document.querySelector.bind(document);
171
- const $sider = $$('#J_sider');
172
- const $siderSlot = $$('#J_sider-slot');
173
- const $siderTrigger = $$('#J_sider-trigger');
174
- let unfold = true;
158
+ <script>
159
+ (() => {
160
+ const lngMap = {
161
+ "en-US": "English",
162
+ "zh-CN": "简体中文",
163
+ };
164
+ const localLng = localStorage.getItem("i18nextLng");
165
+ const lng = lngMap[localLng] ? localLng : "zh-CN";
166
+ console.log(lng);
167
+ document.querySelector("#c-debugger-lang-name").textContent =
168
+ lngMap[lng];
169
+ })();
170
+
171
+ function toPage(path) {
172
+ window.location.href = new URL(path, window.location.origin);
173
+ }
175
174
 
176
- $siderTrigger.addEventListener('click', () => {
177
- ['width', 'max-width', 'min-width'].forEach((name) => {
178
- const width = `${unfold ? 208 : 48}px`;
179
- $sider.style[name] = width;
180
- $siderSlot.style[name] = width;
181
- });
182
- unfold = !unfold;
183
- });
184
- }());
185
- </script>
186
- </body>
175
+ function changeLng(lng, name) {
176
+ localStorage.setItem("i18nextLng", lng);
177
+ location.reload();
178
+ }
179
+ </script>
180
+ </body>
187
181
  </html>