整理

上级 32dc6d23
...@@ -13,10 +13,10 @@ ...@@ -13,10 +13,10 @@
</el-header> </el-header>
<el-main> <el-main>
<el-table :data="userlist" v-loading="loading"> <el-table border :data="userlist" v-loading="loading">
<el-table-column prop="id" label="序号" width="50"></el-table-column> <el-table-column prop="id" label="序号" width="50" sortable></el-table-column>
<el-table-column prop="question" label="问题" width="240"></el-table-column> <el-table-column prop="question" label="问题" width="240" show-overflow-tooltip></el-table-column>
<el-table-column prop="response" label="答案"></el-table-column> <el-table-column prop="response" label="答案" show-overflow-tooltip></el-table-column>
<el-table-column label="创建时间" width="170"> <el-table-column label="创建时间" width="170">
<template slot-scope="props"> <template slot-scope="props">
{{ props.row.createTime | dateFormat }} {{ props.row.createTime | dateFormat }}
...@@ -55,7 +55,7 @@ export default { ...@@ -55,7 +55,7 @@ export default {
loading: false, loading: false,
elementui_page_component_key: 0, elementui_page_component_key: 0,
currentPage: Number(localStorage.getItem('lastPage')) || 1, currentPage: Number(localStorage.getItem('lastPage')) || 1,
pageSize: 5, pageSize: 14,
total: 0, total: 0,
}; };
}, },
......
...@@ -31,27 +31,27 @@ ...@@ -31,27 +31,27 @@
<script> <script>
export default { export default {
name: 'MyUser', name: "MyUser",
data() { data() {
return { return {
// 用户列表数据 // 用户列表数据
userlist: [ userlist: [
{ id: 1, name: '嬴政', age: 18, position: '始皇帝' }, { id: 1, name: "嬴政", age: 18, position: "始皇帝" },
{ id: 2, name: '李斯', age: 35, position: '丞相' }, { id: 2, name: "李斯", age: 35, position: "丞相" },
{ id: 3, name: '吕不韦', age: 50, position: '商人' }, { id: 3, name: "吕不韦", age: 50, position: "商人" },
{ id: 4, name: '赵姬', age: 48, position: '王太后' } { id: 4, name: "赵姬", age: 48, position: "王太后" },
] ],
} };
}, },
methods: { methods: {
gotoDetail(id) { gotoDetail(id) {
// /home/userinfo/1 // /home/userinfo/1
// /home/userinfo/2 // /home/userinfo/2
// /home/userinfo/3 // /home/userinfo/3
this.$router.push('/home/userinfo/' + id) this.$router.push("/home/userinfo/" + id);
} },
} },
} };
</script> </script>
<style lang="less" scoped></style> <style lang="less" scoped></style>
\ No newline at end of file
<template> <template>
<div> <div>
<el-button @click="$router.back()">后退</el-button> <el-button @click="$router.back()">后退</el-button>
<h4 class="text-center">ChatGpt问答详情 --- {{ id }}</h4> <h4 class="text-center">ChatGpt问答详情 --- {{ id }}</h4>
<el-container> <el-container>
<el-main> <el-main>
<el-table :data="list"> <el-table border :data="list">
<el-table-column label="序号" width="50"> <el-table-column label="序号" width="50">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.id }}</span> <span>{{ scope.row.id }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="问题" width="240"> <el-table-column label="问题" width="240">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.question }}</span> <span>{{ scope.row.question }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="回答"> <el-table-column label="回答">
<template slot-scope="scope"> <template slot-scope="scope">
<span id="td-response">{{ scope.row.response }}</span> <span id="td-response">{{ scope.row.response }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="创建时间" width="170"> <el-table-column label="创建时间" width="170">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.createTime | dateFormat }}</span> <span>{{ scope.row.createTime | dateFormat }}</span>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-main> </el-main>
</el-container> </el-container>
<div class="button-container"> <div class="button-container">
<el-button @click="copyCode">复制回答</el-button> <el-button @click="copyCode">复制回答</el-button>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
// 导入 axios 请求库 // 导入 axios 请求库
import axios from "axios"; import axios from 'axios';
export default { export default {
name: "MyChatDetail", name: 'MyChatDetail',
props: ["id"], props: ['id'],
data() { data() {
return { return {
list: [], list: [],
}; };
},
created() {
// 调用请求数据的方法
this.initChatList();
},
methods: {
// // 封装请求列表数据的方法
async initChatList() {
// 调用 axios 的 get 方法,请求列表数据
const { data: res } = await axios.get(
"http://120.79.36.53:8888/chatbot/" + this.id
);
// 只要请求回来的数据,在页面渲染期间要用到,则必须转存到 data 中
if (res.code === 200) {
this.list = [
{
id: res.result.id,
question: res.result.question,
response: res.result.response,
createTime: res.result.createTime,
},
];
}
}, },
copyCode() { created() {
const codeBlock = document.getElementById("td-response"); // 调用请求数据的方法
const range = document.createRange(); this.initChatList();
range.selectNode(codeBlock); },
const selection = window.getSelection(); methods: {
selection.removeAllRanges(); // // 封装请求列表数据的方法
selection.addRange(range); async initChatList() {
document.execCommand("copy"); // 调用 axios 的 get 方法,请求列表数据
selection.removeAllRanges(); const { data: res } = await axios.get('http://120.79.36.53:8888/chatbot/' + this.id);
this.$message.success("代码已复制到剪贴板"); // 只要请求回来的数据,在页面渲染期间要用到,则必须转存到 data 中
if (res.code === 200) {
this.list = [
{
id: res.result.id,
question: res.result.question,
response: res.result.response,
createTime: res.result.createTime,
},
];
}
},
copyCode() {
const codeBlock = document.getElementById('td-response');
const range = document.createRange();
range.selectNode(codeBlock);
const selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
document.execCommand('copy');
selection.removeAllRanges();
this.$message.success('代码已复制到剪贴板');
},
}, },
},
}; };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
.button-container { .button-container {
position: fixed; position: fixed;
bottom: 0; bottom: 0;
right: 0; right: 0;
margin: 16px; margin: 16px;
} }
</style> </style>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册