Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
dd9d2b9bcd | |||
70d597ce77 | |||
b4d43bf16a |
@ -3,6 +3,7 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@SpringBootApplication
|
||||
@ -11,8 +12,35 @@ public class Demo1Application {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Demo1Application.class, args);
|
||||
}
|
||||
@GetMapping("/")
|
||||
public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
|
||||
return String.format("Hello %s!", name);
|
||||
}
|
||||
// @GetMapping("/hello")
|
||||
// public String hello(@RequestParam(value = "name", defaultValue = "World") String 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;
|
||||
// }
|
||||
}
|
13
src/main/java/com/example/demo/WebConfiguration.java
Normal file
13
src/main/java/com/example/demo/WebConfiguration.java
Normal 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("*");
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.example.demo.speaker.configuration;
|
||||
|
||||
import com.example.demo.speaker.domain.IMethods;
|
||||
import com.example.demo.speaker.domain.MethodInteger;
|
||||
import com.example.demo.speaker.domain.MethodString;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class MethodConfiguration {
|
||||
@Bean(value = "int")
|
||||
public MethodInteger createIntegerMethods() {
|
||||
return new MethodInteger();
|
||||
}
|
||||
|
||||
@Bean(value = "string")
|
||||
public MethodString createStringMethods() {
|
||||
return new MethodString();
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.example.demo.speaker.controller;
|
||||
|
||||
import com.example.demo.speaker.service.MethodService;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import java.io.Console;
|
||||
|
||||
@RestController
|
||||
public class MethodController {
|
||||
private final MethodService methodService;
|
||||
|
||||
public MethodController(MethodService methodService) {
|
||||
this.methodService = methodService;
|
||||
}
|
||||
|
||||
@GetMapping("/sum")
|
||||
@ResponseBody
|
||||
public Object sum(@RequestParam(value = "first", defaultValue = "0") Object first,
|
||||
@RequestParam(value = "second", defaultValue = "0") Object second,
|
||||
@RequestParam(value = "type", defaultValue = "int") String type) {
|
||||
return methodService.Sum(first, second, type);
|
||||
}
|
||||
|
||||
@GetMapping("/mul")
|
||||
@ResponseBody
|
||||
public Object mul(@RequestParam(value = "first", defaultValue = "0") Object first,
|
||||
@RequestParam(value = "second", defaultValue = "0") Object second,
|
||||
@RequestParam(value = "type", defaultValue = "int") String type) {
|
||||
return methodService.Multiply(first, second, type);
|
||||
}
|
||||
|
||||
@GetMapping("/minus")
|
||||
@ResponseBody
|
||||
public Object minus(@RequestParam(value = "first", defaultValue = "0") Object first,
|
||||
@RequestParam(value = "second", defaultValue = "0") Object second,
|
||||
@RequestParam(value = "type", defaultValue = "int") String type) {
|
||||
return methodService.Minus(first, second, type);
|
||||
}
|
||||
|
||||
@GetMapping("/cont")
|
||||
@ResponseBody
|
||||
public Object cont(@RequestParam(value = "first", defaultValue = "0") Object first,
|
||||
@RequestParam(value = "second", defaultValue = "0") Object second,
|
||||
@RequestParam(value = "type", defaultValue = "int") String type) {
|
||||
return methodService.Contains(first, second, type).toString();
|
||||
}
|
||||
|
||||
}
|
12
src/main/java/com/example/demo/speaker/domain/IMethods.java
Normal file
12
src/main/java/com/example/demo/speaker/domain/IMethods.java
Normal file
@ -0,0 +1,12 @@
|
||||
package com.example.demo.speaker.domain;
|
||||
|
||||
public interface IMethods<T> {
|
||||
T Sum(T first, T second);
|
||||
|
||||
T Multiply(T first, T second);
|
||||
|
||||
T Minus(T first, T second);
|
||||
|
||||
Boolean Contains(T first, T second);
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.example.demo.speaker.domain;
|
||||
|
||||
public class MethodInteger implements IMethods<Integer> {
|
||||
@Override
|
||||
public Integer Sum(Integer first, Integer second) {
|
||||
return first + second;
|
||||
}
|
||||
@Override
|
||||
public Integer Multiply(Integer first, Integer second) {
|
||||
return first * second;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer Minus(Integer first, Integer second) {
|
||||
return first - second;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean Contains(Integer first, Integer second) {
|
||||
return Integer.toString(first).contains(Integer.toString(second));
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.example.demo.speaker.domain;
|
||||
|
||||
public class MethodString implements IMethods<String>{
|
||||
@Override
|
||||
public String Sum(String first, String second) {
|
||||
return first.concat(second);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String Multiply(String first, String second) {
|
||||
String res = first;
|
||||
for (int i = 0; i < Integer.parseInt(second) - 1; i++) {
|
||||
res = Sum(res, first);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String Minus(String first, String second) {
|
||||
if (Contains(first, second)) {
|
||||
return first.replace(second, "");
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean Contains(String first, String second) {
|
||||
return first.contains(second);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.example.demo.speaker.service;
|
||||
|
||||
import com.example.demo.speaker.domain.IMethods;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
@Service
|
||||
public class MethodService {
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
public MethodService(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
public Object Sum(Object first, Object second, String type) {
|
||||
final IMethods method = (IMethods) applicationContext.getBean(type);
|
||||
return calculate((x, y) -> method.Sum(x, y), type, first, second);
|
||||
}
|
||||
|
||||
public Object Multiply(Object first, Object second, String type) {
|
||||
final IMethods method = (IMethods) applicationContext.getBean(type);
|
||||
return calculate((x, y) -> method.Multiply(x, y), type, first, second);
|
||||
}
|
||||
|
||||
public Object Minus(Object first, Object second, String type) {
|
||||
final IMethods method = (IMethods) applicationContext.getBean(type);
|
||||
return calculate((x, y) -> method.Minus(x, y), type, first, second);
|
||||
}
|
||||
|
||||
public Object Contains(Object first, Object second, String type) {
|
||||
final IMethods method = (IMethods) applicationContext.getBean(type);
|
||||
return calculate((x, y) -> method.Contains(x, y), type, first, second);
|
||||
}
|
||||
|
||||
private Object calculate(BiFunction<Object, Object, Object> methodCalc, String type, Object a, Object b) {
|
||||
switch (type) {
|
||||
case "int":
|
||||
return methodCalc.apply(Integer.parseInt(a.toString()), Integer.parseInt(b.toString()));
|
||||
case "string":
|
||||
return methodCalc.apply(a.toString(), b.toString());
|
||||
default:
|
||||
throw new IllegalArgumentException("Type not found");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +1,74 @@
|
||||
package com.example.demo;
|
||||
|
||||
import com.example.demo.speaker.service.MethodService;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class Demo1ApplicationTests {
|
||||
|
||||
@Autowired
|
||||
MethodService methodService;
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
void testMethodSumInt() {
|
||||
final Object res = methodService.Sum(1, 2, "int");
|
||||
Assertions.assertEquals(3, res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodSumString() {
|
||||
final Object res = methodService.Sum("1", "2", "string");
|
||||
Assertions.assertEquals("12", res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodMinusInt() {
|
||||
final Object res = methodService.Minus(1, 2, "int");
|
||||
Assertions.assertEquals(-1, res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodMinusString() {
|
||||
final Object res = methodService.Minus("214324", "4", "string");
|
||||
Assertions.assertEquals("2132", res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodMultInt() {
|
||||
final Object res = methodService.Multiply(1, 2, "int");
|
||||
Assertions.assertEquals(2, res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodMultString() {
|
||||
final Object res = methodService.Multiply("1", "2", "string");
|
||||
Assertions.assertEquals("11", res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodContainsInt() {
|
||||
final Object res = methodService.Contains(123, 2, "int");
|
||||
Assertions.assertEquals(true, res);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodContainsString() {
|
||||
final Object res = methodService.Contains("1", "2", "string");
|
||||
Assertions.assertEquals(false, res);
|
||||
}
|
||||
|
||||
@Test()
|
||||
void testErrorWrongType() {
|
||||
try {
|
||||
final Object res = methodService.Sum(1, "ds", "int");
|
||||
Assertions.fail();
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
28
untitled1/.gitignore
vendored
Normal file
28
untitled1/.gitignore
vendored
Normal 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
29
untitled1/README.md
Normal 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
13
untitled1/index.html
Normal 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>
|
1034
untitled1/package-lock.json
generated
Normal file
1034
untitled1/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
23
untitled1/package.json
Normal file
23
untitled1/package.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"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"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.18.0 || >=16.0.0"
|
||||
}
|
||||
}
|
BIN
untitled1/public/favicon.ico
Normal file
BIN
untitled1/public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
14
untitled1/src/App.vue
Normal file
14
untitled1/src/App.vue
Normal file
@ -0,0 +1,14 @@
|
||||
<script setup>
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<router-view></router-view>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
body {
|
||||
background: rgb(221, 244, 251);
|
||||
margin: 1%;
|
||||
}
|
||||
</style>
|
74
untitled1/src/assets/base.css
Normal file
74
untitled1/src/assets/base.css
Normal 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;
|
||||
}
|
1
untitled1/src/assets/logo.svg
Normal file
1
untitled1/src/assets/logo.svg
Normal 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 |
35
untitled1/src/assets/main.css
Normal file
35
untitled1/src/assets/main.css
Normal 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;
|
||||
}
|
||||
}
|
124
untitled1/src/components/Main.vue
Normal file
124
untitled1/src/components/Main.vue
Normal file
@ -0,0 +1,124 @@
|
||||
<template>
|
||||
<form>
|
||||
<div class="row data">
|
||||
<div class="col">
|
||||
<input v-model="val1" type="text" class="form-control" placeholder="First Value">
|
||||
</div>
|
||||
<div class="col">
|
||||
<input v-model="val2" type="text" class="form-control" placeholder="Second Value">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row data">
|
||||
<select v-model="type" class="form-select" aria-label="Default select example">
|
||||
<option value="int">Integer</option>
|
||||
<option value="string">String</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="d-flex justify-content-around">
|
||||
<button v-on:click="minus" class="btn btn-primary" type="button">Minus</button>
|
||||
<button v-on:click="Contains" class="btn btn-primary" type="button">Contains</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">Sum</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: "",
|
||||
val2: "",
|
||||
type: "int",
|
||||
res: ""
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
sum() {
|
||||
let url = "http://localhost:8080/sum?first=" + this.val1 + "&second=" + this.val2 + "&type=" + this.type;
|
||||
let vm = this;
|
||||
console.log(url);
|
||||
fetch(url)
|
||||
.then(function (response) {
|
||||
return response.text();
|
||||
})
|
||||
.then(function (data) {
|
||||
console.info('Loaded');
|
||||
console.log(data);
|
||||
vm.res = data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error('Error:', error);
|
||||
throw "Can't load items";
|
||||
});
|
||||
},
|
||||
Contains() {
|
||||
let url = "http://localhost:8080/cont?first=" + this.val1 + "&second=" + this.val2 + "&type=" + this.type;
|
||||
let vm = this;
|
||||
fetch(url)
|
||||
.then(function (response) {
|
||||
return response.text();
|
||||
})
|
||||
.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?first=" + this.val1 + "&second=" + this.val2 + "&type=" + this.type;
|
||||
let vm = this;
|
||||
console.log(url);
|
||||
fetch(url)
|
||||
.then(function (response) {
|
||||
return response.text();
|
||||
})
|
||||
.then(function (data) {
|
||||
console.info('Loaded');
|
||||
console.log(data);
|
||||
vm.res = data;
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error('Error:', error);
|
||||
throw "Can't load items";
|
||||
});
|
||||
},
|
||||
minus() {
|
||||
let url = "http://localhost:8080/minus?first=" + this.val1 + "&second=" + this.val2 + "&type=" + this.type;
|
||||
let vm = this;
|
||||
console.log(url);
|
||||
fetch(url)
|
||||
.then(function (response) {
|
||||
return response.text();
|
||||
})
|
||||
.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
21
untitled1/src/main.js
Normal 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
14
untitled1/vite.config.js
Normal 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))
|
||||
}
|
||||
}
|
||||
})
|
Loading…
Reference in New Issue
Block a user