Skip to content

Commit

Permalink
chore: 修复一些h5的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
boxshadow committed Aug 15, 2019
1 parent 32aea3e commit 4da4008
Show file tree
Hide file tree
Showing 19 changed files with 3,946 additions and 3,042 deletions.
2 changes: 2 additions & 0 deletions packages/slimkit-plus-feed/src/API2/FeedCommentController.php
Expand Up @@ -20,6 +20,7 @@

namespace Zhiyi\Component\ZhiyiPlus\PlusComponentFeed\API2;

use Cache;
use Illuminate\Http\Request;
use Illuminate\Database\Eloquent\Builder;
use Zhiyi\Plus\Http\Controllers\Controller;
Expand Down Expand Up @@ -199,6 +200,7 @@ public function store(
$feed->comments()->save($comment);
$feed->increment('feed_comment_count', 1);
$user->extra()->firstOrCreate([])->increment('comments_count', 1);
Cache::forget(sprintf('Feed:%d:comments-preview', $feed->id));
});

// 发送消息通知
Expand Down
46 changes: 23 additions & 23 deletions resources/spa/package.json
Expand Up @@ -9,48 +9,48 @@
"test:unit": "vue-cli-service test:unit"
},
"dependencies": {
"axios": "^0.18.0",
"c-swipe": "^2.1.0",
"cropperjs": "^1.4.1",
"axios": "^0.19.0",
"c-swipe": "^2.1.5",
"cropperjs": "^1.5.5",
"crypto-js": "^3.1.9-1",
"dexie": "^2.0.4",
"easemob-websdk": "1.4.15",
"github-markdown-css": "^2.10.0",
"easemob-websdk": "3.0.4",
"github-markdown-css": "^3.0.1",
"headroom.js": "^0.9.4",
"js-md5": "^0.7.3",
"lodash": "^4.17.11",
"markdown-it": "^8.4.2",
"lodash": "^4.17.15",
"markdown-it": "^9.1.0",
"markdown-it-plus-image": "^1.0.1",
"photoswipe": "^4.1.2",
"plus-message-bundle": "^1.0.2",
"register-service-worker": "^1.5.2",
"underscore": "^1.9.1",
"vue": "^2.5.21",
"vue-i18n": "^8.0.0",
"vue-router": "^3.0.1",
"vuex": "^3.0.1",
"weixin-js-sdk": "^1.3.3",
"vue-i18n": "^8.14.0",
"vue-router": "^3.1.2",
"vuex": "^3.1.1",
"weixin-js-sdk": "^1.4.0-test",
"xss": "^1.0.3"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.3.0",
"@vue/cli-plugin-eslint": "^3.3.0",
"@vue/cli-plugin-pwa": "^3.3.0",
"@vue/cli-plugin-unit-jest": "^3.3.0",
"@vue/cli-service": "^3.3.0",
"@vue/cli-plugin-babel": "^3.10.0",
"@vue/cli-plugin-eslint": "^3.10.0",
"@vue/cli-plugin-pwa": "^3.10.0",
"@vue/cli-plugin-unit-jest": "^3.10.0",
"@vue/cli-service": "^3.10.0",
"@vue/eslint-config-standard": "^4.0.0",
"@vue/test-utils": "^1.0.0-beta.26",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"eslint": "^5.9.0",
"eslint-plugin-vue": "^5.0.0-0",
"babel-eslint": "^10.0.2",
"babel-jest": "^24.8.0",
"eslint": "^6.1.0",
"eslint-plugin-vue": "^5.2.3",
"json-loader": "^0.5.7",
"less": "^3.8.1",
"less-loader": "^4.1.0",
"less-loader": "^5.0.0",
"postcss-px2rem": "^0.3.0",
"strip-css-comments": "^3.0.0",
"vue-cli-plugin-i18n": "^0.5.1",
"strip-css-comments": "^4.0.0",
"vue-cli-plugin-i18n": "^0.6.0",
"vue-template-compiler": "^2.5.17",
"yaml-loader": "^0.5.0"
},
Expand Down
17 changes: 12 additions & 5 deletions resources/spa/src/components/FeedCard/FeedCard.vue
Expand Up @@ -412,10 +412,14 @@ export default {
api
.postFeedComment(this.feedId, params)
.then(comment => {
this.commentCount += 1
comment.user = this.$store.state.CURRENTUSER
this.comments.unshift(comment)
if (this.comments.length > 5) this.comments.pop()
const comments = Object.assign([], this.comments)
comments.unshift(comment)
if (comments.length > 5) comments.pop()
this.$store.dispatch('feed/updateSingleFeed', {
id: this.feedId,
data: { comments, feed_comment_count: this.feed.feed_comment_count + 1 },
})
this.$Message.success(this.$t('comment.success'))
this.$bus.$emit('commentInput:close', true)
})
Expand All @@ -425,8 +429,11 @@ export default {
},
deleteComment (commentId) {
api.deleteFeedComment(this.feedId, commentId).then(() => {
this.feed.comments = this.feed.comments.filter(c => c.id !== commentId)
this.commentCount -= 1
const comments = Object.assign([], this.feed.comments.filter(c => c.id !== commentId))
this.$store.dispatch('feed/updateSingleFeed', {
id: this.feedId,
data: { comments, feed_comment_count: this.feed.feed_comment_count - 1 },
})
this.$Message.success(this.$t('comment.delete.success'))
})
},
Expand Down
2 changes: 2 additions & 0 deletions resources/spa/src/components/UserItem.vue
Expand Up @@ -75,6 +75,8 @@ export default {
}).then(follower => {
this.user.follower = follower
this.loading = false
this.user.extra.followers_count = follower ? this.user.extra.followers_count + 1 : this.user.extra.followers_count - 1
this.$store.commit('SAVE_USER', this.user)
})
},
},
Expand Down
2 changes: 1 addition & 1 deletion resources/spa/src/main.js
Expand Up @@ -60,7 +60,7 @@ new Vue({
router,
i18n,
created () {
WebIM.openWebIM()
process.env.VUE_APP_EASEMOB_APP_KEY && WebIM.openWebIM()
},
render: h => h(App),
}).$mount('#app')
Expand Down
5 changes: 3 additions & 2 deletions resources/spa/src/page/UserHome.vue
Expand Up @@ -231,7 +231,7 @@ export default {
},
userBackground () {
const { url } = this.user.bg || {}
return url || require('@/images/user_home_default_cover.png')
return url || require('../images/user_home_default_cover.png')
},
verified () {
return this.user.verified
Expand Down Expand Up @@ -332,7 +332,7 @@ export default {
followUserByStatus (status) {
if (!status || this.fetchFollow) return
this.fetchFollow = true
let { user: { extra: { followers_count: followersCount = 0 } = {} } = {} } = this
userApi
.followUserByStatus({
id: this.user.id,
Expand All @@ -341,6 +341,7 @@ export default {
.then(follower => {
this.relation = follower
this.fetchFollow = false
this.user.extra.followers_count = follower ? followersCount + 1 : followersCount - 1
})
},
hidenFilter () {
Expand Down
2 changes: 1 addition & 1 deletion resources/spa/src/page/article/components/ArticleLike.vue
Expand Up @@ -23,7 +23,7 @@
</RouterLink>

<div class="article-info">
<span>{{ time | time2tips | t('article.posted_at') }}</span>
<span v-if="time">{{ time | time2tips | t('article.posted_at') }}</span>
<span>{{ viewCount | formatNum | t('article.views_count') }}</span>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions resources/spa/src/page/article/components/ArticleReward.vue
Expand Up @@ -6,10 +6,10 @@
path="article.reward_count"
class="reward-info"
tag="p"
:places="{currencyUnit}"
:slot-scope="{currencyUnit}"
>
<span place="count">{{ count | formatNum }}</span>
<span place="amount">{{ ~~amount }}</span>
<span slot="count">{{ count | formatNum }}</span>
<span slot="amount">{{ ~~amount }}</span>
</i18n>
<RouterLink
v-if="list.length > 0"
Expand Down
2 changes: 2 additions & 0 deletions resources/spa/src/page/feed/FeedDetail.vue
Expand Up @@ -537,6 +537,8 @@ export default {
}).then(follower => {
this.relation = follower
this.fetchFollow = false
this.user.extra.followers_count = follower ? this.user.extra.followers_count + 1 : this.user.extra.followers_count - 1
this.$store.commit('SAVE_USER', this.user)
})
},
onRefresh () {
Expand Down
2 changes: 1 addition & 1 deletion resources/spa/src/page/group/GroupHome.vue
Expand Up @@ -16,7 +16,7 @@
<div class="group-label" @click="$router.push({ name: 'groups', query: { type: 'recommend' } })">
<!-- eslint-disable-next-line vue/component-name-in-template-casing -->
<i18n tag="h2" path="group.count">
<strong place="count">{{ groupTotalNumber }}</strong>
<strong slot="count">{{ groupTotalNumber }}</strong>
</i18n>
<svg class="m-style-svg m-svg-def m-entry-append">
<use xlink:href="#icon-arrow-right" />
Expand Down
Expand Up @@ -6,14 +6,14 @@
<!-- eslint-disable-next-line vue/component-name-in-template-casing -->
<i18n v-if="comment.reply_user" path="message.comment.reply">
<RouterLink
place="user1"
slot="user1"
:class="`${prefixCls}-item-top-link`"
:to="`/users/${comment.user_id}`"
>
{{ comment.user.name }}
</RouterLink>
<RouterLink
place="user2"
slot="user2"
:class="`${prefixCls}-item-top-link`"
:to="`/users/${comment.reply_user}`"
>
Expand All @@ -24,10 +24,10 @@
<i18n
v-else
path="message.comment.commented"
:places="{type: $t('article.type.answer')}"
:slot-scope="{type: $t('article.type.answer')}"
>
<RouterLink
place="user"
slot="user"
:class="`${prefixCls}-item-top-link`"
:to="`/users/${comment.user_id}`"
>
Expand Down
Expand Up @@ -6,14 +6,14 @@
<!-- eslint-disable-next-line vue/component-name-in-template-casing -->
<i18n v-if="comment.reply_user" path="message.comment.reply">
<RouterLink
place="user1"
slot="user1"
:class="`${prefixCls}-item-top-link`"
:to="`/users/${comment.user_id}`"
>
{{ comment.user.name }}
</RouterLink>
<RouterLink
place="user2"
slot="user2"
:class="`${prefixCls}-item-top-link`"
:to="`/users/${comment.reply_user}`"
>
Expand All @@ -24,10 +24,10 @@
<i18n
v-else
path="message.comment.commented"
:places="{type: $t('article.type.feed')}"
:slot-scope="{type: $t('article.type.feed')}"
>
<RouterLink
place="user"
slot="user"
:class="`${prefixCls}-item-top-link`"
:to="`/users/${comment.user_id}`"
>
Expand Down
Expand Up @@ -6,14 +6,14 @@
<!-- eslint-disable-next-line vue/component-name-in-template-casing -->
<i18n v-if="comment.reply_user" path="message.comment.reply">
<RouterLink
place="user1"
slot="user1"
:class="`${prefixCls}-item-top-link`"
:to="`/users/${comment.user_id}`"
>
{{ comment.user.name }}
</RouterLink>
<RouterLink
place="user2"
slot="user2"
:class="`${prefixCls}-item-top-link`"
:to="`/users/${comment.reply_user}`"
>
Expand All @@ -24,10 +24,10 @@
<i18n
v-else
path="message.comment.commented"
:places="{type: $t('article.type.question')}"
:slot-scope="{type: $t('article.type.question')}"
>
<RouterLink
place="user"
slot="user"
:class="`${prefixCls}-item-top-link`"
:to="`/users/${comment.user_id}`"
>
Expand Down
Expand Up @@ -4,9 +4,9 @@
<Avatar :user="user" />
<section class="userInfo">
<!-- eslint-disable-next-line vue/component-name-in-template-casing -->
<i18n path="message.like.liked" :places="{type: $t('article.type.answer')}">
<i18n path="message.like.liked" :slot-scope="{type: $t('article.type.answer')}">
<span
place="user"
slot="user"
:class="`${prefixCls}-item-top-link`"
@click="viewUser(user.id)"
>
Expand Down
Expand Up @@ -4,9 +4,9 @@
<Avatar :user="user" />
<section class="userInfo">
<!-- eslint-disable-next-line vue/component-name-in-template-casing -->
<i18n path="message.like.liked" :places="{type: $t('article.type.news')}">
<i18n path="message.like.liked" :slot-scope="{type: $t('article.type.news')}">
<span
place="user"
slot="user"
:class="`${prefixCls}-item-top-link`"
@click="viewUser(user.id)"
>
Expand Down
2 changes: 1 addition & 1 deletion resources/spa/src/page/sign/Signup.vue
Expand Up @@ -150,7 +150,7 @@
<RouterLink to="/signup/protocol" class="register-protocol">
<!-- eslint-disable-next-line vue/component-name-in-template-casing -->
<i18n path="auth.register.agree">
<span place="protocol">{{ siteName }}用户注册协议</span>
<span slot="protocol">{{ siteName }}用户注册协议</span>
</i18n>
</RouterLink>
</template>
Expand Down
38 changes: 38 additions & 0 deletions resources/spa/src/stores/module/feed.js
@@ -1,9 +1,11 @@
import * as api from '@/api/feeds'
import lstore from '@/plugins/lstore/lstore'
import Vue from 'vue'

export const TYPES = {
SAVE_FEED_LIST: 'SAVE_FEED_LIST',
SAVE_PINNED_LIST: 'SAVE_PINNED_LIST',
UPDATE_SINGLE_FEED: 'UPDATE_SINGLE_FEED',
}

const state = {
Expand Down Expand Up @@ -38,6 +40,12 @@ const mutations = {
lstore.setData(`FEED_LIST_${type.toUpperCase()}`, list)
},

[TYPES.UPDATE_SINGLE_FEED] (state, payload) {
const { data, type, index } = payload
const { list: { [type]: feedList = [] } = {} } = state
Vue.set(feedList, index, data)
},

[TYPES.SAVE_PINNED_LIST] (state, payload) {
const { list } = payload
state.list.pinned = list
Expand All @@ -46,6 +54,36 @@ const mutations = {
}

const actions = {
/**
* 更新单条动态
* @param commit
* @param state
* @param payload
*/
updateSingleFeed ({ commit, state }, payload) {
const { list: { pinned: pinnedFeeds, new: newFeeds, hot: hotFeeds, follow: followFeeds } } = state
const { id = 0, data } = payload
let pinnedFeed = pinnedFeeds.find(feed => (feed.id === id))
if (pinnedFeed >= 0) {
const pinned = Object.assign({}, { ...pinnedFeed, ...data })
commit(TYPES.UPDATE_SINGLE_FEED, { feed: pinned, index: pinnedFeed, type: 'pinned' })
}
let newFeed = newFeeds.findIndex(feed => (feed.id === id))
if (newFeed >= 0) {
const feed = Object.assign({}, { ...newFeeds[newFeed], ...data })
commit(TYPES.UPDATE_SINGLE_FEED, { type: 'new', data: feed, index: newFeed })
}
let hotFeed = hotFeeds.findIndex(feed => (feed.id === id))
if (hotFeed >= 0) {
const hot = Object.assign({}, { ...hotFeeds[hotFeed], ...data })
commit(TYPES.UPDATE_SINGLE_FEED, { type: 'hot', data: hot, index: hotFeed })
}
let followFeed = followFeeds.findIndex(feed => (feed.id === id))
if (followFeed >= 0) {
const follow = Object.assign({}, { ...followFeeds[followFeed], ...data })
commit(TYPES.UPDATE_SINGLE_FEED, { type: 'follow', data: follow, index: followFeed })
}
},
/**
* 获取最新动态列表
* @author mutoe <mutoe@foxmail.com>
Expand Down
1 change: 1 addition & 0 deletions resources/spa/src/style/common.less
Expand Up @@ -693,6 +693,7 @@
content: '';
position: absolute;
bottom: 0;
left: 0;
display: block;
height: 3px;/*no*/
width: 100%;
Expand Down

0 comments on commit 4da4008

Please sign in to comment.