ivue 0.0.32 → 0.1.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.
Files changed (157) hide show
  1. package/.babelrc.json +14 -0
  2. package/.eslintrc.cjs +24 -0
  3. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  4. package/.idea/compiler.xml +7 -0
  5. package/.idea/infinite-vue.iml +10 -0
  6. package/.idea/inspectionProfiles/Project_Default.xml +11 -0
  7. package/.idea/modules.xml +8 -0
  8. package/.idea/php.xml +20 -0
  9. package/.idea/vcs.xml +6 -0
  10. package/.vscode/extensions.json +3 -0
  11. package/LICENSE +19 -0
  12. package/README.md +31 -0
  13. package/demo/App.vue +72 -0
  14. package/demo/components/IVueTest.vue +298 -0
  15. package/demo/components/PreComponent.vue +13 -0
  16. package/demo/components/SubComponent2.vue +45 -0
  17. package/demo/components/TraitsComponent.vue +120 -0
  18. package/demo/components/useIVueTest.vue +136 -0
  19. package/demo/main.ts +21 -0
  20. package/demo/router/index.ts +14 -0
  21. package/demo/tests/IVueTests.ts +255 -0
  22. package/demo/tests/Mouse.ts +79 -0
  23. package/demo/tests/ParentIVueTests.ts +36 -0
  24. package/demo/tests/TApp.ts +15 -0
  25. package/demo/tests/TAuth.ts +23 -0
  26. package/demo/tests/TField.ts +84 -0
  27. package/demo/tests/TMessage.ts +52 -0
  28. package/demo/tests/TRouter.ts +18 -0
  29. package/demo/tests/TUser.ts +19 -0
  30. package/demo/tests/Test.ts +86 -0
  31. package/demo/tests/useField.ts +82 -0
  32. package/demo/tests/useIVueTests.ts +57 -0
  33. package/demo/vite.config.ts +13 -0
  34. package/dist/favicon.ico +0 -0
  35. package/dist/index.es.js +518 -0
  36. package/dist/index.umd.js +1 -0
  37. package/dist/src/behavior.d.ts +72 -0
  38. package/dist/src/config.d.ts +6 -0
  39. package/dist/src/index.d.ts +21 -0
  40. package/dist/src/ivue.d.ts +35 -0
  41. package/dist/src/kernel.d.ts +182 -0
  42. package/dist/src/traits/UseCapsule.d.ts +9 -0
  43. package/dist/src/traits/UseEmit.d.ts +3 -0
  44. package/dist/src/traits/UseInstance.d.ts +6 -0
  45. package/dist/src/traits/UseMounting.d.ts +11 -0
  46. package/dist/src/traits/UseRefs.d.ts +8 -0
  47. package/dist/src/traits/UseRoute.d.ts +3 -0
  48. package/dist/src/traits/UseRouter.d.ts +3 -0
  49. package/dist/src/traits/UseRouting.d.ts +6 -0
  50. package/dist/src/traits/UseTick.d.ts +4 -0
  51. package/dist/src/traits/UseVue.d.ts +13 -0
  52. package/dist/src/types/core.d.ts +46 -0
  53. package/dist/src/utils/dispose-garbage.d.ts +12 -0
  54. package/dist/src/utils/extend.d.ts +12 -0
  55. package/dist/src/utils/getters.d.ts +21 -0
  56. package/dist/src/utils/index.d.ts +7 -0
  57. package/dist/src/utils/is.d.ts +14 -0
  58. package/dist/src/utils/pre.d.ts +9 -0
  59. package/dist/src/utils/raw.d.ts +12 -0
  60. package/dist/src/utils/safe-class-name.d.ts +7 -0
  61. package/dist/src/utils/traits.d.ts +41 -0
  62. package/env.d.ts +1 -0
  63. package/index.html +13 -0
  64. package/package-lock.json +14305 -0
  65. package/package.json +89 -10
  66. package/public/favicon.ico +0 -0
  67. package/src/App/App.ts +27 -0
  68. package/src/App/Auth/Auth.ts +105 -0
  69. package/src/App/Auth/Auth.vue +98 -0
  70. package/src/App/Auth/Logout.vue +14 -0
  71. package/src/App/Auth/User.ts +6 -0
  72. package/src/App/BlackBox.ts +75 -0
  73. package/src/App/Config.ts +6 -0
  74. package/src/App/Generators/generators.ts +47 -0
  75. package/src/App/Home/Home.vue +16 -0
  76. package/src/App/Services/Http/FakeHttp.ts +8 -0
  77. package/src/App/Services/Http/Http.ts +51 -0
  78. package/src/App/Services/Message/Message.ts +49 -0
  79. package/src/App/Services/Message/Message.vue +15 -0
  80. package/src/App/Services/Navigation/Navigation.ts +83 -0
  81. package/src/App/Services/Navigation/Navigation.vue +59 -0
  82. package/src/App/Services/Routing/FakeRouter.ts +7 -0
  83. package/src/App/Services/Routing/NotFoundRoute.vue +13 -0
  84. package/src/App/Services/Routing/Router.ts +262 -0
  85. package/src/App/Services/Routing/Routes.ts +49 -0
  86. package/src/App/Stubs/SingleBookResultStub.ts +13 -0
  87. package/src/App/Traits/UseApp.ts +6 -0
  88. package/src/App/Traits/UseBlackline.ts +0 -0
  89. package/src/App/Traits/UseQuasar.ts +8 -0
  90. package/src/behavior.ts +269 -0
  91. package/src/config.ts +15 -0
  92. package/src/dev/dev-utils.ts +78 -0
  93. package/src/index.ts +83 -0
  94. package/src/ivue.ts +296 -0
  95. package/src/kernel.ts +810 -0
  96. package/src/tests/auth.spec.ts +48 -0
  97. package/src/traits/UseCapsule.ts +28 -0
  98. package/src/traits/UseEmit.ts +3 -0
  99. package/src/traits/UseInstance.ts +17 -0
  100. package/src/traits/UseMounting.ts +23 -0
  101. package/src/traits/UseRefs.ts +17 -0
  102. package/src/traits/UseRoute.ts +6 -0
  103. package/src/traits/UseRouter.ts +5 -0
  104. package/src/traits/UseRouting.ts +7 -0
  105. package/src/traits/UseTick.ts +5 -0
  106. package/src/traits/UseVue.ts +38 -0
  107. package/src/types/core.ts +64 -0
  108. package/src/utils/dispose-garbage.ts +34 -0
  109. package/src/utils/extend.ts +85 -0
  110. package/src/utils/getters.ts +62 -0
  111. package/src/utils/index.ts +16 -0
  112. package/src/utils/is.ts +22 -0
  113. package/src/utils/pre.ts +29 -0
  114. package/src/utils/raw.ts +19 -0
  115. package/src/utils/safe-class-name.ts +15 -0
  116. package/src/utils/traits.ts +121 -0
  117. package/tsconfig.app.json +47 -0
  118. package/tsconfig.json +14 -0
  119. package/tsconfig.node.json +14 -0
  120. package/tsconfig.vitest.json +9 -0
  121. package/vite.config.ts +55 -0
  122. package/vitest.config.ts +18 -0
  123. package/dist/index.js +0 -218
  124. package/docs/index.html +0 -195
  125. package/docs/index.json +0 -3
  126. package/docs/input.html +0 -41
  127. package/docs/items.html +0 -42
  128. package/gulpfile.js +0 -5
  129. package/src/components/checkbox.js +0 -47
  130. package/src/components/data.js +0 -6
  131. package/src/components/file.js +0 -40
  132. package/src/components/form.js +0 -7
  133. package/src/components/index.js +0 -15
  134. package/src/components/input.js +0 -80
  135. package/src/components/items.js +0 -65
  136. package/src/components/modal.js +0 -42
  137. package/src/components/paginate-old.js +0 -88
  138. package/src/components/paginate.js +0 -35
  139. package/src/components/select-search.js +0 -152
  140. package/src/components/select.js +0 -62
  141. package/src/components/submit.js +0 -10
  142. package/src/components/textarea.js +0 -72
  143. package/src/components/upload.js +0 -49
  144. package/src/directives/href.js +0 -10
  145. package/src/directives/index.js +0 -1
  146. package/src/filters/date.js +0 -3
  147. package/src/filters/datetime.js +0 -3
  148. package/src/filters/index.js +0 -4
  149. package/src/filters/json.js +0 -3
  150. package/src/filters/money.js +0 -3
  151. package/src/index.js +0 -4
  152. package/src/mixins/data.js +0 -13
  153. package/src/mixins/form.js +0 -85
  154. package/src/mixins/resource.js +0 -31
  155. package/src/services/client.js +0 -32
  156. package/src/services/flash.js +0 -17
  157. package/src/services/index.js +0 -2
