@zhin.js/client 1.0.0 → 1.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.
Files changed (43) hide show
  1. package/README.md +334 -67
  2. package/app/index.html +4 -3
  3. package/app/postcss.config.js +5 -0
  4. package/app/src/components/ThemeToggle.tsx +21 -0
  5. package/app/src/hooks/useTheme.ts +17 -0
  6. package/app/src/layouts/dashboard.tsx +259 -0
  7. package/app/src/main.tsx +121 -0
  8. package/app/src/pages/dashboard-bots.tsx +198 -0
  9. package/app/src/pages/dashboard-home.tsx +301 -0
  10. package/app/src/pages/dashboard-logs.tsx +298 -0
  11. package/app/src/pages/dashboard-plugin-detail.tsx +360 -0
  12. package/app/src/pages/dashboard-plugins.tsx +166 -0
  13. package/app/src/style.css +1105 -0
  14. package/app/src/theme/index.ts +92 -0
  15. package/app/tailwind.config.js +70 -0
  16. package/app/tsconfig.json +5 -0
  17. package/dist/index.js +15 -3
  18. package/package.json +20 -7
  19. package/src/index.ts +19 -3
  20. package/src/router/index.tsx +55 -0
  21. package/src/store/index.ts +111 -0
  22. package/src/store/reducers/index.ts +16 -0
  23. package/src/store/reducers/route.ts +122 -0
  24. package/src/store/reducers/script.ts +103 -0
  25. package/src/store/reducers/ui.ts +31 -0
  26. package/src/types.ts +11 -17
  27. package/src/websocket/index.ts +193 -0
  28. package/src/websocket/useWebSocket.ts +42 -0
  29. package/app/components.d.ts +0 -33
  30. package/app/src/App.vue +0 -7
  31. package/app/src/main.ts +0 -127
  32. package/app/src/pages/$.vue +0 -899
  33. package/app/src/pages/404.vue +0 -11
  34. package/app/src/pages/contexts/overview.vue +0 -177
  35. package/app/src/pages/dashboard.vue +0 -323
  36. package/app/src/pages/plugins/installed.vue +0 -734
  37. package/app/src/pages/system/status.vue +0 -241
  38. package/app/src/services/api.ts +0 -155
  39. package/app/src/styles/README.md +0 -202
  40. package/app/src/styles/common.css +0 -0
  41. package/global.d.ts +0 -19
  42. package/src/router.ts +0 -44
  43. package/src/store.ts +0 -53
package/src/store.ts DELETED
@@ -1,53 +0,0 @@
1
- import { ref, watch } from 'vue';
2
- import { defineStore } from 'pinia';
3
- export const useCommonStore = defineStore('common', () => {
4
- const store = ref<Record<string, any>>({});
5
- const initialized = ref(false);
6
- let resolve: (v: unknown) => any;
7
- const initial = new Promise(res => (resolve = res));
8
- const syncData = ({ key, value }: { key: string; value: any }) => {
9
- store.value[key] = value;
10
- if (resolve) {
11
- initialized.value = true;
12
- setTimeout(resolve, 300);
13
- }
14
- };
15
- const addData = ({ key, value }: { key: string; value: any }) => {
16
- const list = (store.value[key] ||= []);
17
- list.push(value);
18
- };
19
- const deleteData = ({ key, value }: { key: string; value: any }) => {
20
- const list = (store.value[key] ||= []);
21
- list.splice(list.indexOf(value), 1);
22
- };
23
- let beforeElement: Node[] = [];
24
- const createScript = (store: Record<string, any>) => {
25
- if(!store.entries?.length) return;
26
- const fragment = document.createDocumentFragment();
27
- while (beforeElement.length) {
28
- const element = beforeElement.shift()!;
29
- document.body.removeChild(element);
30
- }
31
- const entries: string[] = (store.entries ||= []);
32
- entries.forEach(entry => {
33
- const el = document.createElement('script');
34
- el.type = 'module';
35
- el.src = entry;
36
- fragment.appendChild(el);
37
- beforeElement.push(el);
38
- });
39
- document.body.appendChild(fragment);
40
- };
41
- watch(store, createScript, {
42
- immediate: true,
43
- deep: true,
44
- });
45
- return {
46
- store,
47
- initialized,
48
- initial,
49
- syncData,
50
- addData,
51
- deleteData,
52
- };
53
- });