@radiantabyss/vue 3.3.11 → 3.3.13
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/package.json +1 -1
- package/src/Bootstrap.js +17 -17
- package/src/Components.js +1 -1
- package/src/Directives.js +1 -1
- package/src/Invoke.js +1 -1
- package/src/Modals.js +1 -1
- package/src/Request.js +78 -12
- package/src/Routing/Route.js +1 -1
- package/src/Routing/RouteCrud.js +1 -1
- package/src/Routing/Router.js +20 -9
package/package.json
CHANGED
package/src/Bootstrap.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import Components from './Components';
|
|
2
|
-
import Directives from './Directives';
|
|
3
|
-
import Mixins from './Mixins';
|
|
4
|
-
import Modals from './Modals';
|
|
1
|
+
import Components from './Components.js';
|
|
2
|
+
import Directives from './Directives.js';
|
|
3
|
+
import Mixins from './Mixins.js';
|
|
4
|
+
import Modals from './Modals.js';
|
|
5
5
|
|
|
6
|
-
import Alert from './Alert';
|
|
7
|
-
import Cookie from './Support/Cookie';
|
|
8
|
-
import Confirm from './Confirm';
|
|
9
|
-
import Gate from './Support/Gate';
|
|
10
|
-
import Helpers from './Support/Helpers';
|
|
11
|
-
import Invoke from './Invoke';
|
|
12
|
-
import Item from './Support/Item';
|
|
13
|
-
import Items from './Support/Items';
|
|
14
|
-
import Modal from './Modal';
|
|
15
|
-
import Request from './Request';
|
|
16
|
-
import ReactiveStorage from './Support/ReactiveStorage';
|
|
17
|
-
import Str from './Support/Str';
|
|
6
|
+
import Alert from './Alert.js';
|
|
7
|
+
import Cookie from './Support/Cookie.js';
|
|
8
|
+
import Confirm from './Confirm.js';
|
|
9
|
+
import Gate from './Support/Gate.js';
|
|
10
|
+
import Helpers from './Support/Helpers.js';
|
|
11
|
+
import Invoke from './Invoke.js';
|
|
12
|
+
import Item from './Support/Item.js';
|
|
13
|
+
import Items from './Support/Items.js';
|
|
14
|
+
import Modal from './Modal.js';
|
|
15
|
+
import Request from './Request.js';
|
|
16
|
+
import ReactiveStorage from './Support/ReactiveStorage.js';
|
|
17
|
+
import Str from './Support/Str.js';
|
|
18
18
|
|
|
19
|
-
import Store from './Store';
|
|
19
|
+
import Store from './Store.js';
|
|
20
20
|
|
|
21
21
|
export default async (app) => {
|
|
22
22
|
//helpers
|
package/src/Components.js
CHANGED
package/src/Directives.js
CHANGED
package/src/Invoke.js
CHANGED
package/src/Modals.js
CHANGED
package/src/Request.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
let sprite_version = import.meta.env.VITE_SPRITE_VERSION;
|
|
2
|
+
let get_params_format = import.meta.env.VITE_GET_PARAMS_FORMAT || 'php';
|
|
3
|
+
let current = {};
|
|
2
4
|
|
|
3
5
|
const formatErrors = function(response) {
|
|
4
6
|
let errors = [];
|
|
@@ -56,6 +58,36 @@ const appendFormData = (formData, key, value) => {
|
|
|
56
58
|
}
|
|
57
59
|
};
|
|
58
60
|
|
|
61
|
+
const buildParams = (obj, prefix = '', params = new URLSearchParams()) => {
|
|
62
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
63
|
+
const full_key = prefix ? `${prefix}[${key}]` : key;
|
|
64
|
+
|
|
65
|
+
if ( Array.isArray(value) ) {
|
|
66
|
+
if ( value.length ) {
|
|
67
|
+
value.forEach((v, i) => {
|
|
68
|
+
if (typeof v === 'object') {
|
|
69
|
+
buildParams(v, `${full_key}[${i}]`, params);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
params.append(`${full_key}[]`, v);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
params.append(full_key, value);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else if ( typeof value === 'object' && value !== null ) {
|
|
81
|
+
buildParams(value, full_key, params);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
params.append(full_key, value);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return params;
|
|
89
|
+
}
|
|
90
|
+
|
|
59
91
|
const request = function(method, edge, payload = {}, display_errors = false, base_url = null, auth_token = null, headers = {}, upload_progress = null) {
|
|
60
92
|
return new Promise((resolve, reject) => {
|
|
61
93
|
if ( !base_url ) {
|
|
@@ -66,7 +98,7 @@ const request = function(method, edge, payload = {}, display_errors = false, bas
|
|
|
66
98
|
auth_token = localStorage.getItem('jwt_token');
|
|
67
99
|
}
|
|
68
100
|
|
|
69
|
-
if ( method
|
|
101
|
+
if ( method == 'POST' ) {
|
|
70
102
|
Alert.hide();
|
|
71
103
|
}
|
|
72
104
|
|
|
@@ -101,23 +133,43 @@ const request = function(method, edge, payload = {}, display_errors = false, bas
|
|
|
101
133
|
_button.disabled = true;
|
|
102
134
|
}
|
|
103
135
|
|
|
136
|
+
let _cancel;
|
|
137
|
+
if ( payload._cancel !== undefined ) {
|
|
138
|
+
_cancel = new AbortController();
|
|
139
|
+
delete payload._cancel;
|
|
140
|
+
|
|
141
|
+
if ( current[edge] ) {
|
|
142
|
+
try {
|
|
143
|
+
current[edge].abort();
|
|
144
|
+
}
|
|
145
|
+
catch(e) {}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
current[edge] = _cancel;
|
|
149
|
+
}
|
|
150
|
+
|
|
104
151
|
let data;
|
|
105
152
|
let url = base_url + edge;
|
|
106
153
|
|
|
107
|
-
if ( method
|
|
108
|
-
|
|
154
|
+
if ( method == 'GET' ) {
|
|
155
|
+
if ( get_params_format == 'php' ) {
|
|
156
|
+
url += '?' + buildParams(payload);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
url += '?' + new URLSearchParams(payload).toString();
|
|
160
|
+
}
|
|
109
161
|
}
|
|
110
|
-
else if ( method
|
|
111
|
-
if ( headers['Content-Type']
|
|
162
|
+
else if ( method == 'POST' ) {
|
|
163
|
+
if ( headers['Content-Type'] == 'multipart/form-data' ) {
|
|
112
164
|
data = new FormData();
|
|
113
165
|
|
|
114
|
-
for (let key in payload) {
|
|
166
|
+
for ( let key in payload ) {
|
|
115
167
|
appendFormData(data, key, payload[key]);
|
|
116
168
|
}
|
|
117
169
|
|
|
118
170
|
delete headers['Content-Type'];
|
|
119
171
|
}
|
|
120
|
-
else if ( headers['Content-Type']
|
|
172
|
+
else if ( headers['Content-Type'] == 'application/x-www-form-urlencoded' ) {
|
|
121
173
|
data = serializeToURLEncoded(payload).replace(/\&+$/, '');
|
|
122
174
|
}
|
|
123
175
|
else {
|
|
@@ -150,17 +202,25 @@ const request = function(method, edge, payload = {}, display_errors = false, bas
|
|
|
150
202
|
}
|
|
151
203
|
}
|
|
152
204
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
body
|
|
157
|
-
}
|
|
205
|
+
let options = { method, headers };
|
|
206
|
+
|
|
207
|
+
if ( method != 'GET' ) {
|
|
208
|
+
options.body = data;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if ( _cancel ) {
|
|
212
|
+
options.signal = _cancel.signal;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
fetch(url, options)
|
|
158
216
|
.then(async (response) => {
|
|
159
217
|
if ( _button !== undefined ) {
|
|
160
218
|
_button.disabled = false;
|
|
161
219
|
_button.innerHTML = _button_html;
|
|
162
220
|
}
|
|
163
221
|
|
|
222
|
+
delete current[edge];
|
|
223
|
+
|
|
164
224
|
const response_data = await response.json();
|
|
165
225
|
|
|
166
226
|
if ( edge.match(/\.json/) ) {
|
|
@@ -179,6 +239,12 @@ const request = function(method, edge, payload = {}, display_errors = false, bas
|
|
|
179
239
|
reject(errors);
|
|
180
240
|
})
|
|
181
241
|
.catch((error) => {
|
|
242
|
+
if ( error.name == 'AbortError' ) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
delete current[edge];
|
|
247
|
+
|
|
182
248
|
let errors = [error.message];
|
|
183
249
|
|
|
184
250
|
if ( display_errors ) {
|
package/src/Routing/Route.js
CHANGED
package/src/Routing/RouteCrud.js
CHANGED
package/src/Routing/Router.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { nextTick, watch } from 'vue';
|
|
2
|
-
import { createRouter, createWebHistory } from 'vue-router';
|
|
3
|
-
import Str from './../Support/Str';
|
|
4
|
-
import Actions from './Actions';
|
|
5
|
-
import Middleware from './Middleware';
|
|
6
|
-
import RouteFiles from './RouteFiles';
|
|
7
|
-
import Route from './Route';
|
|
8
|
-
import RouteCrud from './RouteCrud';
|
|
2
|
+
import { createRouter, createWebHistory, createWebHashHistory, createMemoryHistory } from 'vue-router';
|
|
3
|
+
import Str from './../Support/Str.js';
|
|
4
|
+
import Actions from './Actions.js';
|
|
5
|
+
import Middleware from './Middleware.js';
|
|
6
|
+
import RouteFiles from './RouteFiles.js';
|
|
7
|
+
import Route from './Route.js';
|
|
8
|
+
import RouteCrud from './RouteCrud.js';
|
|
9
9
|
|
|
10
10
|
window.RouteFiles = RouteFiles;
|
|
11
11
|
window.Route = Route;
|
|
@@ -30,14 +30,25 @@ const loadModules = async () => {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export default async () => {
|
|
33
|
+
export default async (history_mode = 'web') => {
|
|
34
34
|
let runMiddleware = await Middleware();
|
|
35
35
|
|
|
36
36
|
await loadModules();
|
|
37
37
|
|
|
38
|
+
let history;
|
|
39
|
+
if ( history_mode == 'web' ) {
|
|
40
|
+
history = createWebHistory();
|
|
41
|
+
}
|
|
42
|
+
else if ( history_mode == 'hash' ) {
|
|
43
|
+
history = createWebHashHistory();
|
|
44
|
+
}
|
|
45
|
+
else if ( history_mode == 'memory' ) {
|
|
46
|
+
history = createMemoryHistory();
|
|
47
|
+
}
|
|
48
|
+
|
|
38
49
|
//create router
|
|
39
50
|
const Router = createRouter({
|
|
40
|
-
history
|
|
51
|
+
history,
|
|
41
52
|
routes: [],
|
|
42
53
|
duplicateNavigationPolicy: 'reload',
|
|
43
54
|
scrollBehavior(to, from, scroll) {
|