Lab Work 1 (Checked)

This commit is contained in:
shadowik 2023-02-11 15:41:10 +04:00
parent e697f31215
commit b4d43bf16a
15 changed files with 1436 additions and 1 deletions

View File

@ -3,6 +3,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication @SpringBootApplication
@ -11,8 +12,35 @@ public class Demo1Application {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(Demo1Application.class, args); SpringApplication.run(Demo1Application.class, args);
} }
@GetMapping("/") @GetMapping("/hello")
public String hello(@RequestParam(value = "name", defaultValue = "World") String name) { public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
return String.format("Hello %s!", name); return String.format("Hello %s!", name);
} }
@GetMapping("/div")
@ResponseBody
public double Division(@RequestParam(defaultValue = "1") double a, @RequestParam(defaultValue = "1") double b) {
if (b == 0) return 0;
return a / b;
}
@GetMapping("/mul")
@ResponseBody
public double Multiply(@RequestParam(defaultValue = "1") double a, @RequestParam(defaultValue = "1") double b) {
return a * b;
}
@GetMapping("/pow")
@ResponseBody
public double Pow(@RequestParam(defaultValue = "1") double a,
@RequestParam(defaultValue = "1") double b) {
return Math.pow(a, b);
}
@GetMapping("/plus")
@ResponseBody
public double Plus(@RequestParam(defaultValue = "1") double a,
@RequestParam(defaultValue = "1") double b) {
return a + b;
}
} }

View File

@ -0,0 +1,13 @@
package com.example.demo;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfiguration implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedMethods("*");
}
}

28
untitled1/.gitignore vendored Normal file
View File

@ -0,0 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

29
untitled1/README.md Normal file
View File

@ -0,0 +1,29 @@
# untitled1
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
npm install
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Compile and Minify for Production
```sh
npm run build
```

13
untitled1/index.html Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>

1031
untitled1/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

20
untitled1/package.json Normal file
View File

@ -0,0 +1,20 @@
{
"name": "untitled1",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.2.45",
"vue-router": "^4.1.6",
"bootstrap": "^5.2.3",
"bootstrap-vue": "^2.23.1"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.0.0",
"vite": "^4.0.0"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

14
untitled1/src/App.vue Normal file
View File

@ -0,0 +1,14 @@
<script setup>
</script>
<template>
<router-view></router-view>
</template>
<style>
body {
background: rgb(221, 244, 251);
margin: 1%;
}
</style>

View File

@ -0,0 +1,74 @@
/* color palette from <https://github.com/vuejs/theme> */
:root {
--vt-c-white: #ffffff;
--vt-c-white-soft: #f8f8f8;
--vt-c-white-mute: #f2f2f2;
--vt-c-black: #181818;
--vt-c-black-soft: #222222;
--vt-c-black-mute: #282828;
--vt-c-indigo: #2c3e50;
--vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
--vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
--vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
--vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);
--vt-c-text-light-1: var(--vt-c-indigo);
--vt-c-text-light-2: rgba(60, 60, 60, 0.66);
--vt-c-text-dark-1: var(--vt-c-white);
--vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
}
/* semantic color variables for this project */
:root {
--color-background: var(--vt-c-white);
--color-background-soft: var(--vt-c-white-soft);
--color-background-mute: var(--vt-c-white-mute);
--color-border: var(--vt-c-divider-light-2);
--color-border-hover: var(--vt-c-divider-light-1);
--color-heading: var(--vt-c-text-light-1);
--color-text: var(--vt-c-text-light-1);
--section-gap: 160px;
}
@media (prefers-color-scheme: dark) {
:root {
--color-background: var(--vt-c-black);
--color-background-soft: var(--vt-c-black-soft);
--color-background-mute: var(--vt-c-black-mute);
--color-border: var(--vt-c-divider-dark-2);
--color-border-hover: var(--vt-c-divider-dark-1);
--color-heading: var(--vt-c-text-dark-1);
--color-text: var(--vt-c-text-dark-2);
}
}
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
position: relative;
font-weight: normal;
}
body {
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
transition: color 0.5s, background-color 0.5s;
line-height: 1.6;
font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
font-size: 15px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.76 226.69" xmlns:v="https://vecta.io/nano"><path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883"/><path d="M161.096.001l-30.225 52.351L100.647.001H52.346l78.526 136.01L209.398.001z" fill="#34495e"/></svg>

After

Width:  |  Height:  |  Size: 308 B

View File

@ -0,0 +1,35 @@
@import './base.css';
#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
font-weight: normal;
}
a,
.green {
text-decoration: none;
color: hsla(160, 100%, 37%, 1);
transition: 0.4s;
}
@media (hover: hover) {
a:hover {
background-color: hsla(160, 100%, 37%, 0.2);
}
}
@media (min-width: 1024px) {
body {
display: flex;
place-items: center;
}
#app {
display: grid;
grid-template-columns: 1fr 1fr;
padding: 0 2rem;
}
}

