Skip to content

Commit

Permalink
fix: #62 display a message if user delete the page if only one page;
Browse files Browse the repository at this point in the history
当只有一页的时候,提示用户至少需要保留一页
  • Loading branch information
ly525 committed Dec 15, 2019
1 parent 99652fe commit bbe623b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion front-end/h5/src/store/modules/page.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/*
* @Author: ly525
* @Date: 2019-12-08 17:05:09
* @LastEditors: ly525
* @LastEditTime: 2019-12-15 15:41:56
* @FilePath: /luban-h5/front-end/h5/src/store/modules/page.js
* @Github: https://github.com/ly525/luban-h5
* @Description: page module
* @Copyright 2018 - 2019 luban-h5. All Rights Reserved
*/
import { message } from 'ant-design-vue'

import Page from '../../components/core/models/page'

// actions
Expand Down Expand Up @@ -29,7 +41,12 @@ export const mutations = {
state.work.pages.push(state.editingPage.clone())
break
case 'delete':
if (state.work.pages.length === 1) return // #!zh: 作品中至少需要保留一个页面,TODO 需要在页面中提示用户此信息
if (state.work.pages.length === 1) {
// #!zh: 作品中至少需要保留一个页面
// #!en: At least one page needs to be kept in the work
message.info(`作品中至少需要保留一个页面`)
return
}

const { work, editingPage } = state
let index = work.pages.findIndex(page => page.uuid === editingPage.uuid)
Expand Down

0 comments on commit bbe623b

Please sign in to comment.