Commit 563e14b7ffbdd607f74973aa16968055355fef01
Committed by
小小鲁班
1 parent
1804eea1
feat(component): add news list; !#zh: 新闻列表组件
Showing
9 changed files
with
129 additions
and
14 deletions
front-end/h5/src/components/core/editor/edit-panel/props/global-work.vue
| @@ -41,15 +41,15 @@ export default { | @@ -41,15 +41,15 @@ export default { | ||
| 41 | get () { | 41 | get () { |
| 42 | return this.work.page_mode || PAGE_MODE.SWIPPER_PAGE | 42 | return this.work.page_mode || PAGE_MODE.SWIPPER_PAGE |
| 43 | }, | 43 | }, |
| 44 | - set (page_mode) { | ||
| 45 | - this.updateWork({ page_mode }) | 44 | + set (pageMode) { |
| 45 | + this.updateWork({ page_mode: pageMode }) | ||
| 46 | } | 46 | } |
| 47 | } | 47 | } |
| 48 | }, | 48 | }, |
| 49 | methods: { | 49 | methods: { |
| 50 | ...mapActions('editor', [ | 50 | ...mapActions('editor', [ |
| 51 | 'updateWork' | 51 | 'updateWork' |
| 52 | - ]), | 52 | + ]) |
| 53 | } | 53 | } |
| 54 | } | 54 | } |
| 55 | </script> | 55 | </script> |
front-end/h5/src/components/core/support/excel.js
| @@ -68,7 +68,6 @@ export default { | @@ -68,7 +68,6 @@ export default { | ||
| 68 | this.sheet.loadData({ | 68 | this.sheet.loadData({ |
| 69 | rows: this.innerItems | 69 | rows: this.innerItems |
| 70 | }).change(excelData => { | 70 | }).change(excelData => { |
| 71 | - debugger | ||
| 72 | // console.log('----------') | 71 | // console.log('----------') |
| 73 | // console.log(excelData) | 72 | // console.log(excelData) |
| 74 | // console.log(this.formatter(excelData)) | 73 | // console.log(this.formatter(excelData)) |
front-end/h5/src/components/plugins/lbp-news-list.js
0 → 100644
| 1 | +import PropTypes from '@luban-h5/plugin-common-props' | ||
| 2 | +import Parser from '../../utils/excel-parser' | ||
| 3 | +import './styles/news-list.scss' | ||
| 4 | + | ||
| 5 | +export default { | ||
| 6 | + extra: { | ||
| 7 | + defaultStyle: { | ||
| 8 | + width: 320, | ||
| 9 | + height: 256 | ||
| 10 | + } | ||
| 11 | + }, | ||
| 12 | + name: 'lbp-news-list', | ||
| 13 | + props: { | ||
| 14 | + dataset: PropTypes.excel({ | ||
| 15 | + defaultValue: () => [ | ||
| 16 | + ['新闻标题', '摘要', '链接', '日期', '来源'], | ||
| 17 | + [ | ||
| 18 | + '1 . 鲁班H5 可视化搭建平台!', | ||
| 19 | + '鲁班H5-是一款基于常见业务组件,通过拖拽的形式,生成页面的可视化搭建系统;我们的初心也是希望能通过工程化的手段,提高简单H5页面的制作效率', | ||
| 20 | + 'https://luban-h5.com/', | ||
| 21 | + '2020-01-01', | ||
| 22 | + '鲁班H5' | ||
| 23 | + ], | ||
| 24 | + [ | ||
| 25 | + '2 . 鲁班H5-开源的可视化搭建平台!', | ||
| 26 | + 'en: web design tool || mobile page builder/editor || mini webflow for mobile page. zh: 类似易企秀的H5制作、建站工具、可视化搭建系统.', | ||
| 27 | + 'https://github.com/ly525/luban-h5', | ||
| 28 | + '2020-01-01', | ||
| 29 | + '鲁班H5(github)' | ||
| 30 | + ] | ||
| 31 | + ] | ||
| 32 | + }) | ||
| 33 | + }, | ||
| 34 | + data () { | ||
| 35 | + return { | ||
| 36 | + option: {} | ||
| 37 | + } | ||
| 38 | + }, | ||
| 39 | + render () { | ||
| 40 | + /** | ||
| 41 | + * rows[0] { | ||
| 42 | + '新闻标题': '', | ||
| 43 | + '摘要': '', | ||
| 44 | + '链接': '', | ||
| 45 | + '日期': '', | ||
| 46 | + '来源': '', | ||
| 47 | + } | ||
| 48 | + */ | ||
| 49 | + const { rows } = Parser.csv2VChartJson(this.dataset) | ||
| 50 | + return <div class="newslist" style="border-color: transparent;"> | ||
| 51 | + { | ||
| 52 | + rows.map((item, i) => | ||
| 53 | + <div class="news-item"> | ||
| 54 | + <a href={item['链接']} target="_blank" class="link"> | ||
| 55 | + <div class="title">{item['新闻标题']}</div> | ||
| 56 | + </a> | ||
| 57 | + <div class="content">{item['摘要']}</div> | ||
| 58 | + <div class="source">{item['来源']}</div> | ||
| 59 | + <div class="time">{item['日期']}</div> | ||
| 60 | + </div> | ||
| 61 | + ) | ||
| 62 | + } | ||
| 63 | + </div> | ||
| 64 | + }, | ||
| 65 | + mounted () { | ||
| 66 | + // this.renderChart() | ||
| 67 | + } | ||
| 68 | +} |
front-end/h5/src/components/plugins/styles/news-list.scss
0 → 100644
| 1 | +.news-item { | ||
| 2 | + border-color: rgba(33, 181, 244, 0.2); | ||
| 3 | + border-bottom: 1px solid #bbddff; | ||
| 4 | + text-align: left; | ||
| 5 | + padding: 16px 12px 4px; | ||
| 6 | + overflow: auto; | ||
| 7 | + color: #333; | ||
| 8 | + font-size: 12px; | ||
| 9 | + | ||
| 10 | + .link { | ||
| 11 | + color: #333; | ||
| 12 | + text-decoration: underline; | ||
| 13 | + } | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | +.news-item .title { | ||
| 17 | + font-weight: 700; | ||
| 18 | + text-align: left; | ||
| 19 | + font-size: 14px; | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +.news-item .content { | ||
| 23 | + // text-indent: 24px!important; | ||
| 24 | + text-align: left; | ||
| 25 | + margin-bottom: 8px; | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | + .news-item .source { | ||
| 29 | + float: left; | ||
| 30 | + text-align: left; | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +.news-item .time { | ||
| 34 | + float: right; | ||
| 35 | + margin-right: 4px; | ||
| 36 | +} | ||
| 0 | \ No newline at end of file | 37 | \ No newline at end of file |
front-end/h5/src/constants/work.js
| @@ -5,10 +5,10 @@ | @@ -5,10 +5,10 @@ | ||
| 5 | */ | 5 | */ |
| 6 | export const PAGE_MODE = { | 6 | export const PAGE_MODE = { |
| 7 | SWIPPER_PAGE: 'h5_swipper', | 7 | SWIPPER_PAGE: 'h5_swipper', |
| 8 | - LONG_PAGE: 'h5_long_page', | 8 | + LONG_PAGE: 'h5_long_page' |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | export const PAGE_MODE_LABEL = { | 11 | export const PAGE_MODE_LABEL = { |
| 12 | SWIPPER_PAGE: '翻页H5', | 12 | SWIPPER_PAGE: '翻页H5', |
| 13 | - LONG_PAGE: '长页面', | ||
| 14 | -} | ||
| 15 | \ No newline at end of file | 13 | \ No newline at end of file |
| 14 | + LONG_PAGE: '长页面' | ||
| 15 | +} |
front-end/h5/src/engine-entry.js
| @@ -62,7 +62,7 @@ const Engine = { | @@ -62,7 +62,7 @@ const Engine = { | ||
| 62 | }, | 62 | }, |
| 63 | renderPreview (pageElements = []) { | 63 | renderPreview (pageElements = []) { |
| 64 | const pageWrapperStyle = this.isLongPage ? { | 64 | const pageWrapperStyle = this.isLongPage ? { |
| 65 | - height: window.__work.height + 'px' | 65 | + height: window.__work.height + 'px' |
| 66 | } : {} | 66 | } : {} |
| 67 | 67 | ||
| 68 | const elements = pageElements.map(element => new Element(element)) | 68 | const elements = pageElements.map(element => new Element(element)) |
| @@ -78,10 +78,10 @@ const Engine = { | @@ -78,10 +78,10 @@ const Engine = { | ||
| 78 | </div> | 78 | </div> |
| 79 | ) | 79 | ) |
| 80 | }, | 80 | }, |
| 81 | - getContainerStyle(work) { | 81 | + getContainerStyle (work) { |
| 82 | const containerStyle = { | 82 | const containerStyle = { |
| 83 | position: 'relative', | 83 | position: 'relative', |
| 84 | - height: '100%', | 84 | + height: '100%' |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | if (this.isLongPage) { | 87 | if (this.isLongPage) { |
| @@ -89,9 +89,9 @@ const Engine = { | @@ -89,9 +89,9 @@ const Engine = { | ||
| 89 | } | 89 | } |
| 90 | return containerStyle | 90 | return containerStyle |
| 91 | }, | 91 | }, |
| 92 | - renderUnPublishTip() { | 92 | + renderUnPublishTip () { |
| 93 | return <div style="box-sizing: border-box;min-height: 568px;line-height: 568px;text-align: center;">页面可能暂未发布</div> | 93 | return <div style="box-sizing: border-box;min-height: 568px;line-height: 568px;text-align: center;">页面可能暂未发布</div> |
| 94 | - }, | 94 | + } |
| 95 | }, | 95 | }, |
| 96 | render (h) { | 96 | render (h) { |
| 97 | const work = window.__work | 97 | const work = window.__work |
front-end/h5/src/mixins/load-plugins.js
| @@ -16,6 +16,7 @@ import LbpRate from '../components/plugins/lbp-rate' | @@ -16,6 +16,7 @@ import LbpRate from '../components/plugins/lbp-rate' | ||
| 16 | import LbpQQMap from '../components/plugins/lbp-qq-map/src' | 16 | import LbpQQMap from '../components/plugins/lbp-qq-map/src' |
| 17 | import LbpLineChart from '../components/plugins/charts/line' | 17 | import LbpLineChart from '../components/plugins/charts/line' |
| 18 | import LbpTable from '../components/plugins/lbp-table' | 18 | import LbpTable from '../components/plugins/lbp-table' |
| 19 | +import LbpNewsList from '../components/plugins/lbp-news-list' | ||
| 19 | // import LbpTabs from '../components/plugins/lbp-tabs' | 20 | // import LbpTabs from '../components/plugins/lbp-tabs' |
| 20 | 21 | ||
| 21 | export const pluginsList = [ | 22 | export const pluginsList = [ |
| @@ -277,6 +278,17 @@ export const pluginsList = [ | @@ -277,6 +278,17 @@ export const pluginsList = [ | ||
| 277 | shortcutProps: { | 278 | shortcutProps: { |
| 278 | theme: 'lbp-table-theme-light-blue' | 279 | theme: 'lbp-table-theme-light-blue' |
| 279 | } | 280 | } |
| 281 | + }, | ||
| 282 | + { | ||
| 283 | + i18nTitle: { | ||
| 284 | + 'en-US': 'NewsList', | ||
| 285 | + 'zh-CN': '新闻列表' | ||
| 286 | + }, | ||
| 287 | + title: '新闻列表', | ||
| 288 | + icon: 'list', | ||
| 289 | + component: LbpNewsList, | ||
| 290 | + visible: true, | ||
| 291 | + name: LbpNewsList.name | ||
| 280 | } | 292 | } |
| 281 | ] | 293 | ] |
| 282 | 294 |
front-end/h5/src/store/modules/work.js
| @@ -39,7 +39,7 @@ export const actions = { | @@ -39,7 +39,7 @@ export const actions = { | ||
| 39 | * 预览作品之前需要先保存,但希望 用户点击保存按钮 和 点击预览按钮 loading_name 能够不同(虽然都调用了 saveWork) | 39 | * 预览作品之前需要先保存,但希望 用户点击保存按钮 和 点击预览按钮 loading_name 能够不同(虽然都调用了 saveWork) |
| 40 | * 因为 loading 效果要放在不同的按钮上 | 40 | * 因为 loading 效果要放在不同的按钮上 |
| 41 | */ | 41 | */ |
| 42 | - saveWork ({ commit, dispatch, state }, { isSaveCover = false, loadingName = 'saveWork_loading', successMsg="保存作品成功" } = {}) { | 42 | + saveWork ({ commit, dispatch, state }, { isSaveCover = false, loadingName = 'saveWork_loading', successMsg = '保存作品成功' } = {}) { |
| 43 | const fn = (callback) => { | 43 | const fn = (callback) => { |
| 44 | new AxiosWrapper({ | 44 | new AxiosWrapper({ |
| 45 | dispatch, | 45 | dispatch, |
front-end/h5/src/utils/excel-parser.js
| @@ -139,7 +139,7 @@ export default class Parser { | @@ -139,7 +139,7 @@ export default class Parser { | ||
| 139 | rows: rows.map((row, index) => { | 139 | rows: rows.map((row, index) => { |
| 140 | const obj = {} | 140 | const obj = {} |
| 141 | columns.forEach((col, colIndex) => { | 141 | columns.forEach((col, colIndex) => { |
| 142 | - obj[col] = row[colIndex] | 142 | + obj[col.trim()] = row[colIndex] |
| 143 | }) | 143 | }) |
| 144 | return obj | 144 | return obj |
| 145 | }) | 145 | }) |