package/package.json CHANGED
@@ -1,16 +1,95 @@
1
1
  {
2
2
  "name": "ivue",
3
- "version": "0.0.32",
4
- "description": "",
5
- "main": "src/index.js",
3
+ "version": "0.1.0",
4
+ "description": "ivue – Infinite Vue. Advanced State Management & Class Architecture for Vue 3+.",
5
+ "exports": {
6
+ ".": {
7
+ "require": "./dist/index.umd.js",
8
+ "import": "./dist/index.es.js",
9
+ "types": "./dist/src/index.d.ts",
10
+ "style": "./dist/style.css"
11
+ }
12
+ },
13
+ "main": "./dist/index.umd.js",
14
+ "module": "./dist/index.es.js",
15
+ "types": "./dist/src/index.d.ts",
6
16
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
17
+ "dev": "vite",
18
+ "build": "run-p type-check build-only",
19
+ "preview": "vite preview",
20
+ "test": "vitest --reporter=verbose",
21
+ "build-only": "rm -rf ./dist/* && vite build",
22
+ "type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
23
+ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
24
+ },
25
+ "peerDependencies": {
26
+ "vue": "^3.0.0",
27
+ "vue-router": "^4.0.0"
8
28
  },
9
- "author": "",
10
- "license": "ISC",
11
29
  "devDependencies": {
12
- "gulp": "^3.9.1",
13
- "laravel-elixir": "^6.0.0-10",
14
- "laravel-elixir-webpack-official": "^1.0.4"
15
- }
30
+ "@rushstack/eslint-patch": "^1.2.0",
31
+ "@tsconfig/node18": "^2.0.1",
32
+ "@types/inversify": "^2.0.33",
33
+ "@types/jsdom": "^21.1.1",
34
+ "@types/node": "^18.16.8",
35
+ "@vitejs/plugin-vue": "^4.2.3",
36
+ "@vitejs/plugin-vue-jsx": "^3.0.1",
37
+ "@vue/eslint-config-typescript": "^11.0.3",
38
+ "@vue/test-utils": "^2.3.2",
39
+ "@vue/tsconfig": "^0.4.0",
40
+ "@vueuse/core": "^10.1.2",
41
+ "babel-jest": "^29.5.0",
42
+ "eslint": "^8.39.0",
43
+ "eslint-plugin-vue": "^9.11.0",
44
+ "infinite-vue": "^1.4.5",
45
+ "inversify": "^6.0.1",
46
+ "inversify-inject-decorators": "^3.1.0",
47
+ "ivue": "npm:infinite-vue",
48
+ "jsdom": "^22.0.0",
49
+ "lodash": "^4.17.21",
50
+ "npm-run-all": "^4.1.5",
51
+ "pinia": "^2.0.36",
52
+ "reflect-metadata": "^0.1.13",
53
+ "rollup-plugin-terser": "^7.0.2",
54
+ "transform-class-properties": "^1.0.0-beta",
55
+ "tree-model": "^1.0.7",
56
+ "typescript": "~5.0.4",
57
+ "vite": "^4.3.5",
58
+ "vite-plugin-dts": "^2.3.0",
59
+ "vitest": "^0.31.0",
60
+ "vue": "^3.3.4",
61
+ "vue-dd": "^1.6.4",
62
+ "vue-router": "^4.2.4",
63
+ "vue-tsc": "^1.6.4",
64
+ "vue-use": "^0.2.0",
65
+ "wait-for-expect": "^3.0.2"
66
+ },
67
+ "repository": {
68
+ "type": "git",
69
+ "url": "https://github.com/infinite-system/infinite-vue"
70
+ },
71
+ "homepage": "https://github.com/infinite-system/infinite-vue",
72
+ "bugs": {
73
+ "url": "https://github.com/infinite-system/infinite-vue/issues",
74
+ "email": "ekalashnikov@gmail.com"
75
+ },
76
+ "keywords": [
77
+ "ivue",
78
+ "vuex",
79
+ "mobx",
80
+ "redux",
81
+ "vue",
82
+ "react",
83
+ "vuejs",
84
+ "vuex",
85
+ "pinia",
86
+ "state management",
87
+ "reactive"
88
+ ],
89
+ "author": {
90
+ "name": "Evgeny Kalashnikov",
91
+ "email": "ekalashnikov@gmail.com"
92
+ },
93
+ "license": "MIT",
94
+ "dependencies": {}
16
95
  }
