🎨 接口数据结构变更

This commit is contained in:
ronger 2022-08-27 16:05:43 +08:00
parent 77ec373863
commit c5176326ad
12 changed files with 192 additions and 215 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<el-row> <el-row>
<el-col v-for="article in articles.articles" :key="article.idArticle" style="padding-top: 1rem;"> <el-col v-for="article in articles.list" :key="article.idArticle" style="padding-top: 1rem;">
<el-card> <el-card>
<div class="card-body d-flex flex-column"> <div class="card-body d-flex flex-column">
<el-link rel="nofollow" :underline="false" style="margin-bottom: .5rem;"> <el-link rel="nofollow" :underline="false" style="margin-bottom: .5rem;">
@ -17,8 +17,8 @@
<div class="vertical-container text-center" style="padding-top: 10px;"> <div class="vertical-container text-center" style="padding-top: 10px;">
<el-pagination :hide-on-single-page="true" <el-pagination :hide-on-single-page="true"
layout="prev, pager, next" layout="prev, pager, next"
:current-page="articles.pagination.currentPage" :current-page="articles.pageNum"
:total="articles.pagination.total" :total="articles.total"
prev-text="上一页" prev-text="上一页"
next-text="下一页" next-text="下一页"
@current-change="currentChange"> @current-change="currentChange">
@ -54,7 +54,7 @@
}).then(function (res) { }).then(function (res) {
_ts.$set(_ts, 'loading', false); _ts.$set(_ts, 'loading', false);
if (res) { if (res) {
_ts.$message(res.message); _ts.$message('绑定成功!');
_ts.currentChange(1); _ts.currentChange(1);
} }
}) })

View File

@ -97,7 +97,7 @@
sortNo: article.sortNo sortNo: article.sortNo
}).then(function (res) { }).then(function (res) {
if (res) { if (res) {
_ts.$message(res.message); _ts.$message("更新成功!");
} }
}) })
} else { } else {
@ -118,7 +118,7 @@
} }
}).then(function (res) { }).then(function (res) {
if (res) { if (res) {
_ts.$message(res.message); _ts.$message('操作成功!');
_ts.currentChange(_ts.articles.pageNum); _ts.currentChange(_ts.articles.pageNum);
} }
}) })

View File