View File

@ -0,0 +1,114 @@
<template>
<form>
<div class="row data">
<div class="col">
<input v-model="val1" type="number" class="form-control" placeholder="First Value">
</div>
<div class="col">
<input v-model="val2" type="number" class="form-control" placeholder="Second Value">
</div>
</div>
<div class="d-flex justify-content-around">
<button v-on:click="div" class="btn btn-primary" type="button">Division</button>
<button v-on:click="pow" class="btn btn-primary" type="button">Power</button>
<button v-on:click="mul" class="btn btn-primary" type="button">Multiply</button>
<button v-on:click="sum" class="btn btn-primary" type="button">Plus</button>
</div>
<div class="row data">
<div class="col">
<input v-model = "res" type="text" class="form-control" placeholder="Result">
</div>
</div>
</form>
</template>
<script>
export default {
name: "Main",
data() {
return {
val1: 0,
val2: 0,
res: ""
}
},
methods: {
sum() {
let url = "http://localhost:8080/plus?a=" + this.val1.toString() + "&b=" + this.val2.toString();
let vm = this;
fetch(url)
.then(function (response) {
return response.json();
})
.then(function (data) {
console.info('Loaded');
console.log(data);
vm.res = data;
})
.catch(function (error) {
console.error('Error:', error);
throw "Can't load items";
});
},
pow() {
let url = "http://localhost:8080/pow?a=" + this.val1.toString() + "&b=" + this.val2.toString();
let vm = this;
fetch(url)
.then(function (response) {
return response.json();
})
.then(function (data) {
console.info('Loaded');
console.log(data);
vm.res = data;
})
.catch(function (error) {
console.error('Error:', error);
throw "Can't load items";
});
},
mul() {
let url = "http://localhost:8080/mul?a=" + this.val1.toString() + "&b=" + this.val2.toString();
let vm = this;
fetch(url)
.then(function (response) {
return response.json();
})
.then(function (data) {
console.info('Loaded');
console.log(data);
vm.res = data;
})
.catch(function (error) {
console.error('Error:', error);
throw "Can't load items";
});
},
div() {
let url = "http://localhost:8080/div?a=" + this.val1.toString() + "&b=" + this.val2.toString();
let vm = this;
fetch(url)
.then(function (response) {
return response.json();
})
.then(function (data) {
console.info('Loaded');
console.log(data);
vm.res = data;
})
.catch(function (error) {
console.error('Error:', error);
throw "Can't load items";
});
}
}
}
</script>
<style scoped>
.data {
padding: 1%;
}
</style>

21
untitled1/src/main.js Normal file
View File

@ -0,0 +1,21 @@
import { createApp } from 'vue'
import App from './App.vue'
import { createRouter, createWebHistory } from 'vue-router'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
import Main from "@/components/Main.vue";
const routes = [
{ path: '/', redirect: '/main' },
{ path: '/main', component: Main },
]
const router = createRouter({
history: createWebHistory(),
linkActiveClass: 'active',
routes
})
createApp(App).use(router).mount('#app')

14
untitled1/vite.config.js Normal file
View File

@ -0,0 +1,14 @@
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
})