整理

上级 bdcd31ec
{
"printWidth": 800,
"tabWidth": 2,
"useTabs": true,
"semi": false,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"jsxBracketSameLine": true,
"arrowParens": "always",
"requirePragma": false,
"insertPragma": false,
"htmlWhitespaceSensitivity": "ignore",
"vueIndentScriptAndStyle": false,
"endOfLine": "lf",
"embeddedLanguageFormatting": "auto",
"prettier.proseWrap": "preserve",
"vetur.format.defaultFormatter.js": "prettier"
}
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<script> <script>
export default { export default {
name: 'MyApp' name: 'MyApp',
} }
</script> </script>
......
此差异已折叠。
...@@ -21,17 +21,17 @@ ...@@ -21,17 +21,17 @@
<script> <script>
// 头部区域组件 // 头部区域组件
import MyHeader from "./subcomponents/MyHeader.vue"; import MyHeader from './subcomponents/MyHeader.vue'
// 左侧边栏组件 // 左侧边栏组件
import MyAside from "./subcomponents/MyAside.vue"; import MyAside from './subcomponents/MyAside.vue'
export default { export default {
name: "MyHome", name: 'MyHome',
// 注册组件 // 注册组件
components: { components: {
MyHeader, MyHeader,
MyAside, MyAside,
}, },
}; }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
......
...@@ -11,25 +11,12 @@ ...@@ -11,25 +11,12 @@
<!-- 登录名称 --> <!-- 登录名称 -->
<div class="form-group form-inline"> <div class="form-group form-inline">
<label for="username">登录名称</label> <label for="username">登录名称</label>
<input <input type="text" class="form-control ml-2" id="username" placeholder="请输入登录名称" autocomplete="off" v-model.trim="username" />
type="text"
class="form-control ml-2"
id="username"
placeholder="请输入登录名称"
autocomplete="off"
v-model.trim="username"
/>
</div> </div>
<!-- 登录密码 --> <!-- 登录密码 -->
<div class="form-group form-inline"> <div class="form-group form-inline">
<label for="password">登录密码</label> <label for="password">登录密码</label>
<input <input type="password" class="form-control ml-2" id="password" placeholder="请输入登录密码" v-model.trim="password" />
type="password"
class="form-control ml-2"
id="password"
placeholder="请输入登录密码"
v-model.trim="password"
/>
</div> </div>
<!-- 登录和重置按钮 --> <!-- 登录和重置按钮 -->
<div class="form-group form-inline d-flex justify-content-end"> <div class="form-group form-inline d-flex justify-content-end">
...@@ -47,7 +34,7 @@ export default { ...@@ -47,7 +34,7 @@ export default {
data() { data() {
return { return {
username: '', username: '',
password: '' password: '',
} }
}, },
methods: { methods: {
...@@ -66,8 +53,8 @@ export default { ...@@ -66,8 +53,8 @@ export default {
// 登录失败 // 登录失败
localStorage.removeItem('token') localStorage.removeItem('token')
} }
} },
} },
} }
</script> </script>
......
...@@ -4,40 +4,19 @@ ...@@ -4,40 +4,19 @@
<el-main> <el-main>
<el-form :inline="true" :model="formInline" class="demo-form-inline"> <el-form :inline="true" :model="formInline" class="demo-form-inline">
<el-form-item label="问题"> <el-form-item label="问题">
<el-input <el-input clearable v-model="formInline.question" placeholder="请输入问题" @keydown.enter.native="initCartList"></el-input>
clearable
v-model="formInline.question"
placeholder="请输入问题"
@keydown.enter.native="initCartList"
></el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="initCartList">查询</el-button> <el-button type="primary" @click="initCartList">查询</el-button>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click.prevent="addChat"> <el-button type="primary" @click.prevent="addChat">新增</el-button>
新增
</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table border :data="userlist" v-loading="loading"> <el-table border :data="userlist" v-loading="loading">
<el-table-column <el-table-column prop="id" label="序号" width="100" sortable></el-table-column>
prop="id" <el-table-column prop="question" label="问题" width="240" show-overflow-tooltip></el-table-column>
label="序号" <el-table-column prop="response" label="答案" show-overflow-tooltip></el-table-column>
width="100"
sortable
></el-table-column>
<el-table-column
prop="question"
label="问题"
width="240"
show-overflow-tooltip
></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 }}
...@@ -45,26 +24,12 @@ ...@@ -45,26 +24,12 @@
</el-table-column> </el-table-column>
<el-table-column prop="详情" label="详情" width="180"> <el-table-column prop="详情" label="详情" width="180">
<template slot-scope="props"> <template slot-scope="props">
<el-button <el-button type="success" @click.prevent="gotoDetail(props.row.id)">详情</el-button>
type="success" <el-button type="danger" @click="onDelete(props.row.id)">删除</el-button>
@click.prevent="gotoDetail(props.row.id)"
>详情
</el-button>
<el-button type="danger" @click="onDelete(props.row.id)"
>删除</el-button
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-pagination <el-pagination class="pagination" background :key="elementui_page_component_key" :current-page.sync="currentPage" :page-size="pageSize" :total="total" @current-change="handleCurrentChange"></el-pagination>
class="pagination"
background
:key="elementui_page_component_key"
:current-page.sync="currentPage"
:page-size="pageSize"
:total="total"
@current-change="handleCurrentChange"
></el-pagination>
</el-main> </el-main>
<el-backtop class="backtop"></el-backtop> <el-backtop class="backtop"></el-backtop>
</el-container> </el-container>
...@@ -72,9 +37,9 @@ ...@@ -72,9 +37,9 @@
</template> </template>
<script> <script>
import axios from "axios"; import axios from 'axios'
export default { export default {
name: "MyChat", name: 'MyChat',
data() { data() {
return { return {
...@@ -82,96 +47,90 @@ export default { ...@@ -82,96 +47,90 @@ export default {
userlist: [], userlist: [],
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: 10, pageSize: 10,
total: 0, total: 0,
formInline: { formInline: {
question: "", question: '',
}, },
}; }
}, },
watch: { watch: {
"formInline.question"(newVal) { 'formInline.question'(newVal) {
if (newVal === "") { if (newVal === '') {
this.currentPage = 1; this.currentPage = 1
localStorage.setItem("lastPage", this.currentPage); localStorage.setItem('lastPage', this.currentPage)
this.initCartList(); this.initCartList()
} }
}, },
}, },
created() { created() {
this.$nextTick(() => { this.$nextTick(() => {
const foo = this.$route.query.back; const foo = this.$route.query.back
const add = this.$route.query.add; const add = this.$route.query.add
if (foo === "back" && add != "add") { if (foo === 'back' && add != 'add') {
this.currentPage = Number(localStorage.getItem("lastPage")) || 1; this.currentPage = Number(localStorage.getItem('lastPage')) || 1
this.formInline.question = localStorage.getItem("lastQuestion") || ""; this.formInline.question = localStorage.getItem('lastQuestion') || ''
} else { } else {
localStorage.setItem("lastPage", 1); localStorage.setItem('lastPage', 1)
localStorage.setItem("lastQuestion", ""); localStorage.setItem('lastQuestion', '')
this.currentPage = 1; this.currentPage = 1
this.formInline.question = ""; this.formInline.question = ''
} }
// 调用请求数据的方法 // 调用请求数据的方法
this.initCartList(); this.initCartList()
}); })
}, },
mounted() { mounted() {
this.currentPage = Number(localStorage.getItem("lastPage")) || 1; this.currentPage = Number(localStorage.getItem('lastPage')) || 1
this.formInline.question = localStorage.getItem("lastQuestion"); this.formInline.question = localStorage.getItem('lastQuestion')
this.elementui_page_component_key++; this.elementui_page_component_key++
}, },
methods: { methods: {
async onDelete(id) { async onDelete(id) {
this.loading = true; this.loading = true
const { data: res } = await axios.get( const { data: res } = await axios.get('http://120.79.36.53:8888/chatbot/delete', {
"http://120.79.36.53:8888/chatbot/delete",
{
params: { params: {
id: id, id: id,
}, },
} })
); this.initCartList()
this.initCartList(); this.loading = false
this.loading = false;
}, },
refreshPage() { refreshPage() {
location.reload(); location.reload()
}, },
gotoDetail(id) { gotoDetail(id) {
this.$router.push("/home/chatinfo/" + id); this.$router.push('/home/chatinfo/' + id)
}, },
addChat() { addChat() {
this.$router.push("/home/addChat/"); this.$router.push('/home/addChat/')
}, },
async initCartList() { async initCartList() {
this.loading = true; this.loading = true
const { data: res } = await axios.get( const { data: res } = await axios.get('http://120.79.36.53:8888/chatbot/page', {
"http://120.79.36.53:8888/chatbot/page",
{
params: { params: {
page: this.currentPage, page: this.currentPage,
pageSize: this.pageSize, pageSize: this.pageSize,
question: this.formInline.question, question: this.formInline.question,
}, },
} })
);
if (res.code === 200) { if (res.code === 200) {
this.userlist = res.result.records; this.userlist = res.result.records
this.total = res.result.total; this.total = res.result.total
localStorage.setItem("lastPage", this.currentPage); localStorage.setItem('lastPage', this.currentPage)
localStorage.setItem("lastQuestion", this.formInline.question); localStorage.setItem('lastQuestion', this.formInline.question)
} }
this.loading = false; this.loading = false
}, },
handleCurrentChange(currentPage) { handleCurrentChange(currentPage) {
this.currentPage = currentPage; this.currentPage = currentPage
this.initCartList(); this.initCartList()
}, },
}, },
}; }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
......
...@@ -31,27 +31,24 @@ ...@@ -31,27 +31,24 @@
<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 this.$router.push('/home/userinfo/' + id)
// /home/userinfo/2
// /home/userinfo/3
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>
<el-menu <el-menu default-active="$route.path" class="layout-aside-container" background-color="#fff" text-color="#000" active-text-color="#42b983">
default-active="$route.path"
class="layout-aside-container"
background-color="#fff"
text-color="#000"
active-text-color="#42b983"
>
<router-link to="/home/users"> <router-link to="/home/users">
<el-menu-item index="/users" class="left-aside-item"> <el-menu-item index="/users" class="left-aside-item">
<i class="el-icon-user"></i> <i class="el-icon-user"></i>
...@@ -45,7 +39,7 @@ ...@@ -45,7 +39,7 @@
</el-menu> </el-menu>
</template> </template>
<script> <script>
export default {name: 'MyAside'}; export default { name: 'MyAside' }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
......
...@@ -3,18 +3,14 @@ ...@@ -3,18 +3,14 @@
<!-- 左侧 logo 和 标题区域 --> <!-- 左侧 logo 和 标题区域 -->
<div class="layout-header-left d-flex align-items-center user-select-none"> <div class="layout-header-left d-flex align-items-center user-select-none">
<!-- logo --> <!-- logo -->
<img class="layout-header-left-img" src="../../assets/kwan.png" alt=""/> <img class="layout-header-left-img" src="../../assets/kwan.png" alt="" />
<!-- 标题 --> <!-- 标题 -->
<h4 class="layout-header-left-title ml-3">kwan的解忧杂货铺</h4> <h4 class="layout-header-left-title ml-3">kwan的解忧杂货铺</h4>
</div> </div>
<el-row> <el-row>
<el-col :inline="true" :span="24"> <el-col :inline="true" :span="24">
<el-button class="el-button-header" type="success" round @click="myHome"> <el-button class="el-button-header" type="success" round @click="myHome">我的主页</el-button>
我的主页 <el-button class="el-button-header" type="primary" round @click="logout">退出登录</el-button>
</el-button>
<el-button class="el-button-header" type="primary" round @click="logout">
退出登录
</el-button>
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
...@@ -22,22 +18,22 @@ ...@@ -22,22 +18,22 @@
<script> <script>
export default { export default {
name: "MyHeader", name: 'MyHeader',
methods: { methods: {
logout() { logout() {
// 1. 清空 token // 1. 清空 token
localStorage.removeItem("token"); localStorage.removeItem('token')
// 2. 跳转到登录页面 // 2. 跳转到登录页面
this.$router.push("/login"); this.$router.push('/login')
}, },
myHome() { myHome() {
// 新页面打开 // 新页面打开
window.open("http://qinyingjie.top/"); window.open('http://qinyingjie.top/')
// 当前页面打开 // 当前页面打开
// window.location.href = "http://qinyingjie.top/"; // window.location.href = "http://qinyingjie.top/";
}, },
}, },
}; }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
......
...@@ -21,59 +21,59 @@ ...@@ -21,59 +21,59 @@
</template> </template>
<script> <script>
// 导入 axios 请求库 // 导入 axios 请求库
import axios from "axios"; import axios from 'axios'
export default { export default {
name: "AddChatDetail", name: 'AddChatDetail',
data() { data() {
return { return {
form: { form: {
question: "", question: '',
response: "", response: '',
}, },
}; }
}, },
methods: { methods: {
clearContent() { clearContent() {
this.form.question = ""; this.form.question = ''
this.form.response = ""; this.form.response = ''
}, },
async onSubmit() { async onSubmit() {
const data = { const data = {
question: this.form.question, question: this.form.question,
response: this.form.response, response: this.form.response,
}; }
axios axios
.post("http://120.79.36.53:8888/chatbot", data) .post('http://120.79.36.53:8888/chatbot', data)
.then((response) => { .then((response) => {
// 只要请求回来的数据,在页面渲染期间要用到,则必须转存到 data 中 // 只要请求回来的数据,在页面渲染期间要用到,则必须转存到 data 中
if (response.data.code === 200) { if (response.data.code === 200) {
this.$message.success({ this.$message.success({
message: "问题和答案新增成功", message: '问题和答案新增成功',
duration: 1000, duration: 1000,
}); })
this.goBack(); this.goBack()
} }
}) })
.catch((error) => { .catch((error) => {
// 处理错误 // 处理错误
this.$message.error("系统异常"); this.$message.error('系统异常')
}); })
}, },
goBack() { goBack() {
// 传递参数到前一个页面 // 传递参数到前一个页面
const params = { const params = {
// 参数名: 参数值 // 参数名: 参数值
back: "back", back: 'back',
add: "add", add: 'add',
}; }
// 使用 $router.push() 导航到前一个页面 // 使用 $router.push() 导航到前一个页面
this.$router.push({ this.$router.push({
path: "/home/chat", // 前一个页面的路径 path: '/home/chat', // 前一个页面的路径
query: params, // 参数对象 query: params, // 参数对象
}); })
}, },
}, },
}; }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
......
...@@ -36,40 +36,38 @@ ...@@ -36,40 +36,38 @@
</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() { created() {
// 调用请求数据的方法 // 调用请求数据的方法
this.initChatList(); this.initChatList()
}, },
methods: { methods: {
goBack() { goBack() {
// 传递参数到前一个页面 // 传递参数到前一个页面
const params = { const params = {
// 参数名: 参数值 // 参数名: 参数值
back: "back", back: 'back',
// baz: "qux", // baz: "qux",
}; }
// 使用 $router.push() 导航到前一个页面 // 使用 $router.push() 导航到前一个页面
this.$router.push({ this.$router.push({
path: "/home/chat", // 前一个页面的路径 path: '/home/chat', // 前一个页面的路径
query: params, // 参数对象 query: params, // 参数对象
}); })
}, },
// 封装请求列表数据的方法 // 封装请求列表数据的方法
async initChatList() { async initChatList() {
// 调用 axios 的 get 方法,请求列表数据 // 调用 axios 的 get 方法,请求列表数据
const { data: res } = await axios.get( const { data: res } = await axios.get('http://120.79.36.53:8888/chatbot/' + this.id)
"http://120.79.36.53:8888/chatbot/" + this.id
);
// 只要请求回来的数据,在页面渲染期间要用到,则必须转存到 data 中 // 只要请求回来的数据,在页面渲染期间要用到,则必须转存到 data 中
if (res.code === 200) { if (res.code === 200) {
this.list = [ this.list = [
...@@ -79,22 +77,22 @@ export default { ...@@ -79,22 +77,22 @@ export default {
response: res.result.response, response: res.result.response,
createTime: res.result.createTime, createTime: res.result.createTime,
}, },
]; ]
} }
}, },
copyCode() { copyCode() {
const codeBlock = document.getElementById("td-response"); const codeBlock = document.getElementById('td-response')
const range = document.createRange(); const range = document.createRange()
range.selectNode(codeBlock); range.selectNode(codeBlock)
const selection = window.getSelection(); const selection = window.getSelection()
selection.removeAllRanges(); selection.removeAllRanges()
selection.addRange(range); selection.addRange(range)
document.execCommand("copy"); document.execCommand('copy')
selection.removeAllRanges(); selection.removeAllRanges()
this.$message.success("代码已复制到剪贴板"); this.$message.success('代码已复制到剪贴板')
}, },
}, },
}; }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<script> <script>
export default { export default {
name: 'MyUserDetail', name: 'MyUserDetail',
props: ['id'] props: ['id'],
} }
</script> </script>
......
...@@ -69,7 +69,7 @@ const router = new VueRouter({ ...@@ -69,7 +69,7 @@ const router = new VueRouter({
props: true props: true
}, { }, {
path: 'addChat', path: 'addChat',
component: AddChatDetail, component: AddChatDetail
}, },
] ]
} }
......
export default ['/home', '/home/users', '/home/rights'] export default['/home', '/home/users', '/home/rights']
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册