@lazycatcloud/lzc-cli 1.1.8 → 1.1.9

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 (105) hide show
  1. package/README.md +69 -11
  2. package/lib/api.js +71 -39
  3. package/lib/app/index.js +76 -21
  4. package/lib/app/lpk_build.js +95 -63
  5. package/lib/app/lpk_create.js +63 -41
  6. package/lib/app/lpk_create_generator.js +202 -0
  7. package/lib/app/lpk_devshell.js +393 -328
  8. package/lib/app/lpk_devshell_docker.js +211 -0
  9. package/lib/app/lpk_installer.js +63 -26
  10. package/lib/app/lpk_log.js +68 -0
  11. package/lib/app/lpk_status.js +18 -0
  12. package/lib/app/lpk_uninstall.js +19 -0
  13. package/lib/appstore/index.js +37 -0
  14. package/lib/appstore/login.js +96 -93
  15. package/lib/appstore/publish.js +62 -0
  16. package/lib/autologin.js +0 -78
  17. package/lib/box/api/clientapi.js +1322 -0
  18. package/lib/box/api/empty.js +35 -0
  19. package/lib/box/check_qemu.js +1 -0
  20. package/lib/box/index.js +41 -94
  21. package/lib/box/qemu_vm_mgr.js +208 -239
  22. package/lib/box/schemes/vm_box_system_debian.json +1 -1
  23. package/lib/docker-compose.js +1 -2
  24. package/lib/env.js +19 -101
  25. package/lib/key.js +1 -0
  26. package/lib/sdk.js +10 -25
  27. package/lib/utils.js +156 -132
  28. package/package.json +19 -10
  29. package/scripts/cli.js +14 -135
  30. package/template/_lpk/README.md +31 -0
  31. package/template/_lpk/exec.sh +19 -0
  32. package/template/_lpk/golang.manifest.yml.in +16 -0
  33. package/template/_lpk/lazycat.png +0 -0
  34. package/template/_lpk/lite.manifest.yml.in +19 -0
  35. package/template/_lpk/local_devshell/Dockerfile +16 -0
  36. package/template/_lpk/local_devshell/build.sh +5 -0
  37. package/template/_lpk/local_devshell/entrypoint.sh +87 -0
  38. package/template/{_lazycat/debug/shell → _lpk/local_devshell}/sshd_config +8 -8
  39. package/template/_lpk/manifest.yml.in +0 -1
  40. package/template/{vue/lzc-build.yml → _lpk/vue.lzc-build.yml.in} +9 -1
  41. package/template/golang/README.md +0 -2
  42. package/template/golang/_gitignore +2 -0
  43. package/template/golang/build.sh +6 -0
  44. package/template/golang/lazycat.png +0 -0
  45. package/template/golang/lzc-build.yml +9 -1
  46. package/template/golang/rego.go +15 -16
  47. package/template/golang/rego_test.go +13 -0
  48. package/template/ionic_vue3/lazycat.png +0 -0
  49. package/template/ionic_vue3/lzc-build.yml +9 -1
  50. package/template/lite/error_pages/502.html.tpl +13 -0
  51. package/template/lite/lazycat.png +0 -0
  52. package/template/lite/lzc-build.yml +60 -0
  53. package/cmds/app.js +0 -133
  54. package/cmds/config.js +0 -55
  55. package/cmds/create.js +0 -55
  56. package/cmds/dev.js +0 -130
  57. package/cmds/init.js +0 -125
  58. package/cmds/log.js +0 -103
  59. package/cmds/publish.js +0 -116
  60. package/lib/archiver.js +0 -105
  61. package/lib/box/hportal.js +0 -120
  62. package/lib/builder.js +0 -313
  63. package/lib/dev.js +0 -314
  64. package/lib/generator.js +0 -146
  65. package/template/_lazycat/_gitignore +0 -1
  66. package/template/_lazycat/app-config +0 -1
  67. package/template/_lazycat/debug/devforward/50x.html +0 -30
  68. package/template/_lazycat/debug/devforward/Dockerfile +0 -16
  69. package/template/_lazycat/debug/devforward/docker-compose.override.yml.in +0 -11
  70. package/template/_lazycat/debug/devforward/entrypoint.sh +0 -10
  71. package/template/_lazycat/debug/devforward/nginx.conf.template +0 -56
  72. package/template/_lazycat/debug/devforward/sshd_config +0 -116
  73. package/template/_lazycat/debug/shell/50x.html +0 -32
  74. package/template/_lazycat/debug/shell/Dockerfile +0 -18
  75. package/template/_lazycat/debug/shell/build.sh +0 -15
  76. package/template/_lazycat/debug/shell/docker-compose.override.yml.in +0 -13
  77. package/template/_lazycat/debug/shell/entrypoint.sh +0 -12
  78. package/template/_lazycat/docker-compose.yml.in +0 -15
  79. package/template/_lazycat/icon.svg +0 -1
  80. package/template/_lazycat/screenshot.png +0 -0
  81. package/template/_lpk/sync/Dockerfile +0 -16
  82. package/template/_lpk/sync/build.sh +0 -5
  83. package/template/_lpk/sync/entrypoint.sh +0 -8
  84. package/template/_lpk/sync/sshd_config +0 -117
  85. package/template/_lpk/sync.manifest.yml.in +0 -3
  86. package/template/release/golang/Dockerfile +0 -18
  87. package/template/release/golang/build.sh +0 -13
  88. package/template/release/ionic_vue3/Dockerfile +0 -10
  89. package/template/release/ionic_vue3/build.sh +0 -7
  90. package/template/release/ionic_vue3/docker-compose.yml.in +0 -3
  91. package/template/release/vue/Dockerfile +0 -10
  92. package/template/release/vue/build.sh +0 -10
  93. package/template/release/vue/docker-compose.yml.in +0 -3
  94. package/template/vue/README.md +0 -29
  95. package/template/vue/_dockerignore +0 -1
  96. package/template/vue/babel.config.js +0 -3
  97. package/template/vue/package.json +0 -43
  98. package/template/vue/public/favicon.ico +0 -0
  99. package/template/vue/public/index.html +0 -33
  100. package/template/vue/src/App.vue +0 -39
  101. package/template/vue/src/main.js +0 -8
  102. package/template/vue/src/todo.vue +0 -640
  103. package/template/vue/src/top-bar.vue +0 -100
  104. package/template/vue/src/webdav.vue +0 -183
  105. package/template/vue/vue.config.js +0 -21
