@tuya-sat/micro-dev-loader 0.0.1 → 0.0.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.
@@ -111,20 +111,28 @@ var LayoutMockPlugin = /*#__PURE__*/ function() {
111
111
  _htmlWebpackPlugin.default.getHooks(compilation).beforeEmit.tapAsync("LayoutMockPlugin", function(data, cb) {
112
112
  var $ = _cheerio.default.load(data.html);
113
113
  var name1 = manifest.name, defaultMenuIcon = manifest.defaultMenuIcon, entries = manifest.entries;
114
+ var nameProcesser = function(name) {
115
+ var ref = _slicedToArray(name.split("."), 2), _ = ref[0], key = ref[1];
116
+ return lang[key] || name;
117
+ };
114
118
  data.html = _ejs.default.render(layoutMockTpl, {
115
- appName: function() {
116
- var ref = _slicedToArray(name1.split("."), 2), _ = ref[0], key = ref[1];
117
- return lang[key] || name1;
118
- }(),
119
+ appName: nameProcesser(name1),
119
120
  appIcon: defaultMenuIcon.url,
120
- menus: entries.map(function(item) {
121
- var name = item.name;
122
- var ref = _slicedToArray(name.split("."), 2), _ = ref[0], key = ref[1];
123
- return _objectSpread({
124
- }, item, {
125
- langName: lang[key] || name
126
- });
127
- }),
121
+ menus: function() {
122
+ var processer = function(item) {
123
+ return _objectSpread({
124
+ }, item, {
125
+ langName: nameProcesser(item.name)
126
+ });
127
+ };
128
+ var entries$ = entries.length ? entries : [
129
+ {
130
+ name: name1,
131
+ path: "/"
132
+ },
133
+ ];
134
+ return entries$.map(processer);
135
+ }(),
128
136
  appHtml: [
129
137
  $("head").html(),
130
138
  $("body").html()
@@ -0,0 +1,180 @@
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><%= 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
+ }
86
+ .c-debugger-lang-trigger .c-debugger-lang-list span {
87
+ display: block;
88
+ padding: 5px 12px;
89
+ }
90
+ .c-debugger-lang-trigger .c-debugger-lang-list span:hover {
91
+ background-color: #f5f5f5;
92
+ }
93
+ .c-debugger-menu {
94
+ display: flex;
95
+ justify-content: flex-start;
96
+ align-items: center;
97
+ height: 40px;
98
+ padding: 0 0 0 17px;
99
+ margin: 4px 0 8px;
100
+ cursor: pointer;
101
+ font-size: 14px;
102
+ color: rgba(0, 0, 0, 0.85);
103
+ }
104
+ .c-debugger-menu-name {
105
+ margin-left: 10px;
106
+ }
107
+ .c-debugger-menu:hover {
108
+ color: #1890ff;
109
+ }
110
+ </style>
111
+ </head>
112
+ <body style="margin: 0; padding: 0">
113
+ <div class="c-debugger-container">
114
+ <div class="c-debugger-header">
115
+ <div class="c-debugger-logo">
116
+ <img
117
+ src="https://promotion-static.tuyacn.com/static/242969466160533504.png"
118
+ alt=""
119
+ style="height: 28px"
120
+ />
121
+ <div class="c-debugger-title"><%= appName %></div>
122
+ </div>
123
+
124
+ <div class="c-debugger-lang-trigger">
125
+ <span id="c-debugger-lang-name"></span>
126
+ <div class="c-debugger-lang-list">
127
+ <span onclick="changeLng('en-US')">English</span>
128
+ <span onclick="changeLng('zh-CN')">简体中文</span>
129
+ </div>
130
+ </div>
131
+ </div>
132
+ <div class="c-debugger-main">
133
+ <div class="c-debugger-side">
134
+ <% menus.forEach(function(menu){ %>
135
+ <div class="c-debugger-menu" onclick="toPage('<%= menu.path %>')">
136
+ <svg
137
+ viewBox="0 0 1024 1024"
138
+ version="1.1"
139
+ xmlns="http://www.w3.org/2000/svg"
140
+ p-id="2323"
141
+ width="14"
142
+ height="14"
143
+ >
144
+ <path
145
+ 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"
146
+ fill=""
147
+ p-id="2324"
148
+ ></path>
149
+ </svg>
150
+ <div class="c-debugger-menu-name"><%= menu.langName %></div>
151
+ </div>
152
+ <% }); %>
153
+ </div>
154
+ <div class="c-debugger-content"><%- appHtml %></div>
155
+ </div>
156
+ </div>
157
+ <script>
158
+ (() => {
159
+ const lngMap = {
160
+ "en-US": "English",
161
+ "zh-CN": "简体中文",
162
+ };
163
+ const localLng = localStorage.getItem("i18nextLng");
164
+ const lng = lngMap[localLng] ? localLng : "zh-CN";
165
+ console.log(lng);
166
+ document.querySelector("#c-debugger-lang-name").textContent =
167
+ lngMap[lng];
168
+ })();
169
+
170
+ function toPage(path) {
171
+ window.location.href = new URL(path, window.location.origin);
172
+ }
173
+
174
+ function changeLng(lng, name) {
175
+ localStorage.setItem("i18nextLng", lng);
176
+ location.reload();
177
+ }
178
+ </script>
179
+ </body>
180
+ </html>
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-dev-loader",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "scripts": {
7
7
  "dev": "swc src -D -w -d dist",
8
- "build": "swc src -d dist",
8
+ "build": "swc src -D -d dist",
9
9
  "prepublish": "yarn build",
10
10
  "test": "jest --verbose ./__tests__"
11
11
  },