diff --git a/luckydiamond/src/assets/js/AuthService.js b/luckydiamond/src/assets/js/AuthService.js deleted file mode 100644 index e69de29..0000000 diff --git a/luckydiamond/src/assets/js/authentication/AuthService.js b/luckydiamond/src/assets/js/authentication/AuthService.js new file mode 100644 index 0000000..981fa8d --- /dev/null +++ b/luckydiamond/src/assets/js/authentication/AuthService.js @@ -0,0 +1,12 @@ +import { Post } from '../rest/RestMethods.js'; +import { BackendApiUrl } from '@/properties/Сonfig.js'; + +export function + LogIn(authCode) { + return Post(BackendApiUrl + "/LogIn", { code: authCode }).then((data) => { + console.log(data); + return data; + }).catch(error => { + console.log(error) + }); +} diff --git a/luckydiamond/src/assets/js/authentication/LoggingMiddleware.js b/luckydiamond/src/assets/js/authentication/LoggingMiddleware.js new file mode 100644 index 0000000..88a54a1 --- /dev/null +++ b/luckydiamond/src/assets/js/authentication/LoggingMiddleware.js @@ -0,0 +1,10 @@ +export function + GetAuthCodeFromCurrentPath() { + const currentPath = window.location.pathname; + + const parts = currentPath.split('/'); + + const code = parts[parts.length - 1]; + + return code; +} diff --git a/luckydiamond/src/assets/js/rest/RestMethods.js b/luckydiamond/src/assets/js/rest/RestMethods.js new file mode 100644 index 0000000..5178026 --- /dev/null +++ b/luckydiamond/src/assets/js/rest/RestMethods.js @@ -0,0 +1,21 @@ +export async function Post(url = "", data = {}) { + // Default options are marked with * + try { + const response = await fetch(url, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + redirect: "follow", + referrerPolicy: "no-referrer", + body: JSON.stringify(data), + }); + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + return await response.json(); + } catch (error) { + console.log("Fetch error:", error); + throw error; // Re-throw the error so it can be caught by the calling function + } +} \ No newline at end of file diff --git a/luckydiamond/src/components/HeaderComponent.vue b/luckydiamond/src/components/HeaderComponent.vue index ab00b4d..133bf6b 100644 --- a/luckydiamond/src/components/HeaderComponent.vue +++ b/luckydiamond/src/components/HeaderComponent.vue @@ -1,6 +1,7 @@ diff --git a/luckydiamond/src/properties/Сonfig.js b/luckydiamond/src/properties/Сonfig.js new file mode 100644 index 0000000..859cd6f --- /dev/null +++ b/luckydiamond/src/properties/Сonfig.js @@ -0,0 +1,2 @@ +// export const BackendApiUrl = 'https://spsystemcore20231122004605.azurewebsites.net'; +export const BackendApiUrl = 'https://localhost:7062'; \ No newline at end of file diff --git a/luckydiamond/vue.config.js b/luckydiamond/vue.config.js index 306897b..07978e9 100644 --- a/luckydiamond/vue.config.js +++ b/luckydiamond/vue.config.js @@ -6,6 +6,22 @@ // : '/' // } +// module.exports = { +// publicPath: '/' +// } + +const path = require('path'); + module.exports = { - publicPath: '/' -} \ No newline at end of file + // Установка базового URL-адреса для проекта + publicPath: '/', + + // Настройка Webpack + configureWebpack: { + resolve: { + alias: { + '@': path.resolve(__dirname, 'src/'), // Настройка алиаса '@' для каталога 'src/' + } + } + } +};