@@ -1,640 +0,0 @@
1
- <template>
2
- <div>
3
- <section class="todoapp">
4
- <header class="header">
5
- <h1>todos</h1>
6
- <input
7
- class="new-todo"
8
- autofocus
9
- autocomplete="off"
10
- placeholder="What needs to be done?"
11
- v-model="newTodo"
12
- @keyup.enter="addTodo"
13
- />
14
- </header>
15
- <section class="main" v-show="todos.length" v-cloak>
16
- <input
17
- id="toggle-all"
18
- class="toggle-all"
19
- type="checkbox"
20
- v-model="allDone"
21
- />
22
- <label for="toggle-all"></label>
23
- <ul class="todo-list">
24
- <li
25
- v-for="todo in filteredTodos"
26
- class="todo"
27
- :key="todo.id"
28
- :class="{ completed: todo.completed, editing: todo == editedTodo }"
29
- >
30
- <div class="view">
31
- <input class="toggle" type="checkbox" v-model="todo.completed" />
32
- <label @dblclick="editTodo(todo)">{{ todo.title }}</label>
33
- <button class="destroy" @click="removeTodo(todo)"></button>
34
- </div>
35
- <input
36
- class="edit"
37
- type="text"
38
- v-model="todo.title"
39
- v-todo-focus="todo == editedTodo"
40
- @blur="doneEdit(todo)"
41
- @keyup.enter="doneEdit(todo)"
42
- @keyup.esc="cancelEdit(todo)"
43
- />
44
- </li>
45
- </ul>
46
- </section>
47
- <footer class="footer" v-show="todos.length" v-cloak>
48
- <span class="todo-count">
49
- <strong>{{ remaining }}</strong> {{ remaining | pluralize }} left
50
- </span>
51
- <ul class="filters">
52
- <li>
53
- <a href="#/all" :class="{ selected: visibility == 'all' }">All</a>
54
- </li>
55
- <li>
56
- <a href="#/active" :class="{ selected: visibility == 'active' }"
57
- >Active</a
58
- >
59
- </li>
60
- <li>
61
- <a
62
- href="#/completed"
63
- :class="{ selected: visibility == 'completed' }"
64
- >Completed</a
65
- >
66
- </li>
67
- </ul>
68
- <button
69
- class="clear-completed"
70
- @click="removeCompleted"
71
- v-show="todos.length > remaining"
72
- >
73
- Clear completed
74
- </button>
75
- </footer>
76
- </section>
77
- <footer class="info">
78
- <p>Double-click to edit a todo</p>
79
- </footer>
80
-
81
- <div class="error" v-if="error">
82
- {{ error }}
83
- </div>
84
- </div>
85
- </template>
86
-
87
- <script>
88
- var STORAGE_KEY = "/todos";
89
- var todoStorage = {
90
- fetch: async function (lzc) {
91
- let todos;
92
-
93
- if (!lzc.isLogged()) {
94
- throw "Please login";
95
- }
96
-
97
- if ((await lzc.fs.exists(STORAGE_KEY)) === false) {
98
- return [];
99
- } else {
100
- let content = await lzc.fs.getFileContents(STORAGE_KEY, {
101
- format: "text",
102
- });
103
-
104
- todos = JSON.parse(content);
105
- }
106
-
107
- todos.forEach(function (todo, index) {
108
- todo.id = index;
109
- });
110
- todoStorage.uid = todos.length;
111
- return todos;
112
- },
113
-
114
- save: function (lzc, todos) {
115
- let content = JSON.stringify(todos);
116
- if (lzc.isLogged()) {
117
- lzc.fs
118
- .putFileContents(STORAGE_KEY, content, {
119
- overwrite: true,
120
- contentLength: true,
121
- })
122
- .catch((e) => {
123
- console.error(e);
124
- });
125
- }
126
- },
127
- };
128
-
129
- // visibility filters
130
- var filters = {
131
- all: function (todos) {
132
- return todos;
133
- },
134
- active: function (todos) {
135
- return todos.filter(function (todo) {
136
- return !todo.completed;
137
- });
138
- },
139
- completed: function (todos) {
140
- return todos.filter(function (todo) {
141
- return todo.completed;
142
- });
143
- },
144
- };
145
-
146
- // app Vue instance
147
- export default {
148
- // app initial state
149
- data: function () {
150
- return {
151
- todos: [],
152
- newTodo: "",
153
- editedTodo: null,
154
- visibility: "all",
155
- error: "",
156
- };
157
- },
158
-
159
- // watch todos change for localStorage persistence
160
- watch: {
161
- todos: {
162
- handler: function (todos) {
163
- todoStorage.save(this.$lzc, todos);
164
- },
165
- deep: true,
166
- },
167
- },
168
-
169
- async mounted() {
170
- try {
171
- this.todos = await todoStorage.fetch(this.$lzc);
172
- } catch (e) {
173
- this.error = e;
174
- console.error(e);
175
- }
176
-
177
- const that = this;
178
- function onHashChange() {
179
- var visibility = window.location.hash.replace(/#\/?/, "");
180
- if (filters[visibility]) {
181
- that.visibility = visibility;
182
- } else {
183
- window.location.hash = "";
184
- that.visibility = "all";
185
- }
186
- }
187
-
188
- window.addEventListener("hashchange", onHashChange);
189
- onHashChange();
190
- },
191
-
192
- // computed properties
193
- // http://vuejs.org/guide/computed.html
194
- computed: {
195
- filteredTodos: function () {
196
- return filters[this.visibility](this.todos);
197
- },
198
- remaining: function () {
199
- return filters.active(this.todos).length;
200
- },
201
- allDone: {
202
- get: function () {
203
- return this.remaining === 0;
204
- },
205
- set: function (value) {
206
- this.todos.forEach(function (todo) {
207
- todo.completed = value;
208
- });
209
- },
210
- },
211
- },
212
-
213
- filters: {
214
- pluralize: function (n) {
215
- return n === 1 ? "item" : "items";
216
- },
217
- },
218
-
219
- // methods that implement data logic.
220
- // note there's no DOM manipulation here at all.
221
- methods: {
222
- addTodo: function () {
223
- var value = this.newTodo && this.newTodo.trim();
224
- if (!value) {
225
- return;
226
- }
227
- this.todos.push({
228
- id: todoStorage.uid++,
229
- title: value,
230
- completed: false,
231
- });
232
- this.newTodo = "";
233
- },
234
-
235
- removeTodo: function (todo) {
236
- this.todos.splice(this.todos.indexOf(todo), 1);
237
- },
238
-
239
- editTodo: function (todo) {
240
- this.beforeEditCache = todo.title;
241
- this.editedTodo = todo;
242
- },
243
-
244
- doneEdit: function (todo) {
245
- if (!this.editedTodo) {
246
- return;
247
- }
248
- this.editedTodo = null;
249
- todo.title = todo.title.trim();
250
- if (!todo.title) {
251
- this.removeTodo(todo);
252
- }
253
- },
254
-
255
- cancelEdit: function (todo) {
256
- this.editedTodo = null;
257
- todo.title = this.beforeEditCache;
258
- },
259
-
260
- removeCompleted: function () {
261
- this.todos = filters.active(this.todos);
262
- },
263
- },
264
-
265
- // a custom directive to wait for the DOM to be updated
266
- // before focusing on the input field.
267
- // http://vuejs.org/guide/custom-directive.html
268
- directives: {
269
- "todo-focus": function (el, binding) {
270
- if (binding.value) {
271
- el.focus();
272
- }
273
- },
274
- },
275
- };
276
- </script>
277
-
278
- <style scoped>
279
- .error {
280
- color: #da4453;
281
- }
282
-
283
- button {
284
- margin: 0;
285
- padding: 0;
286
- border: 0;
287
- background: none;
288
- font-size: 100%;
289
- vertical-align: baseline;
290
- font-family: inherit;
291
- font-weight: inherit;
292
- color: inherit;
293
- -webkit-appearance: none;
294
- appearance: none;
295
- -webkit-font-smoothing: antialiased;
296
- -moz-osx-font-smoothing: grayscale;
297
- }
298
-
299
- :focus {
300
- outline: 0;
301
- }
302
-
303
- .hidden {
304
- display: none;
305
- }
306
-
307
- .todoapp {
308
- background: #fff;
309
- margin: 130px 0 40px 0;
310
- position: relative;
311
- box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1);
312
- }
313
-
314
- .todoapp input::-webkit-input-placeholder {
315
- font-style: italic;
316
- font-weight: 300;
317
- color: #e6e6e6;
318
- }
319
-
320
- .todoapp input::-moz-placeholder {
321
- font-style: italic;
322
- font-weight: 300;
323
- color: #e6e6e6;
324
- }
325
-
326
- .todoapp input::input-placeholder {
327
- font-style: italic;
328
- font-weight: 300;
329
- color: #e6e6e6;
330
- }
331
-
332
- .todoapp h1 {
333
- position: absolute;
334
- top: -155px;
335
- width: 100%;
336
- font-size: 100px;
337
- font-weight: 100;
338
- text-align: center;
339
- color: rgba(175, 47, 47, 0.15);
340
- -webkit-text-rendering: optimizeLegibility;
341
- -moz-text-rendering: optimizeLegibility;
342
- text-rendering: optimizeLegibility;
343
- }
344
-
345
- .new-todo,
346
- .edit {
347
- position: relative;
348
- margin: 0;
349
- width: 100%;
350
- font-size: 24px;
351
- font-family: inherit;
352
- font-weight: inherit;
353
- line-height: 1.4em;
354
- border: 0;
355
- color: inherit;
356
- padding: 6px;
357
- border: 1px solid #999;
358
- box-shadow: inset 0 -1px 5px 0 rgba(0, 0, 0, 0.2);
359
- box-sizing: border-box;
360
- -webkit-font-smoothing: antialiased;
361
- -moz-osx-font-smoothing: grayscale;
362
- }
363
-
364
- .new-todo {
365
- padding: 16px 16px 16px 60px;
366
- border: none;
367
- background: rgba(0, 0, 0, 0.003);
368
- box-shadow: inset 0 -2px 1px rgba(0, 0, 0, 0.03);
369
- }
370
-
371
- .main {
372
- position: relative;
373
- z-index: 2;
374
- border-top: 1px solid #e6e6e6;
375
- }
376
-
377
- .toggle-all {
378
- width: 1px;
379
- height: 1px;
380
- border: none; /* Mobile Safari */
381
- opacity: 0;
382
- position: absolute;
383
- right: 100%;
384
- bottom: 100%;
385
- }
386
-
387
- .toggle-all + label {
388
- width: 60px;
389
- height: 34px;
390
- font-size: 0;
391
- position: absolute;
392
- top: -52px;
393
- left: -13px;
394
- -webkit-transform: rotate(90deg);
395
- transform: rotate(90deg);
396
- }
397
-
398
- .toggle-all + label:before {
399
- content: "❯";
400
- font-size: 22px;
401
- color: #e6e6e6;
402
- padding: 10px 27px 10px 27px;
403
- }
404
-
405
- .toggle-all:checked + label:before {
406
- color: #737373;
407
- }
408
-
409
- .todo-list {
410
- margin: 0;
411
- padding: 0;
412
- list-style: none;
413
- }
414
-
415
- .todo-list li {
416
- position: relative;
417
- font-size: 24px;
418
- border-bottom: 1px solid #ededed;
419
- }
420
-
421
- .todo-list li:last-child {
422
- border-bottom: none;
423
- }
424
-
425
- .todo-list li.editing {
426
- border-bottom: none;
427
- padding: 0;
428
- }
429
-
430
- .todo-list li.editing .edit {
431
- display: block;
432
- width: calc(100% - 43px);
433
- padding: 12px 16px;
434
- margin: 0 0 0 43px;
435
- }
436
-
437
- .todo-list li.editing .view {
438
- display: none;
439
- }
440
-
441
- .todo-list li .toggle {
442
- text-align: center;
443
- width: 40px;
444
- /* auto, since non-WebKit browsers doesn't support input styling */
445
- height: auto;
446
- position: absolute;
447
- top: 0;
448
- bottom: 0;
449
- margin: auto 0;
450
- border: none; /* Mobile Safari */
451
- -webkit-appearance: none;
452
- appearance: none;
453
- }
454
-
455
- .todo-list li .toggle {
456
- opacity: 0;
457
- }
458
-
459
- .todo-list li .toggle + label {
460
- /*
461
- Firefox requires `#` to be escaped - https://bugzilla.mozilla.org/show_bug.cgi?id=922433
462
- IE and Edge requires *everything* to be escaped to render, so we do that instead of just the `#` - https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/7157459/
463
- */
464
- background-image: url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%22-10%20-18%20100%20135%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2250%22%20fill%3D%22none%22%20stroke%3D%22%23ededed%22%20stroke-width%3D%223%22/%3E%3C/svg%3E");
465
- background-repeat: no-repeat;
466
- background-position: center left;
467
- }
468
-
469
- .todo-list li .toggle:checked + label {
470
- background-image: url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2240%22%20height%3D%2240%22%20viewBox%3D%22-10%20-18%20100%20135%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2250%22%20fill%3D%22none%22%20stroke%3D%22%23bddad5%22%20stroke-width%3D%223%22/%3E%3Cpath%20fill%3D%22%235dc2af%22%20d%3D%22M72%2025L42%2071%2027%2056l-4%204%2020%2020%2034-52z%22/%3E%3C/svg%3E");
471
- }
472
-
473
- .todo-list li label {
474
- word-break: break-all;
475
- padding: 15px 15px 15px 60px;
476
- display: block;
477
- line-height: 1.2;
478
- transition: color 0.4s;
479
- }
480
-
481
- .todo-list li.completed label {
482
- color: #d9d9d9;
483
- text-decoration: line-through;
484
- }
485
-
486
- .todo-list li .destroy {
487
- display: none;
488
- position: absolute;
489
- top: 0;
490
- right: 10px;
491
- bottom: 0;
492
- width: 40px;
493
- height: 40px;
494
- margin: auto 0;
495
- font-size: 30px;
496
- color: #cc9a9a;
497
- margin-bottom: 11px;
498
- transition: color 0.2s ease-out;
499
- }
500
-
501
- .todo-list li .destroy:hover {
502
- color: #af5b5e;
503
- }
504
-
505
- .todo-list li .destroy:after {
506
- content: "×";
507
- }
508
-
509
- .todo-list li:hover .destroy {
510
- display: block;
511
- }
512
-
513
- .todo-list li .edit {
514
- display: none;
515
- }
516
-
517
- .todo-list li.editing:last-child {
518
- margin-bottom: -1px;
519
- }
520
-
521
- .footer {
522
- color: #777;
523
- padding: 10px 15px;
524
- height: 20px;
525
- text-align: center;
526
- border-top: 1px solid #e6e6e6;
527
- }
528
-
529
- .footer:before {
530
- content: "";
531
- position: absolute;
532
- right: 0;
533
- bottom: 0;
534
- left: 0;
535
- height: 50px;
536
- overflow: hidden;
537
- box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2), 0 8px 0 -3px #f6f6f6,
538
- 0 9px 1px -3px rgba(0, 0, 0, 0.2), 0 16px 0 -6px #f6f6f6,
539
- 0 17px 2px -6px rgba(0, 0, 0, 0.2);
540
- }
541
-
542
- .todo-count {
543
- float: left;
544
- text-align: left;
545
- }
546
-
547
- .todo-count strong {
548
- font-weight: 300;
549
- }
550
-
551
- .filters {
552
- margin: 0;
553
- padding: 0;
554
- list-style: none;
555
- position: absolute;
556
- right: 0;
557
- left: 0;
558
- }
559
-
560
- .filters li {
561
- display: inline;
562
- }
563
-
564
- .filters li a {
565
- color: inherit;
566
- margin: 3px;
567
- padding: 3px 7px;
568
- text-decoration: none;
569
- border: 1px solid transparent;
570
- border-radius: 3px;
571
- }
572
-
573
- .filters li a:hover {
574
- border-color: rgba(175, 47, 47, 0.1);
575
- }
576
-
577
- .filters li a.selected {
578
- border-color: rgba(175, 47, 47, 0.2);
579
- }
580
-
581
- .clear-completed,
582
- html .clear-completed:active {
583
- float: right;
584
- position: relative;
585
- line-height: 20px;
586
- text-decoration: none;
587
- cursor: pointer;
588
- }
589
-
590
- .clear-completed:hover {
591
- text-decoration: underline;
592
- }
593
-
594
- .info {
595
- margin: 65px auto 0;
596
- color: #bfbfbf;
597
- font-size: 10px;
598
- text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
599
- text-align: center;
600
- }
601
-
602
- .info p {
603
- line-height: 1;
604
- }
605
-
606
- .info a {
607
- color: inherit;
608
- text-decoration: none;
609
- font-weight: 400;
610
- }
611
-
612
- .info a:hover {
613
- text-decoration: underline;
614
- }
615
-
616
- /*
617
- Hack to remove background from Mobile Safari.
618
- Can't use it globally since it destroys checkboxes in Firefox
619
- */
620
- @media screen and (-webkit-min-device-pixel-ratio: 0) {
621
- .toggle-all,
622
- .todo-list li .toggle {
623
- background: none;
624
- }
625
-
626
- .todo-list li .toggle {
627
- height: 40px;
628
- }
629
- }
630
-
631
- @media (max-width: 430px) {
632
- .footer {
633
- height: 50px;
634
- }
635
-
636
- .filters {
637
- bottom: 10px;
638
- }
639
- }
640
- </style>
@@ -1,100 +0,0 @@
1
- <template>
2
- <div class="top-bar">
3
- <div class="top-bar-left">
4
- <div v-if="isLogged">
5
- <span
6
- >Email: <b>{{ info.Email }}</b></span
7
- >
8
- <span
9
- >UID: <b>{{ info.UID }}</b></span
10
- >
11
- <span
12
- >Groups: <b>{{ info.Group.join(",") }}</b></span
13
- >
14
- </div>
15
- </div>
16
-
17
- <div class="top-bar-right">
18
- <button v-if="isLogged" @click="logout">注销</button>
19
- <button v-else @click="login">登录</button>
20
- </div>
21
- </div>
22
- </template>
23
-
24
- <script>
25
- export default {
26
- mounted() {
27
- this.isLogged = this.$lzc.isLogged();
28
- this.info = this.$lzc.user;
29
- },
30
- data() {
31
- return {
32
- info: undefined,
33
- isLogged: false,
34
- };
35
- },
36
- methods: {
37
- logout() {
38
- this.$lzc
39
- .logout()
40
- .then(() => {
41
- this.isLogged = false;
42
- this.info = undefined;
43
- this.$emit("logout");
44
- })
45
- .catch((e) => {
46
- console.error(e);
47
- })
48
- .finally(() => {
49
- window.location.reload();
50
- });
51
- },
52
- login() {
53
- this.$lzc.login();
54
- },
55
- },
56
- };
57
- </script>
58
-
59
- <style scoped>
60
- .top-bar {
61
- display: flex;
62
- flex-direction: row;
63
- justify-content: space-between;
64
- align-items: center;
65
- border: 1px solid #ebebeb;
66
- border-radius: 3px;
67
- line-height: 56px;
68
- padding: 0px 14px;
69
- }
70
-
71
- .top-bar span {
72
- padding: 0px 14px;
73
- }
74
-
75
- .top-bar button {
76
- display: inline-block;
77
- line-height: 1;
78
- white-space: nowrap;
79
- cursor: pointer;
80
- background: #fff;
81
- border: 1px solid #dcdfe6;
82
- -webkit-appearance: none;
83
- text-align: center;
84
- box-sizing: border-box;
85
- outline: none;
86
- margin: 0;
87
- transition: 0.1s;
88
- font-weight: 500;
89
- -moz-user-select: none;
90
- -webkit-user-select: none;
91
- -ms-user-select: none;
92
- padding: 12px 20px;
93
- font-size: 14px;
94
- border-radius: 4px;
95
-
96
- color: #fff;
97
- background-color: #409eff;
98
- border-color: #409eff;
99
- }
100
- </style>