<commit_before><template>
  <div class="p-message-system">
    <CommonHeader>{{ $t('message.system.name') }}</CommonHeader>

    <JoLoadMore
      ref="loadmore"
      @onRefresh="onRefresh"
      @onLoadMore="onLoadMore"
    >
      <section
        v-for="notification in notifications"
        :key="notification.id"
        class="notification-item"
        @click="jump(notification.data)"
      >
        <h5>{{ notification.data | getNotificationDisplay }}</h5>
        <p>{{ notification.created_at | time2tips }}</p>
      </section>
    </JoLoadMore>
  </div>
</template>

<script>
import * as api from '@/api/message'

export default {
  name: 'MessageSystem',
  data () {
    return {
      notifications: [],
      page: 1,
    }
  },
  activated () {
    this.$refs.loadmore.beforeRefresh()
  },
  methods: {
    onRefresh () {
      const type = 'system'
      api.getNotification({ type, page: this.page })
        .then(({ data }) => {
          const noMore = data.meta.last_page <= data.meta.current_page
          this.notifications = data.data
          api.resetNotificationCount(type)
          this.$refs.loadmore.afterRefresh(noMore)
          if (!noMore) this.page++
        })
    },
    onLoadMore () {
      const type = 'system'<commit_msg>fix(SPA): 修复系统通知多次刷新时会变为加载更多的问题<commit_after><template>
  <div class="p-message-system">
    <CommonHeader>{{ $t('message.system.name') }}</CommonHeader>

    <JoLoadMore
      ref="loadmore"
      @onRefresh="onRefresh"
      @onLoadMore="onLoadMore"
    >
      <section
        v-for="notification in notifications"
        :key="notification.id"
        class="notification-item"
        @click="jump(notification.data)"
      >
        <h5>{{ notification.data | getNotificationDisplay }}</h5>
        <p>{{ notification.created_at | time2tips }}</p>
      </section>
    </JoLoadMore>
  </div>
</template>

<script>
import * as api from '@/api/message'

export default {
  name: 'MessageSystem',
  data () {
    return {
      notifications: [],
      page: 1,
    }
  },
  activated () {
    this.$refs.loadmore.beforeRefresh()
  },
  methods: {
    onRefresh () {
      const type = 'system'
      this.page = 1
      api.getNotification({ type, page: this.page })
        .then(({ data }) => {
          const noMore = data.meta.last_page <= data.meta.current_page
          this.notifications = data.data
          api.resetNotificationCount(type)
          this.$refs.loadmore.afterRefresh(noMore)
          if (!noMore) this.page++
        })
    },
    onLoadMore () {
      const type = 'system'
{'fraction_non_alphanumeric': 0.15232558139534882, 'fraction_numerical': 0.0034883720930232558, 'mean_word_length': 2.3694516971279374, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7480137', 'n_tokens_mistral': 833, 'n_tokens_neox': 819, 'n_words': 146}