@ninebone/util 1.0.24 → 1.0.26

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/dist/nine-util.js CHANGED
@@ -197,18 +197,22 @@ const _Fetch = class _Fetch {
197
197
  };
198
198
  _request = new WeakMap();
199
199
  __publicField(_Fetch, "BASE_URL", window.__API_BASE_URL__ || "");
200
- __privateAdd(_Fetch, _request, (method, url, data = {}, showLoading = true) => {
200
+ __privateAdd(_Fetch, _request, (method, url, data = {}, headers = {}, showLoading = true) => {
201
201
  const finalUrl = url.startsWith("http") ? url : `${_Fetch.BASE_URL}${url}`;
202
202
  if (showLoading) {
203
203
  Loading.show();
204
204
  }
205
- const headers = {};
205
+ const finalHeaders = { ...headers };
206
+ const token = localStorage.getItem("accessToken");
207
+ if (token && !finalHeaders["Authorization"] && !finalHeaders["authorization"]) {
208
+ finalHeaders["Authorization"] = `Bearer ${token}`;
209
+ }
206
210
  if (!(data instanceof FormData)) {
207
- headers["Content-Type"] = "application/json";
211
+ finalHeaders["Content-Type"] = "application/json";
208
212
  }
209
213
  const options = {
210
214
  method,
211
- headers
215
+ headers: finalHeaders
212
216
  };
213
217
  let targetUrl = finalUrl;
214
218
  if (method === "GET") {
@@ -232,15 +236,15 @@ __privateAdd(_Fetch, _request, (method, url, data = {}, showLoading = true) => {
232
236
  });
233
237
  });
234
238
  // 기존 post/get 메서드도 인자를 넘겨주도록 수정
235
- __publicField(_Fetch, "get", (url, data = {}, showLoading = true) => {
239
+ __publicField(_Fetch, "get", (url, data = {}, header = {}, showLoading = true) => {
236
240
  var _a2;
237
- return __privateGet(_a2 = _Fetch, _request).call(_a2, "GET", url, data, showLoading);
241
+ return __privateGet(_a2 = _Fetch, _request).call(_a2, "GET", url, data, header, showLoading);
238
242
  });
239
- __publicField(_Fetch, "post", (url, data = {}, showLoading = true) => {
243
+ __publicField(_Fetch, "post", (url, data = {}, header = {}, showLoading = true) => {
240
244
  var _a2;
241
- return __privateGet(_a2 = _Fetch, _request).call(_a2, "POST", url, data, showLoading);
245
+ return __privateGet(_a2 = _Fetch, _request).call(_a2, "POST", url, data, header, showLoading);
242
246
  });
243
- /**
247
+ /**header
244
248
  * 🚀 범용 청크 전송 (파라미터 이름까지 동적 설정)
245
249
  * @param {string} url - API 주소
246
250
  * @param {Array} rows - 데이터 배열
@@ -1297,7 +1301,7 @@ class UxSplitter extends HTMLElement {
1297
1301
  const htmlTmpl = document.createElement("template");
1298
1302
  htmlTmpl.innerHTML = `
1299
1303
  <style>
1300
- @import "https://cdn.jsdelivr.net/npm/@ninebone/util@${"1.0.24"}/dist/css/nine-util.css";
1304
+ @import "https://cdn.jsdelivr.net/npm/@ninebone/util@${"1.0.26"}/dist/css/nine-util.css";
1301
1305
  ${customImport}
1302
1306
  </style>
1303
1307
  ${gripTmpl}
@@ -1825,6 +1829,9 @@ class NineUtil {
1825
1829
  }
1826
1830
  return null;
1827
1831
  });
1832
+ __publicField(this, "login", (provider) => {
1833
+ window.location.href = `${window.__API_BASE_URL__ || ""}/accounts/auth/${provider}/login`;
1834
+ });
1828
1835
  __publicField(this, "randomUUID", (num) => {
1829
1836
  if (!num) num = 10;
1830
1837
  const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";