Binary file
package/src/App/App.ts ADDED
@@ -0,0 +1,27 @@
1
+ import { use } from '@/index'
2
+
3
+ import { Message } from './Services/Message/Message'
4
+ import { Router } from './Services/Routing/Router'
5
+
6
+ import routes from './Services/Routing/Routes'
7
+ import { Auth } from './Auth/Auth'
8
+ import { User } from './Auth/User'
9
+
10
+
11
+ export class App {
12
+
13
+ get router () { return use(Router) }
14
+
15
+ get user () { return use(User) }
16
+
17
+ get auth () { return use(Auth) }
18
+
19
+ get message () { return use(Message) }
20
+
21
+ load () {
22
+ this.router.$.register(routes)
23
+ return this
24
+ }
25
+ }
26
+
27
+ //
@@ -0,0 +1,105 @@
1
+ import { use } from '@/index'
2
+ import { Traits } from '@/index'
3
+ import { User } from './User'
4
+ import { Http } from '@/App/Services/Http/Http';
5
+ import { $Message, Message } from '@/App/Services/Message/Message';
6
+ import { Router } from '@/App/Services/Routing/Router'
7
+ import type { Null } from '@/types/core'
8
+ import { UseCapsule } from '@/traits/UseCapsule';
9
+
10
+ export class $Auth {
11
+
12
+ get http () { return use(Http) }
13
+ get user () { return use(User) }
14
+ get $message () { return use($Message) }
15
+
16
+ async login (email: Null<string>, password: Null<string>) {
17
+
18
+ const login = await this.http.post(
19
+ '/login', { email, password }
20
+ )
21
+
22
+ if (login.success) {
23
+ this.user.email = email
24
+ this.user.token = login.result.token
25
+ }
26
+
27
+ return this.$message.unpack(login)
28
+ }
29
+
30
+ async register (email: Null<string>, password: Null<string>) {
31
+
32
+ const registerDto = await this.http.post(
33
+ '/register', { email, password }
34
+ )
35
+
36
+ return this.$message.unpack(registerDto)
37
+ }
38
+
39
+ async logout () {
40
+ this.user.email = ''
41
+ this.user.token = ''
42
+ }
43
+ }
44
+
45
+
46
+ export class Auth {
47
+
48
+ capsule = $Auth
49
+ constructor() {
50
+ this.useCapsule()
51
+ }
52
+
53
+ get router () { return use(Router) }
54
+ get message () { return use(Message) }
55
+
56
+ email: Null<string> = null
57
+ password: Null<string> = null
58
+ option: Null<string> = null
59
+
60
+ init(){
61
+ this.option = 'login'
62
+ this.email = 'ekalashnikov@gmail.com'
63
+ this.password = 'test1234'
64
+ }
65
+
66
+ reset () {
67
+ this.email = ''
68
+ this.password = ''
69
+ this.option = 'login'
70
+ }
71
+
72
+ formValid () {
73
+ const message = []
74
+
75
+ if (this.email === '') message.push('No email')
76
+ if (this.password === '') message.push('No password')
77
+
78
+ this.message.$.clientMessages = message
79
+
80
+ return message.length === 0
81
+ }
82
+
83
+ async login () {
84
+ const login = await this.$.login(this.email, this.password)
85
+
86
+ this.message.show(login, 'User logged in')
87
+
88
+ if (login.success) {
89
+ this.router.push({ name: 'home' })
90
+ }
91
+ }
92
+
93
+ async register () {
94
+ const register = await this.$.register(this.email, this.password)
95
+ this.message.show(register, 'User registered')
96
+ }
97
+
98
+ async logout () {
99
+ this.$.logout()
100
+ this.router.push({ name: 'login' })
101
+ }
102
+ }
103
+
104
+ Traits(Auth, [UseCapsule])
105
+ export interface Auth extends UseCapsule {}
@@ -0,0 +1,98 @@
1
+ <script setup lang="ts">
2
+ import { use } from '@/index'
3
+ import { Auth } from '@/App/Auth/Auth'
4
+
5
+ import Message from '@/App/Services/Message/Message.vue'
6
+
7
+ const v = use(Auth);
8
+ </script>
9
+ <template>
10
+
11
+ <div class="container">
12
+ <div class="login-register">
13
+ <div class="w3-row">
14
+ <div class="w3-col s4 w3-center">
15
+ <br />
16
+ </div>
17
+ <div class="w3-col s4 w3-center logo">
18
+ <img alt="logo"
19
+ src="https://kajabi-storefronts-production.kajabi-cdn.com/kajabi-storefronts-production/themes/2147767979/settings_images/iE7LayVvSHeoYcZWO4Dq_web-logo-pink-light-bg3x.png"
20
+ style="width: 160px; filter: grayscale(100%);">
21
+ </div>
22
+
23
+ <div class="w3-col s4 w3-center">
24
+
25
+ </div>
26
+ </div>
27
+ </div>
28
+
29
+ <div>
30
+ <div class="w3-row">
31
+ <div class="w3-col s4 w3-center">
32
+ <br />
33
+ </div>
34
+ <div class="w3-col s4 w3-center option">
35
+ <input
36
+ class="lr-submit"
37
+ :style="{ backgroundColor: '#e4257d' }"
38
+ type="submit"
39
+ value="login"
40
+ @click.prevent="() => v.option = 'login'"
41
+ />
42
+ <input
43
+ class="lr-submit"
44
+ :style="{ backgroundColor: '#2E91FC' }"
45
+ type="submit"
46
+ value="register"
47
+ @click.prevent="() => {
48
+ v.option = 'register'
49
+ }"
50
+ />
51
+ </div>
52
+ <div class="w3-col s4 w3-center">
53
+ <br />
54
+ </div>
55
+ </div>
56
+ <div
57
+ class="w3-row"
58
+ :style="{
59
+ backgroundColor: v.option === 'login' ? '#E4257D' : '#2E91FC',
60
+ height: '100px',
61
+ paddingTop: '20px',
62
+ }"
63
+ >
64
+ <form
65
+ class="login"
66
+ @submit.prevent="(event) => {
67
+ // event.preventDefault()
68
+ if (v.formValid()) {
69
+ if (v.option === 'login') v.login()
70
+ if (v.option === 'register') v.register()
71
+ }
72
+ }"
73
+ >
74
+ <div class="w3-col s4 w3-center">
75
+ <input
76
+ type="text"
77
+ v-model="v.email"
78
+ placeholder="Email"
79
+ />
80
+ </div>
81
+ <div class="w3-col s4 w3-center">
82
+ <input
83
+ type="text"
84
+ v-model="v.password"
85
+ placeholder="Password"
86
+ />
87
+ </div>
88
+ <div class="w3-col s4 w3-center">
89
+ <input type="submit" class="lr-submit" :value="v.option" />
90
+ </div>
91
+
92
+ <br />
93
+ </form>
94
+ </div>
95
+ <Message />
96
+ </div>
97
+ </div>
98
+ </template>
@@ -0,0 +1,14 @@
1
+ <script setup lang="ts">
2
+ import { use } from '@/index'
3
+ import { Auth } from './Auth'
4
+
5
+ const v = use(Auth)
6
+ </script>
7
+ <template>
8
+ <div @click="() => v.logout()"
9
+ class="navigation-item"
10
+ :style="{ backgroundColor: '#5BCA06' }"
11
+ >
12
+ <span>☯ Logout</span>
13
+ </div>
14
+ </template>
@@ -0,0 +1,6 @@
1
+ import type { Null } from "@/types/core"
2
+
3
+ export class User {
4
+ email: Null<string> = ''
5
+ token: Null<string> = ''
6
+ }
@@ -0,0 +1,75 @@
1
+ import { createApp } from "vue";
2
+ import { vi } from 'vitest'
3
+ import { setup, bind, use } from '@/index'
4
+ import AppComponent from "../../demo/App.vue";
5
+ import { FakeRouter } from './Services/Routing/FakeRouter'
6
+ import { FakeHttp } from './Services/Http/FakeHttp'
7
+
8
+ import { App } from './App'
9
+ import { Http } from '@/App/Services/Http/Http';
10
+ import { Router } from './Services/Routing/Router'
11
+ import { Auth } from './Auth/Auth.js'
12
+
13
+ import { SingleBooksResultStub } from './Stubs/SingleBooksResultStub'
14
+
15
+ export class BlackBox {
16
+
17
+ app!: App
18
+
19
+ http!: Http
20
+
21
+ auth!: Auth
22
+
23
+ router!: Router
24
+
25
+ vue!: ReturnType<typeof createApp>
26
+
27
+ init() {
28
+
29
+ // bind(Http).to(FakeHttp).singleton().ivue()
30
+ // bind(Router).to(FakeRouter).singleton().ivue()
31
+
32
+ this.app = use(App).load()
33
+ setup({ router: this.app.router })
34
+
35
+ // this.vue = createApp(AppComponent);
36
+
37
+ // console.log('router', this.app.router)
38
+ // this.vue.use(this.app.router)
39
+
40
+ // this.vue.mount("#app");
41
+
42
+
43
+ // Object.defineProperty(Router.prototype, 'push', {
44
+ // value: vi.fn().mockImplementation(to => {
45
+ // // pivot
46
+ // this.router.$.beforeRoute(to)
47
+ // })
48
+ // })
49
+
50
+ return this
51
+ }
52
+
53
+ // 2. bootstrap the app
54
+ bootStrap() {
55
+ this.app.load()
56
+ }
57
+
58
+ // 3. login or register to the app
59
+ setupLogin = async (loginStub, type) => {
60
+
61
+ this.http.get = vi.fn().mockImplementation((path) => {
62
+ // return Promise.resolve(SingleBooksResultStub())
63
+ })
64
+
65
+ this.http.post = vi.fn().mockImplementation((path) => {
66
+ return Promise.resolve(loginStub())
67
+ })
68
+ //
69
+ // this.loginRegisterPresenter = this.container.get(TestPresenter)
70
+ // this.loginRegisterPresenter.email = 'a@b.com'
71
+ // this.loginRegisterPresenter.password = '123'
72
+ // await this.loginRegisterPresenter.login()
73
+ // return this.loginRegisterPresenter
74
+ }
75
+ }
@@ -0,0 +1,6 @@
1
+ export class Config {
2
+ apiUrl: string
3
+ constructor() {
4
+ this.apiUrl = 'https://api.logicroom.co/secure-api/ekalashnikov@gmail.com'
5
+ }
6
+ }
@@ -0,0 +1,47 @@
1
+ export function generateHugeArray(obj, size = 20) {
2
+ for (let i = 0; i < size; i++) {
3
+ obj.hugeArray.push({
4
+ struct: {
5
+ id: i,
6
+ user: 'username',
7
+ text: 'hello world',
8
+ struct: {
9
+ id: i,
10
+ user: 'username',
11
+ text: 'hello world',
12
+ struct: {
13
+ id: i,
14
+ user: 'username',
15
+ text: 'hello world',
16
+ struct: {
17
+ id: i,
18
+ user: 'username',
19
+ text: 'hello world',
20
+ struct: {
21
+ id: i,
22
+ user: 'username',
23
+ text: 'hello world',
24
+ struct: {
25
+ id: i,
26
+ user: 'username',
27
+ text: 'hello world',
28
+ struct: {
29
+ id: i,
30
+ user: 'username',
31
+ text: 'hello world',
32
+ struct: {
33
+ id: i,
34
+ user: 'username',
35
+ text: 'hello world',
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }
44
+ })
45
+ }
46
+
47
+ }
@@ -0,0 +1,16 @@
1
+ <script setup lang="ts">
2
+ import Navigation from '@/App/Services/Navigation/Navigation.vue'
3
+ </script>
4
+ <template>
5
+ <!-- <vue-dd v-model="app" get-all-properties /> -->
6
+ <br />
7
+
8
+ <div class="w3-row">
9
+ <div class="w3-col s4 w3-center">
10
+ <Navigation />
11
+ </div>
12
+ <div class="w3-col s8 w3-left">
13
+ <router-view />
14
+ </div>
15
+ </div>
16
+ </template>
@@ -0,0 +1,8 @@
1
+
2
+ export class FakeHttp {
3
+ get = async (path) => {}
4
+
5
+ post = async (path, requestDto) => {}
6
+
7
+ delete = async (path) => {}
8
+ }
@@ -0,0 +1,51 @@
1
+ import { Config } from '../../Config'
2
+ import { User } from '../../Auth/User'
3
+ import { use } from '@/index'
4
+
5
+ export class Http {
6
+
7
+ get config () { return use(Config) }
8
+
9
+ get user () { return use(User) }
10
+
11
+ setHeaders () {
12
+ return {
13
+ 'Content-Type': 'application/json',
14
+ Authorization: this.user.token as string,
15
+ }
16
+ }
17
+
18
+ async get (path: string) {
19
+
20
+ const response = await fetch(
21
+ this.config.apiUrl + path, {
22
+ method: 'GET',
23
+ headers: this.setHeaders()
24
+ })
25
+
26
+ return response.json()
27
+ }
28
+
29
+ async post (path: string, req: {}) {
30
+
31
+ const response = await fetch(
32
+ this.config.apiUrl + path, {
33
+ method: 'POST',
34
+ body: JSON.stringify(req),
35
+ headers: this.setHeaders()
36
+ })
37
+
38
+ return response.json()
39
+ }
40
+
41
+ async delete (path: string) {
42
+
43
+ const response = await fetch(
44
+ this.config.apiUrl + path, {
45
+ method: 'DELETE',
46
+ headers: this.setHeaders()
47
+ })
48
+
49
+ return response.json()
50
+ }
51
+ }
@@ -0,0 +1,49 @@
1
+ import { use } from '@/index'
2
+ import type { Null } from '@/types/core'
3
+
4
+ export class $Message {
5
+
6
+ appMessages: Null<any[]> = null
7
+ clientMessages: Null<any[]> = null
8
+
9
+ constructor () {
10
+ this.reset()
11
+ }
12
+
13
+ reset () {
14
+ this.appMessages = []
15
+ this.clientMessages = []
16
+ }
17
+
18
+ unpack (dto: any) {
19
+ return {
20
+ success: dto.success,
21
+ serverMessage: dto.result.message
22
+ }
23
+ }
24
+ }
25
+
26
+ export class Message {
27
+
28
+ get $ () { return use($Message) }
29
+
30
+ showWarning: Null<boolean> = null
31
+
32
+ init () {
33
+ this.showWarning = false
34
+ this.$.reset()
35
+ }
36
+
37
+ get appMessages () {
38
+ return this.$.appMessages
39
+ }
40
+
41
+ get clientMessages () {
42
+ return this.$.clientMessages
43
+ }
44
+
45
+ show (pm: any, userMessage: any) {
46
+ this.showWarning = !pm.success
47
+ this.$.appMessages = pm.success ? [userMessage] : [pm.serverMessage]
48
+ }
49
+ }
@@ -0,0 +1,15 @@
1
+ <script setup lang="ts">
2
+ import { use } from '@/index'
3
+ import { Message } from './Message'
4
+
5
+ const v = use(Message);
6
+ </script>
7
+ <template>
8
+ <div v-for="message in v.appMessages" :style="{ backgroundColor: 'red' }">
9
+ - {{ message }}
10
+ </div>
11
+
12
+ <div v-for="message in v.clientMessages" :style="{ backgroundColor: 'orange' }">
13
+ - {{ message }}
14
+ </div>
15
+ </template>