@ -32,7 +32,7 @@
</el-col> </el-col>
</el-col> </el-col>
</el-col> </el-col>
<el-col v-for="tag in tags" :key="tag.idTag"> <el-col v-for="tag in tags.list" :key="tag.idTag">
<el-card style="margin: .5rem;"> <el-card style="margin: .5rem;">
<el-col :span="1"> <el-col :span="1">
<el-avatar shape="square" :src="tag.tagIconPath" fit="scale-down"></el-avatar> <el-avatar shape="square" :src="tag.tagIconPath" fit="scale-down"></el-avatar>
@ -56,8 +56,8 @@
<div class="vertical-container text-center"> <div class="vertical-container text-center">
<el-pagination :hide-on-single-page="true" <el-pagination :hide-on-single-page="true"
layout="prev, pager, next" layout="prev, pager, next"
:current-page="pagination.currentPage" :current-page="tags.pageNum"
:total="pagination.total" :total="tags.total"
@current-change="currentChange"> @current-change="currentChange">
</el-pagination> </el-pagination>
</div> </div>
@ -90,8 +90,7 @@ export default {
computed: { computed: {
...mapState({ ...mapState({
topic: state => state.topic.detail.data, topic: state => state.topic.detail.data,
tags: state => state.topic.tags.data.tags, tags: state => state.topic.tags.data
pagination: state => state.topic.tags.data.pagination
}), }),
hasPermissions() { hasPermissions() {
return this.$store.getters.hasPermissions('topic'); return this.$store.getters.hasPermissions('topic');
@ -100,7 +99,7 @@ export default {
methods: { methods: {
currentChange(page) { currentChange(page) {
let _ts = this; let _ts = this;
this.$store.dispatch('topic/fetchTopicTags', { _ts.$store.dispatch('topic/fetchTopicTags', {
page: page, page: page,
topic_uri: _ts.topic.topicUri topic_uri: _ts.topic.topicUri
}) })
@ -130,10 +129,8 @@ export default {
idTopic: _ts.topic.idTopic idTopic: _ts.topic.idTopic
} }
}).then(function (res) { }).then(function (res) {
if (res && res.message) { if (res) {
_ts.$message.error(res.message); const page = _ts.tags.pageNum;
} else {
const page = _ts.pagination.currentPage;
_ts.$store.dispatch('topic/fetchTopicTags', { _ts.$store.dispatch('topic/fetchTopicTags', {
page: page, page: page,
topic_uri: _ts.topic.topicUri topic_uri: _ts.topic.topicUri

View File

@ -14,7 +14,7 @@
<el-button @click="getTags()" slot="append" icon="el-icon-search"></el-button> <el-button @click="getTags()" slot="append" icon="el-icon-search"></el-button>
</el-input> </el-input>
</el-col> </el-col>
<el-col v-for="tag in tags" :key="tag.idTag"> <el-col v-for="tag in tags.list" :key="tag.idTag">
<el-card style="margin: .5rem;"> <el-card style="margin: .5rem;">
<el-col :span="1"> <el-col :span="1">
<el-avatar shape="square" :src="tag.tagIconPath" fit="scale-down"></el-avatar> <el-avatar shape="square" :src="tag.tagIconPath" fit="scale-down"></el-avatar>
@ -38,8 +38,8 @@
<div class="vertical-container text-center"> <div class="vertical-container text-center">
<el-pagination :hide-on-single-page="true" <el-pagination :hide-on-single-page="true"
layout="prev, pager, next" layout="prev, pager, next"
:current-page="pagination.currentPage" :current-page="tags.pageNum"
:total="pagination.total" :total="tags.total"
@current-change="currentChange"> @current-change="currentChange">
</el-pagination> </el-pagination>
</div> </div>
@ -64,8 +64,7 @@ export default {
computed: { computed: {
...mapState({ ...mapState({
topic: state => state.topic.detail.data, topic: state => state.topic.detail.data,
tags: state => state.topic.tags.data.tags, tags: state => state.topic.tags.data
pagination: state => state.topic.tags.data.pagination
}) })
}, },
data() { data() {
@ -93,18 +92,16 @@ export default {
idTag: idTag, idTag: idTag,
idTopic: _ts.topic.idTopic idTopic: _ts.topic.idTopic
}).then(function (res) { }).then(function (res) {
if (res && res.message) { if (res) {
_ts.$message.error(res.message); _ts.currentChange(_ts.tags.pageNum);
} else {
_ts.currentChange(_ts.pagination.currentPage);
} }
}) })
}).catch(() => { }).catch(() => {
_ts.currentChange(_ts.pagination.currentPage); _ts.currentChange(_ts.tags.pageNum);
}); });
}, },
getTags() { getTags() {
this.currentChange(this.pagination.currentPage); this.currentChange(this.tags.pageNum);
} }
}, },
mounted() { mounted() {

View File

@ -159,7 +159,7 @@ export default {
toggleStatus(index, user) { toggleStatus(index, user) {
let _ts = this; let _ts = this;
let title, status; let title, status;
if (user.status == 0) { if (user.status === '0') {
title = '禁用'; title = '禁用';
status = 1; status = 1;
} else { } else {
@ -175,9 +175,7 @@ export default {
idUser: user.idUser, idUser: user.idUser,
status: status status: status
}).then(function (res) { }).then(function (res) {
if (res && res.message) { if (res) {
_ts.$message.error(res.message);
} else {
_ts.$message({ _ts.$message({
type: 'success', type: 'success',
message: title + '成功!' message: title + '成功!'
@ -213,14 +211,11 @@ export default {
idRole: _ts.idRole idRole: _ts.idRole
}; };
_ts.$axios.$patch('/api/admin/user/update-role', data).then(function (res) { _ts.$axios.$patch('/api/admin/user/update-role', data).then(function (res) {
if (res && res.message) { if (res) {
_ts.$message.error(res.message);
} else {
_ts.$message({ _ts.$message({
message: '授权成功', message: '授权成功',
type: 'success' type: 'success'
}); });
_ts.$set(_ts, 'dialogVisible', false); _ts.$set(_ts, 'dialogVisible', false);
_ts.$set(_ts, 'idUser', 0); _ts.$set(_ts, 'idUser', 0);
_ts.$set(_ts, 'idRole', 0); _ts.$set(_ts, 'idRole', 0);

View File

@ -372,12 +372,8 @@ export default {
idArticle: _ts.article.idArticle idArticle: _ts.article.idArticle
}).then(function (res) { }).then(function (res) {
if (res) { if (res) {
if (res.success) { _ts.$message.success("点赞成功");
_ts.$message.success(res.message); _ts.$store.dispatch('article/updateThumbsUpCount', {thumbsUpNumber: res})
_ts.$store.dispatch('article/updateThumbsUpCount', {thumbsUpNumber: res.thumbsUpNumber})
} else {
_ts.$message.error(_ts.message);
}
} }
}) })
}, },
@ -388,12 +384,8 @@ export default {
dataId: _ts.article.idArticle dataId: _ts.article.idArticle
}).then(function (res) { }).then(function (res) {
if (res) { if (res) {
if (res.success) { _ts.$message.success('赞赏成功');
_ts.$message.success(res.message); _ts.$store.dispatch('article/updateSponsorCount', {sponsorNumber: 1})
_ts.$store.dispatch('article/updateSponsorCount', {sponsorNumber: 1})
} else {
_ts.$message.error(_ts.message);
}
} }
}) })
}, },

View File

@ -47,12 +47,10 @@ export default {
}; };
_ts.$axios.$patch("/api/console/forget-password", data).then(function (res) { _ts.$axios.$patch("/api/console/forget-password", data).then(function (res) {
if (res) { if (res) {
_ts.$message(res.message); _ts.$message("修改成功,正在跳转登录界面!");
if (res.flag === 1) { _ts.$router.push({
_ts.$router.push({ name: 'login'
name: 'login' })
})
}
} }
}) })
} }

View File

@ -78,6 +78,9 @@
) )
} }
} }
},
mounted() {
this.$store.commit('setActiveMenu', 'portfolioBind');
} }
} }
</script> </script>

View File

@ -332,14 +332,10 @@ export default {
} }
}).then(function (res) { }).then(function (res) {
if (res) { if (res) {
if (res.message) { _ts.$set(_ts, 'notificationFlag', false);
_ts.$message(res.message); _ts.$router.push({
} else { path: '/user/' + _ts.$store.state.userInfo?.account
_ts.$set(_ts, 'notificationFlag', false); })
_ts.$router.push({
path: '/user/' + _ts.$store.state.userInfo?.account
})
}
} }
}) })
}).catch(() => { }).catch(() => {

View File

@ -11,20 +11,25 @@
{ type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }]"> { type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }]">
<el-input v-model="user.email" autocomplete="off"></el-input> <el-input v-model="user.email" autocomplete="off"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="密码" prop="password" :rules="[{ required: true, message: '请输入密码', trigger: 'blur' }]"> <el-form-item label="密码" prop="password"
:rules="[{ required: true, message: '请输入密码', trigger: 'blur' }]">
<el-input type="password" v-model="user.password" autocomplete="off" show-password></el-input> <el-input type="password" v-model="user.password" autocomplete="off" show-password></el-input>
</el-form-item> </el-form-item>
<el-form-item label="确认密码" prop="confirmPassword" <el-form-item label="确认密码" prop="confirmPassword"
:rules="[{ required: true, message: '请输入确认密码', trigger: 'blur' }]"> :rules="[{ required: true, message: '请输入确认密码', trigger: 'blur' }]">
<el-input type="password" v-model="user.confirmPassword" autocomplete="off" show-password></el-input> <el-input type="password" v-model="user.confirmPassword" autocomplete="off" show-password></el-input>
</el-form-item> </el-form-item>
<el-form-item label="验证码" prop="code" :rules="[{ required: true, message: '请输入验证码', trigger: 'blur' }]"> <el-form-item label="验证码" prop="code"
:rules="[{ required: true, message: '请输入验证码', trigger: 'blur' }]">
<el-input v-model="user.code" maxlength="6" autocomplete="off"> <el-input v-model="user.code" maxlength="6" autocomplete="off">
<el-button type="email" size="small" slot="append" @click="sendCode" :loading="loading" plain>{{loadText}}</el-button> <el-button type="email" size="small" slot="append" @click="sendCode" :loading="loading" plain>
{{ loadText }}
</el-button>
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button style="width: 60%;" type="primary" @click="register" :loading="registerLoading" plain>立即注册</el-button> <el-button style="width: 60%;" type="primary" @click="register" :loading="registerLoading" plain>立即注册
</el-button>
<el-button style="width: 32%;" @click="login" plain>登录</el-button> <el-button style="width: 32%;" @click="login" plain>登录</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -33,7 +38,8 @@
<div> <div>
<h2>欢迎来到 RYMCU</h2> <h2>欢迎来到 RYMCU</h2>
<p><a rel="nofollow" href="/">RYMCU</a> 是一个嵌入式知识学习交流平台专注于单片机学习</p> <p><a rel="nofollow" href="/">RYMCU</a> 是一个嵌入式知识学习交流平台专注于单片机学习</p>
<p>我们正在构建一个小众社区大家在这里相互<strong>信任</strong><em>平等 自由 奔放</em>的价值观进行分享交流最终希望大家能够找到与自己志同道合的伙伴共同成长</p> <p>我们正在构建一个小众社区大家在这里相互<strong>信任</strong><em>平等 自由 奔放</em>的价值观进行分享交流最终希望大家能够找到与自己志同道合的伙伴共同成长
</p>
<p>最后请大家共同爱护这个<i>自由</i>的交流环境相信这里一定是你注册过的所有社区中用户体验最好的 😍</p> <p>最后请大家共同爱护这个<i>自由</i>的交流环境相信这里一定是你注册过的所有社区中用户体验最好的 😍</p>
</div> </div>
</el-col> </el-col>
@ -41,140 +47,136 @@
</template> </template>
<script> <script>
export default { export default {
name: "register", name: "register",
data() { data() {
return { return {
user: { user: {
email: '', email: '',
code: '', code: '',
password: '', password: '',
confirmPassword: '' confirmPassword: ''
},
registerLoading: false,
loading: false,
loadText: '发送验证码',
timeClock: null
}
},
methods: {
sendCode() {
let _ts = this;
_ts.timerHandler();
let email = _ts.user.email;
if (!email) {
return false
}
let data = {
email: email
}
_ts.$axios.$get('/api/console/get-email-code', {
params: data
}).then(response => {
if (response.message) {
_ts.$message(response.message);
}
}).catch(error => {
console.log(error);
_ts.$message("邮件发送失败,请检查邮箱是否正确!");
})
}, },
timerHandler() { registerLoading: false,
let _ts = this; loading: false,
_ts.$set(_ts, 'loading', true); loadText: '发送验证码',
let times = 30; timeClock: null
_ts.timeClock = setInterval(function (){
times --;
_ts.$set(_ts, 'loadText', times + ' s');
if (times == 0) {
clearInterval(_ts.timeClock);
_ts.$set(_ts, 'loading', false);
_ts.$set(_ts, 'loadText', '发送验证码');
}
},1000)
},
register() {
let _ts = this;
_ts.$refs.user.validate((valid) => {
if (valid) {
_ts.$set(_ts, 'registerLoading', true);
setTimeout(function () {
_ts.$set(_ts, 'registerLoading', false);
}, 10000);
let data = {
email: _ts.user.email,
password: _ts.user.password,
code: _ts.user.code
}
_ts.$axios.$post('/api/console/register', data).then(function (res) {
_ts.$set(_ts, 'registerLoading', false);
if (res) {
_ts.$message(res.message);
if (res.flag && res.flag === 1) {
setTimeout(function () {
_ts.$router.push(
{
name: 'login'
}
)
}, 1000);
}
}
})
} else {
return false;
}
});
},
login() {
this.$router.push(
{
name: 'login'
}
)
}
},
mounted() {
this.$store.commit('setActiveMenu', 'register')
} }
},
methods: {
sendCode() {
let _ts = this;
_ts.timerHandler();
let email = _ts.user.email;
if (!email) {
return false
}
let data = {
email: email
}
_ts.$axios.$get('/api/console/get-email-code', {
params: data
}).then(response => {
if (response.message) {
_ts.$message(response.message);
}
}).catch(error => {
console.log(error);
_ts.$message("邮件发送失败,请检查邮箱是否正确!");
})
},
timerHandler() {
let _ts = this;
_ts.$set(_ts, 'loading', true);
let times = 30;
_ts.timeClock = setInterval(function () {
times--;
_ts.$set(_ts, 'loadText', times + ' s');
if (times == 0) {
clearInterval(_ts.timeClock);
_ts.$set(_ts, 'loading', false);
_ts.$set(_ts, 'loadText', '发送验证码');
}
}, 1000)
},
register() {
let _ts = this;
_ts.$refs.user.validate((valid) => {
if (valid) {
_ts.$set(_ts, 'registerLoading', true);
setTimeout(function () {
_ts.$set(_ts, 'registerLoading', false);
}, 10000);
let data = {
email: _ts.user.email,
password: _ts.user.password,
code: _ts.user.code
}
_ts.$axios.$post('/api/console/register', data).then(function (res) {
_ts.$set(_ts, 'registerLoading', false);
if (res) {
_ts.$message("注册成功!");
_ts.$router.push(
{
name: 'login'
}
)
}
})
} else {
return false;
}
});
},
login() {
this.$router.push(
{
name: 'login'
}
)
}
},
mounted() {
this.$store.commit('setActiveMenu', 'register')
} }
}
</script> </script>
<style scoped> <style scoped>
.icon-rymcu { .icon-rymcu {
margin: 0 auto; margin: 0 auto;
display: block; display: block;
height: 4rem; height: 4rem;
} }
.verify .verify-wrap { .verify .verify-wrap {
/*width: 60%;*/ /*width: 60%;*/
} }
.flex-inline { .flex-inline {
display: flex; display: flex;
align-items: center; align-items: center;
} }
.verify .intro { .verify .intro {
padding: 50px; padding: 50px;
background-color: #f1f7fe; background-color: #f1f7fe;
/*width: 40%;*/ /*width: 40%;*/
color: #616161; color: #616161;
} }
.verify__sign { .verify__sign {
background-color: transparent !important; background-color: transparent !important;
} }
.vditor-reset { .vditor-reset {
font-variant-ligatures: no-common-ligatures; font-variant-ligatures: no-common-ligatures;
font-family: Helvetica Neue, Luxi Sans, DejaVu Sans, Tahoma, Hiragino Sans GB, Microsoft Yahei, sans-serif, Apple Color Emoji, Segoe UI Emoji, Noto Color Emoji, Segoe UI Symbol, Android Emoji, EmojiSymbols; font-family: Helvetica Neue, Luxi Sans, DejaVu Sans, Tahoma, Hiragino Sans GB, Microsoft Yahei, sans-serif, Apple Color Emoji, Segoe UI Emoji, Noto Color Emoji, Segoe UI Symbol, Android Emoji, EmojiSymbols;
word-wrap: break-word; word-wrap: break-word;
overflow: auto; overflow: auto;
line-height: 1.5; line-height: 1.5;
font-size: 16px; font-size: 16px;
word-break: break-word; word-break: break-word;
} }
</style> </style>

View File

@ -20,9 +20,14 @@
<el-input type="textarea" v-model="user.signature"></el-input> <el-input type="textarea" v-model="user.signature"></el-input>
</el-form-item> </el-form-item>
<el-form-item style="text-align: right;"> <el-form-item style="text-align: right;">
<el-button type="primary" round plain @click="updateUserInfo">保存</el-button> <el-button type="primary" round plain @click="updateUserInfo">保存基本信息</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-col>
<el-col>
<h1>社交信息</h1>
</el-col>
<el-col>
<el-form :model="userExtend" ref="userExtend" label-width="100px"> <el-form :model="userExtend" ref="userExtend" label-width="100px">
<el-form-item label="博客" prop="signature"> <el-form-item label="博客" prop="signature">
<el-input placeholder="设置后将会公开你的博客" v-model="userExtend.blog"> <el-input placeholder="设置后将会公开你的博客" v-model="userExtend.blog">
@ -47,7 +52,7 @@
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item style="text-align: right;"> <el-form-item style="text-align: right;">
<el-button type="primary" round plain @click="updateUserExtend">保存</el-button> <el-button type="primary" round plain @click="updateUserExtend">保存社交信息</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-col> </el-col>
@ -87,12 +92,12 @@
let _ts = this; let _ts = this;
_ts.$axios.$get('/api/user-info/detail/' + _ts.idUser).then(function (res) { _ts.$axios.$get('/api/user-info/detail/' + _ts.idUser).then(function (res) {
if (res) { if (res) {
if (res.message) { _ts.$set(_ts, 'user', res);
_ts.$message.error(res.message); }
} else { })
_ts.$set(_ts, 'user', res.user); _ts.$axios.$get('/api/user-info/detail/' + _ts.idUser + '/extend-info').then(function (res) {
_ts.$set(_ts, 'userExtend', res.userExtend); if (res) {
} _ts.$set(_ts, 'userExtend', res);
} }
}) })
}, },
@ -104,8 +109,8 @@
nickname: _ts.user.nickname nickname: _ts.user.nickname
} }
}).then(function (res) { }).then(function (res) {
if (res && res.message) { if (!res) {
_ts.$message.error(res.message); _ts.$message.error('昵称已被占用!');
} }
}) })
}, },
@ -120,13 +125,9 @@
if (valid) { if (valid) {
_ts.$axios.$patch('/api/user-info/update', user).then(function (res) { _ts.$axios.$patch('/api/user-info/update', user).then(function (res) {
if (res) { if (res) {
if (res.message) { _ts.$set(_ts, 'user', res);
_ts.$message.error(res.message); _ts.$store.commit('setUserInfo', res);
} else { _ts.$message.success('更新成功 !');
_ts.$set(_ts, 'user', res.user);
_ts.$store.commit('setUserInfo', res.user);
_ts.$message.success('更新成功 !');
}
} }
}) })
} else { } else {
@ -139,12 +140,8 @@
let userExtend = _ts.userExtend; let userExtend = _ts.userExtend;
_ts.$axios.$patch('/api/user-info/update-extend', userExtend).then(function (res) { _ts.$axios.$patch('/api/user-info/update-extend', userExtend).then(function (res) {
if (res) { if (res) {
if (res.message) { _ts.$set(_ts, 'userExtend', res);
_ts.$message.error(res.message); _ts.$message.success('更新成功 !');
} else {
_ts.$set(_ts, 'userExtend', res.userExtend);
_ts.$message.success('更新成功 !');
}
} }
}) })
} }

View File

@ -50,7 +50,7 @@ export const mutations = {
state.detail.fetching = action state.detail.fetching = action
}, },
updateDetailData(state, action) { updateDetailData(state, action) {
state.detail.data = action.portfolio state.detail.data = action
}, },
updateArticleList(state, action) { updateArticleList(state, action) {
state.articles = action state.articles = action