前端新加页面

This commit is contained in:
房孝庭 2024-07-13 07:58:42 +08:00
parent a965975e5d
commit c43bd16131
15 changed files with 12425 additions and 0 deletions

23
src/前端/gitlink/.gitignore vendored Normal file
View File

@ -0,0 +1,23 @@
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

View File

@ -0,0 +1,24 @@
# gitlink
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

View File

@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}

View File

@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}
}

12017
src/前端/gitlink/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,47 @@
{
"name": "gitlink",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"axios": "^1.7.2",
"core-js": "^3.8.3",
"element-plus": "^2.7.4",
"router": "^1.3.8",
"vue": "^3.2.13",
"vue-router": "^4.3.2"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "@babel/eslint-parser"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead",
"not ie 11"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

View File

@ -0,0 +1,20 @@
<template>
<div id="app">
<router-view></router-view>
</div>
</template>
<script>
export default {
name: 'App'
}
</script>
<style>
#app {
font-family: Arial, sans-serif;
text-align: center;
margin-top: 20px;
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -0,0 +1,132 @@
<template>
<div class="top-right-button">
<el-button type="primary" @click="returnList()">返回</el-button>
</div>
<div class="user-feedback">
<!-- 输入评价 -->
<div class="feedback-input">
<h2>评论</h2>
<form @submit.prevent="send"> <!-- 阻止表单默认提交行为 -->
<textarea id="text" v-model.trim="evaluation.text" rows="4" cols="50"></textarea>
<br>
<label for="contact">联系方式(选填):</label>
<input type="text" id="contact" v-model="evaluation.contact">
<br>
<button type="submit">发布评价</button>
</form>
</div>
<el-space direction="vertical">
<el-row>
<el-text>留下您的评价</el-text>
<el-rate class="ml-1"
v-model="evaluation.score"
:texts="['oops', 'disappointed', 'normal', 'good', 'great']"
show-text
@change="handleRateChange"
clearable />
</el-row>
</el-space>
</div>
</template>
<script>
import axios from 'axios';
export default {
data() {
return {
evaluation: {
score: '',
text: '',
contact: '',
},
};
},
methods: {
send() {
axios.post('http://192.168.234.35:8080/addEvaluation', {
score: this.evaluation.score,
text: this.evaluation.text,
contact: this.evaluation.contact,
}, {
withCredentials: true,
headers: {
'Content-Type': 'application/json'
}
}).then(response => {
if (response.data == 1) {
console.log('评价发送成功');
this.evaluation.text = '';
this.evaluation.score = '';
this.evaluation.contact = '';
alert("发布成功");
}
}).catch(error => {
console.error('评价发送失败', error);
});
},
handleRateChange(score) {
this.evaluation.score = score; //
},
returnList(){
this.$router.push('/evalueationList')
}
},
};
</script>
<style scoped>
.user-feedback {
max-width: 600px;
margin: 0 auto;
position: relative;
}
.feedback-input {
margin-bottom: 40px;
}
textarea {
width: 100%;
padding: 8px;
font-size: 16px;
border: 1px solid #28a7a3;
border-radius: 4px;
margin-bottom: 10px;
}
button {
margin-top: 20px;
padding: 8px 16px;
font-size: 16px;
border: none;
border-radius: 4px;
background-color: #007bff;
color: #003f3f;
cursor: pointer;
}
.submitted-feedback {
border-top: 1px solid #a6cfee;
padding-top: 20px;
}
.feedback-item {
background-color: #abd4ee;
border: 1px solid #c2f1fb;
border-radius: 4px;
padding: 10px;
}
.top-right-button {
/* 绝对定位到右上角 */
position: absolute;
top: 1px; /* 根据需要调整 */
left: 10px; /* 根据需要调整 */
}
.feedback-item p {
margin: 0;
}
</style>

View File

@ -0,0 +1,91 @@
<template>
<div>
<h2>评论列表</h2>
<div
v-for="comment in comments"
:key="comment.text"
class="comment-item"
>
<p>{{ comment.text }}</p>
<!-- <p>评分: {{ comment.score }}</p> -->
</div>
<div class="post-comment-button-container">
<button class='post-comment-button' @click="navigateToPostCommentPage">发表评论</button> <!-- 移除括号因为这里不是调用方法 -->
</div>
</div>
</template>
<script>
import axios from 'axios'; // refonMounted使
export default {
data() {
return {
comments: [],
};
},
methods: {
navigateToPostCommentPage() {
this.$router.push('/Feedback');
},
},
async created() { // createdasynccreated
try {
const response = await axios.get(`http://192.168.234.35:8080/evaluationList`);
this.comments = response.data;
} catch (error) {
console.error('Error fetching comments:', error);
}
},
};
</script>
<style scoped>
.user-feedback {
/* 添加一个最大宽度或容器样式 */
max-width: 800px;
margin: 0 auto; /* 水平居中 */
padding: 20px; /* 添加外边距 */
}
.comment-item {
border: 1px solid #ddd; /* 添加边框 */
padding: 10px; /* 添加内边距 */
margin-bottom: 10px; /* 添加下边距,以分隔评论 */
border: 1px solid #ddd;
background-color: #f5f5f5; /* 添加背景色 */
padding: 15px;
margin-bottom: 20px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); /* 添加阴影效果 */
border-radius: 5px; /* 添加圆角 */
}
.comment-item p {
/* 可以添加字体样式,如字体大小、颜色等 */
font-size: 16px;
color: #333;
}
.post-comment-button-container {
position: fixed;
bottom: 20px; /* 距离页面底部的距离 */
right: 20px; /* 距离页面右侧的距离,可以根据需要调整 */
z-index: 999; /* 确保按钮在其他内容之上 */
display: flex;
justify-content: center; /* 水平居中按钮 */
align-items: center; /* 垂直居中按钮如果按钮容器是flex容器 */
transition: bottom 0.3s ease;
}
.post-comment-button {
padding: 10px 20px;
font-size: 16px;
border: none;
background-color: #4CAF50;
color: white;
justify-content: center;
cursor: pointer;
transition: background-color 0.3s ease; /* 添加背景色过渡效果 */
}
.post-comment-button:hover{
background-color: #55ff00;
}
</style>

View File

@ -0,0 +1,10 @@
import { createApp } from 'vue'
import router from './router';
import ElementPlus from 'element-plus'
import 'element-plus/theme-chalk/index.css';
import App from './App.vue'
const app = createApp(App)
app.use(ElementPlus)
app.use(router)
app.mount('#app')

View File

@ -0,0 +1,16 @@
import { createWebHistory, createRouter } from 'vue-router';
import UserFeedback from '../components/UserFeedback.vue'
import evalueationList from '../components/evalueationList.vue'
const routes = [
{ path: '/', redirect: '/evalueationList' }, // 重定向到/login路径
{ path: '/Feedback', component: UserFeedback },
{ path: '/evalueationList', component: evalueationList },
];
const router = createRouter({
history: createWebHistory(),
routes
});
export default router;

View File

@ -0,0 +1,4 @@
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true
})