整理

上级 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 @@
<script>
export default {
name: 'MyApp'
name: 'MyApp',
}
</script>
......
此差异已折叠。
......@@ -21,17 +21,17 @@
<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 {
name: "MyHome",
name: 'MyHome',
// 注册组件
components: {
MyHeader,
MyAside,
},
};
}
</script>
<style lang="less" scoped>
......
......@@ -11,25 +11,12 @@
<!-- 登录名称 -->
<div class="form-group form-inline">
<label for="username">登录名称</label>
<input
type="text"
class="form-control ml-2"
id="username"
placeholder="请输入登录名称"
autocomplete="off"
v-model.trim="username"
/>
<input type="text" class="form-control ml-2" id="username" placeholder="请输入登录名称" autocomplete="off" v-model.trim="username" />
</div>
<!-- 登录密码 -->
<div class="form-group form-inline">
<label for="password">登录密码</label>
<input
type="password"
class="form-control ml-2"
id="password"
placeholder="请输入登录密码"
v-model.trim="password"
/>
<input type="password" class="form-control ml-2" id="password" placeholder="请输入登录密码" v-model.trim="password" />
</div>
<!-- 登录和重置按钮 -->
<div class="form-group form-inline d-flex justify-content-end">
......@@ -47,7 +34,7 @@ export default {
data() {
return {
username: '',
password: ''
password: '',
}
},
methods: {
......@@ -66,8 +53,8 @@ export default {
// 登录失败
localStorage.removeItem('token')
}
}
}
},
},
}
</script>
......
......@@ -4,40 +4,19 @@
<el-main>
<el-form :inline="true" :model="formInline" class="demo-form-inline">
<el-form-item label="问题">
<el-input
clearable
v-model="formInline.question"
placeholder="请输入问题"
@keydown.enter.native="initCartList"
></el-input>
<el-input clearable v-model="formInline.question" placeholder="请输入问题" @keydown.enter.native="initCartList"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="initCartList">查询</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" @click.prevent="addChat">
新增
</el-button>
<el-button type="primary" @click.prevent="addChat">新增</el-button>
</el-form-item>
</el-form>
<el-table border :data="userlist" v-loading="loading">
<el-table-column
prop="id"
label="序号"
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 prop="id" label="序号" 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">
<template slot-scope="props">
{{ props.row.createTime | dateFormat }}
......@@ -45,26 +24,12 @@
</el-table-column>
<el-table-column prop="详情" label="详情" width="180">
<template slot-scope="props">
<el-button
type="success"
@click.prevent="gotoDetail(props.row.id)"
>详情
</el-button>
<el-button type="danger" @click="onDelete(props.row.id)"
>删除</el-button
>
<el-button type="success" @click.prevent="gotoDetail(props.row.id)">详情</el-button>
<el-button type="danger" @click="onDelete(props.row.id)">删除</el-button>
</template>
</el-table-column>
</el-table>
<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-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-backtop class="backtop"></el-backtop>
</el-container>
......@@ -72,9 +37,9 @@
</template>
<script>
import axios from "axios";
import axios from 'axios'
export default {
name: "MyChat",
name: 'MyChat',
data() {
return {
......@@ -82,96 +47,90 @@ export default {
userlist: [],
loading: false,
elementui_page_component_key: 0,
currentPage: Number(localStorage.getItem("lastPage")) || 1,
currentPage: Number(localStorage.getItem('lastPage')) || 1,
pageSize: 10,
total: 0,
formInline: {
question: "",
question: '',
},
};
}
},
watch: {
"formInline.question"(newVal) {
if (newVal === "") {
this.currentPage = 1;
localStorage.setItem("lastPage", this.currentPage);
this.initCartList();
'formInline.question'(newVal) {
if (newVal === '') {
this.currentPage = 1
localStorage.setItem('lastPage', this.currentPage)
this.initCartList()
}
},
},
created() {
this.$nextTick(() => {
const foo = this.$route.query.back;
const add = this.$route.query.add;
if (foo === "back" && add != "add") {
this.currentPage = Number(localStorage.getItem("lastPage")) || 1;
this.formInline.question = localStorage.getItem("lastQuestion") || "";
const foo = this.$route.query.back
const add = this.$route.query.add
if (foo === 'back' && add != 'add') {
this.currentPage = Number(localStorage.getItem('lastPage')) || 1
this.formInline.question = localStorage.getItem('lastQuestion') || ''
} else {
localStorage.setItem("lastPage", 1);
localStorage.setItem("lastQuestion", "");
this.currentPage = 1;
this.formInline.question = "";
localStorage.setItem('lastPage', 1)
localStorage.setItem('lastQuestion', '')
this.currentPage = 1
this.formInline.question = ''
}
// 调用请求数据的方法
this.initCartList();
});
this.initCartList()
})
},
mounted() {
this.currentPage = Number(localStorage.getItem("lastPage")) || 1;
this.formInline.question = localStorage.getItem("lastQuestion");
this.elementui_page_component_key++;
this.currentPage = Number(localStorage.getItem('lastPage')) || 1
this.formInline.question = localStorage.getItem('lastQuestion')
this.elementui_page_component_key++
},
methods: {
async onDelete(id) {
this.loading = true;
const { data: res } = await axios.get(
"http://120.79.36.53:8888/chatbot/delete",
{
this.loading = true
const { data: res } = await axios.get('http://120.79.36.53:8888/chatbot/delete', {
params: {
id: id,
},
}
);
this.initCartList();
this.loading = false;
})
this.initCartList()
this.loading = false
},
refreshPage() {
location.reload();
location.reload()
},
gotoDetail(id) {
this.$router.push("/home/chatinfo/" + id);
this.$router.push('/home/chatinfo/' + id)
},
addChat() {
this.$router.push("/home/addChat/");
this.$router.push('/home/addChat/')
},
async initCartList() {
this.loading = true;
const { data: res } = await axios.get(
"http://120.79.36.53:8888/chatbot/page",
{
this.loading = true
const { data: res } = await axios.get('http://120.79.36.53:8888/chatbot/page', {
params: {
page: this.currentPage,
pageSize: this.pageSize,
question: this.formInline.question,
},
}
);
})
if (res.code === 200) {
this.userlist = res.result.records;
this.total = res.result.total;
localStorage.setItem("lastPage", this.currentPage);
localStorage.setItem("lastQuestion", this.formInline.question);
this.userlist = res.result.records
this.total = res.result.total
localStorage.setItem('lastPage', this.currentPage)
localStorage.setItem('lastQuestion', this.formInline.question)
}
this.loading = false;
this.loading = false
},
handleCurrentChange(currentPage) {
this.currentPage = currentPage;
this.initCartList();
this.currentPage = currentPage
this.initCartList()
},
},
};
}
</script>
<style lang="less" scoped>
......
......@@ -31,27 +31,24 @@
<script>
export default {
name: "MyUser",
name: 'MyUser',
data() {
return {
// 用户列表数据
userlist: [
{ id: 1, name: "嬴政", age: 18, position: "始皇帝" },
{ id: 2, name: "李斯", age: 35, position: "丞相" },
{ id: 3, name: "吕不韦", age: 50, position: "商人" },
{ id: 4, name: "赵姬", age: 48, position: "王太后" },
{ id: 1, name: '嬴政', age: 18, position: '始皇帝' },
{ id: 2, name: '李斯', age: 35, position: '丞相' },
{ id: 3, name: '吕不韦', age: 50, position: '商人' },
{ id: 4, name: '赵姬', age: 48, position: '王太后' },
],
};
}
},
methods: {
gotoDetail(id) {
// /home/userinfo/1
// /home/userinfo/2
// /home/userinfo/3
this.$router.push("/home/userinfo/" + id);
this.$router.push('/home/userinfo/' + id)
},
},
};
}
</script>
<style lang="less" scoped></style>
\ No newline at end of file
<template>
<el-menu
default-active="$route.path"
class="layout-aside-container"
background-color="#fff"
text-color="#000"
active-text-color="#42b983"
>
<el-menu default-active="$route.path" class="layout-aside-container" background-color="#fff" text-color="#000" active-text-color="#42b983">
<router-link to="/home/users">
<el-menu-item index="/users" class="left-aside-item">
<i class="el-icon-user"></i>
......@@ -45,7 +39,7 @@
</el-menu>
</template>
<script>
export default {name: 'MyAside'};
export default { name: 'MyAside' }
</script>
<style lang="less" scoped>
......
......@@ -3,18 +3,14 @@
<!-- 左侧 logo 和 标题区域 -->
<div class="layout-header-left d-flex align-items-center user-select-none">
<!-- 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>
</div>
<el-row>
<el-col :inline="true" :span="24">
<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 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-col>
</el-row>
</div>
......@@ -22,22 +18,22 @@
<script>
export default {
name: "MyHeader",
name: 'MyHeader',
methods: {
logout() {
// 1. 清空 token
localStorage.removeItem("token");
localStorage.removeItem('token')
// 2. 跳转到登录页面
this.$router.push("/login");
this.$router.push('/login')
},
myHome() {
// 新页面打开
window.open("http://qinyingjie.top/");
window.open('http://qinyingjie.top/')
// 当前页面打开
// window.location.href = "http://qinyingjie.top/";
},
},
};
}
</script>
<style lang="less" scoped>
......
......@@ -21,59 +21,59 @@
</template>
<script>
// 导入 axios 请求库
import axios from "axios";
import axios from 'axios'
export default {
name: "AddChatDetail",
name: 'AddChatDetail',
data() {
return {
form: {
question: "",
response: "",
question: '',
response: '',
},
};
}
},
methods: {
clearContent() {
this.form.question = "";
this.form.response = "";
this.form.question = ''
this.form.response = ''
},
async onSubmit() {
const data = {
question: this.form.question,
response: this.form.response,
};
}
axios
.post("http://120.79.36.53:8888/chatbot", data)
.post('http://120.79.36.53:8888/chatbot', data)
.then((response) => {
// 只要请求回来的数据,在页面渲染期间要用到,则必须转存到 data 中
if (response.data.code === 200) {
this.$message.success({
message: "问题和答案新增成功",
message: '问题和答案新增成功',
duration: 1000,
});
this.goBack();
})
this.goBack()
}
})
.catch((error) => {
// 处理错误
this.$message.error("系统异常");
});
this.$message.error('系统异常')
})
},
goBack() {
// 传递参数到前一个页面
const params = {
// 参数名: 参数值
back: "back",
add: "add",
};
back: 'back',
add: 'add',
}
// 使用 $router.push() 导航到前一个页面
this.$router.push({
path: "/home/chat", // 前一个页面的路径
path: '/home/chat', // 前一个页面的路径
query: params, // 参数对象
});
})
},
},
};
}
</script>
<style lang="less" scoped>
......
......@@ -36,40 +36,38 @@
</template>
<script>
// 导入 axios 请求库
import axios from "axios";
import axios from 'axios'
export default {
name: "MyChatDetail",
props: ["id"],
name: 'MyChatDetail',
props: ['id'],
data() {
return {
list: [],
};
}
},
created() {
// 调用请求数据的方法
this.initChatList();
this.initChatList()
},
methods: {
goBack() {
// 传递参数到前一个页面
const params = {
// 参数名: 参数值
back: "back",
back: 'back',
// baz: "qux",
};
}
// 使用 $router.push() 导航到前一个页面
this.$router.push({
path: "/home/chat", // 前一个页面的路径
path: '/home/chat', // 前一个页面的路径
query: params, // 参数对象
});
})
},
// 封装请求列表数据的方法
async initChatList() {
// 调用 axios 的 get 方法,请求列表数据
const { data: res } = await axios.get(
"http://120.79.36.53:8888/chatbot/" + this.id
);
const { data: res } = await axios.get('http://120.79.36.53:8888/chatbot/' + this.id)
// 只要请求回来的数据,在页面渲染期间要用到,则必须转存到 data 中
if (res.code === 200) {
this.list = [
......@@ -79,22 +77,22 @@ export default {
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("代码已复制到剪贴板");
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>
<style lang="less" scoped>
......
......@@ -8,7 +8,7 @@
<script>
export default {
name: 'MyUserDetail',
props: ['id']
props: ['id'],
}
</script>
......
......@@ -69,7 +69,7 @@ const router = new VueRouter({
props: true
}, {
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.
先完成此消息的编辑!
想要评论请 注册