|
|
@@ -1,377 +1,308 @@
|
|
|
<template>
|
|
|
- <section class="slides" contenteditable>
|
|
|
+ <section :class="showMode ? 'slide show-mode' : 'slide read-mode'">
|
|
|
<section class="page">
|
|
|
- <h1>界面布局排版原型</h1>
|
|
|
- <div>本组件用来演示幻灯片放映界面的布局排版</div>
|
|
|
+ <div>
|
|
|
+ <h1>编程基础 I</h1>
|
|
|
+ <div>刘钦</div>
|
|
|
+ </div>
|
|
|
</section>
|
|
|
<section class="page">
|
|
|
- <h3>无序列表</h3>
|
|
|
- <ul>
|
|
|
- <li>豆腐花:费时间快点发哈数据库恢复的空间</li>
|
|
|
- <li>{{ chineseLorem }}</li>
|
|
|
- <li>{{ englishLorem }}</li>
|
|
|
- <li>{{ chineseLongLorem }}</li>
|
|
|
- </ul>
|
|
|
+ <div>
|
|
|
+ <h3>Outline</h3>
|
|
|
+ <ul>
|
|
|
+ <li>代码是用来读的(实践经验)</li>
|
|
|
+ <li>降低复杂度 — 分解与抽象(方法学)</li>
|
|
|
+ <li>编程=数据结构+算法(理论逻辑)</li>
|
|
|
+ <li>算法建模(理论逻辑)</li>
|
|
|
+ <li>数据建模(理论逻辑)</li>
|
|
|
+ <li>编程范式 — 声明式与命令式(表现形式)</li>
|
|
|
+ <li>编程典型场景 — 数据处理(理论逻辑)</li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
</section>
|
|
|
<section class="page">
|
|
|
- <h3>有序列表</h3>
|
|
|
- <ol>
|
|
|
- <li>豆腐花:费时间快点发哈数据库恢复的空间</li>
|
|
|
- <li>{{ chineseLorem }}</li>
|
|
|
- <li>{{ englishLorem }}</li>
|
|
|
- <li>{{ chineseLongLorem }}</li>
|
|
|
- </ol>
|
|
|
+ <div>
|
|
|
+ <h2>1. 代码是用来读的!</h2>
|
|
|
+ </div>
|
|
|
</section>
|
|
|
<section class="page">
|
|
|
- <h3>图片</h3>
|
|
|
- <img src="./example.png" alt="" />
|
|
|
+ <div>
|
|
|
+ <h3>Write once, Read many times</h3>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <blockquote>
|
|
|
+ When you program, you have to think about how someone will read your
|
|
|
+ code, not just how a computer will interpret it.
|
|
|
+ </blockquote>
|
|
|
+ <div>—— Kent Beck</div>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <h3>代码可读</h3>
|
|
|
+ <ul>
|
|
|
+ <li>团队的需要</li>
|
|
|
+ <li>维护的需要</li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <h3>糟糕的变量名字</h3>
|
|
|
+ <div class="code java">
|
|
|
+ <code>
|
|
|
+ var x = x - xx <br />
|
|
|
+ var xxx = aretha + SalesTax( aretha )<br />
|
|
|
+ var x = x + LateFee( x1, x ) + xxx <br />
|
|
|
+ var x = x + Interest( x1, x )
|
|
|
+ </code>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <h3>良好的变量名字</h3>
|
|
|
+ <div class="code java">
|
|
|
+ <code>
|
|
|
+ var balance = balance - lastPayment <br />
|
|
|
+ var monthlyTotal = NewPurchases + SalesTax( newPurchases ) <br />
|
|
|
+ var balance = balance + LateFee( customerID, balance ) +
|
|
|
+ monthlyTotal<br />
|
|
|
+ var balance = balance + Interest( customerID, balance )
|
|
|
+ </code>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <h3>代码是用来读的!</h3>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <h2>2. 降低复杂度 - 分解与抽象</h2>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <h3>为什么要降低复杂度</h3>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <h3>世界是复杂的吗</h3>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <h3>程序员是干什么的?</h3>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <h3>将复杂的问题转化为代码</h3>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <h3>有什么降低复杂度的方法?</h3>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <h3>代码是用来读的!</h3>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <div>降低复杂度的方法 -</div>
|
|
|
+ <h2>分解(组合)</h2>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <div>*</div>
|
|
|
+ <div>// 打印一颗 *</div>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <div class="code">
|
|
|
+ <code> print("*")</code>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <div>#</div>
|
|
|
+ <div>// 打印一颗 #</div>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <div class="code">
|
|
|
+ <code>
|
|
|
+ public PageResourceResponse getSlides(@RequestParam(required =
|
|
|
+ false, defaultValue = "") String key, @ApiParam(hidden = true)
|
|
|
+ @PageableDefault(size = Integer.MAX_VALUE, sort = "updateTime",
|
|
|
+ direction = Sort.Direction.DESC) Pageable pageable) {<br />
|
|
|
+ List<SlideVO> slideVOs = slideService.getSlides(key,
|
|
|
+ pageable);<br />
|
|
|
+ return PageResourceResponse.of(slideVOs,
|
|
|
+ PageResourceResponse.PageInfo.of(pageable.getPageNumber(),
|
|
|
+ slideVOs.size())); }
|
|
|
+ </code>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <h3>*#</h3>
|
|
|
+ <br />
|
|
|
+ <div>// 打印 *#</div>
|
|
|
+ <div>// 打印一颗 * + 打印一颗 #</div>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <div class="code">
|
|
|
+ <code>
|
|
|
+ print("*")<br />
|
|
|
+ print("#")
|
|
|
+ </code>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <img src="./分解.png" alt="" />
|
|
|
+ <div>分解(组合)</div>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <h2>分解(组合)的关键点</h2>
|
|
|
+ <ul>
|
|
|
+ <li>分解之后,每一部分复杂度要变小</li>
|
|
|
+ <li>相互之间关联要小,相对独立</li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </section>
|
|
|
+ <section class="page">
|
|
|
+ <div>
|
|
|
+ <img src="./好的分解和坏的分解.png" alt="" />
|
|
|
+ <div>好的分解和坏的分解</div>
|
|
|
+ </div>
|
|
|
</section>
|
|
|
</section>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import Hljs from '@/utils/highlight'
|
|
|
+import 'highlight.js/styles/idea.css'
|
|
|
+
|
|
|
export default {
|
|
|
- data: function() {
|
|
|
+ data() {
|
|
|
return {
|
|
|
- chineseLorem: '豆腐花:费时间快点发哈数据库恢复的空间',
|
|
|
- chineseLongLorem:
|
|
|
- '地方会计史蒂夫好困睡觉啊回复科技示范户史蒂夫史蒂夫,史蒂夫说史蒂夫史蒂夫收费的爱上,是否是否打算史蒂夫史蒂夫史蒂夫说当时的发史蒂夫撒东方是否大。是的发送发送到发史蒂夫撒的发送到发撒东方史蒂夫撒东方四大发史蒂夫,史蒂夫撒东方撒大发史蒂夫。',
|
|
|
- englishLorem:
|
|
|
- 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Natus mollitia itaque vel consectetur beatae vero porro rerum ea blanditiis deserunt nisi voluptatibus amet quasi id praesentium, dolores enim! Mollitia, alias.'
|
|
|
+ showMode: true,
|
|
|
+ milestones: [],
|
|
|
+ animating: false
|
|
|
}
|
|
|
- }
|
|
|
-}
|
|
|
-</script>
|
|
|
-
|
|
|
-<style>
|
|
|
-</style>
|
|
|
-
|
|
|
-<style lang="scss" scoped>
|
|
|
-.page {
|
|
|
- display: flex;
|
|
|
- flex-direction: column;
|
|
|
-
|
|
|
- align-items: center;
|
|
|
- justify-content: center;
|
|
|
- min-height: 100vh;
|
|
|
-
|
|
|
- box-sizing: border-box;
|
|
|
- border-bottom: 1px solid gray; //dev
|
|
|
- font-weight: 500;
|
|
|
-
|
|
|
- & h1,
|
|
|
- h2,
|
|
|
- h3,
|
|
|
- h4,
|
|
|
- h5,
|
|
|
- h6,
|
|
|
- div,
|
|
|
- p,
|
|
|
- li {
|
|
|
- width: 100%;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-.slides {
|
|
|
- box-sizing: border-box;
|
|
|
- padding: 0 12vw;
|
|
|
- text-align: justify;
|
|
|
- margin: 0 auto;
|
|
|
- outline: none;
|
|
|
-
|
|
|
- line-height: 1.8;
|
|
|
- word-break: break-word;
|
|
|
- word-wrap: break-word;
|
|
|
-
|
|
|
- font-size: 26px;
|
|
|
-
|
|
|
- h1,
|
|
|
- h2,
|
|
|
- h3,
|
|
|
- h4,
|
|
|
- h5,
|
|
|
- h6 {
|
|
|
- font-weight: 600;
|
|
|
- text-align: left;
|
|
|
- }
|
|
|
-
|
|
|
- h1 {
|
|
|
- font-size: 1.88em;
|
|
|
- margin: 1.25em 0 1.25em 0;
|
|
|
- }
|
|
|
-
|
|
|
- h2 {
|
|
|
- font-size: 1.56em;
|
|
|
- margin: 2.5em 0 1.56em 0;
|
|
|
- }
|
|
|
-
|
|
|
- h3 {
|
|
|
- font-size: 1.38em;
|
|
|
- margin: 2.19em 0 1.25em 0;
|
|
|
- }
|
|
|
-
|
|
|
- h4 {
|
|
|
- font-size: 1.25em;
|
|
|
- margin: 1.56em 0 0.94em 0;
|
|
|
- }
|
|
|
-
|
|
|
- h5 {
|
|
|
- font-size: 1em;
|
|
|
- margin: 1.25em 0 0.63em 0;
|
|
|
- }
|
|
|
-
|
|
|
- h6 {
|
|
|
- font-size: 1em;
|
|
|
- margin: 1.25em 0 0.63em 0;
|
|
|
- }
|
|
|
-
|
|
|
- p {
|
|
|
- margin: 0.44em 0;
|
|
|
- }
|
|
|
-
|
|
|
- li {
|
|
|
- margin: 0.19em;
|
|
|
- }
|
|
|
-
|
|
|
- ul,
|
|
|
- ol {
|
|
|
- list-style: none;
|
|
|
- padding-left: 1em;
|
|
|
- margin-top: 0.3em;
|
|
|
- margin-bottom: 0.8em;
|
|
|
- }
|
|
|
-
|
|
|
- ul > li::before {
|
|
|
- content: '\02022';
|
|
|
- display: inline-block;
|
|
|
- color: #1976d2;
|
|
|
- width: 1em;
|
|
|
- margin-left: -1em;
|
|
|
- }
|
|
|
-
|
|
|
- ol {
|
|
|
- counter-reset: li;
|
|
|
- margin: 0 0 0 0.5em;
|
|
|
-
|
|
|
- li {
|
|
|
- text-align: left;
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.highlightCode()
|
|
|
+ const handleResize = () => {
|
|
|
+ if (window.innerWidth < 700) {
|
|
|
+ this.showMode = false
|
|
|
+ } else {
|
|
|
+ this.showMode = true
|
|
|
+ }
|
|
|
+
|
|
|
+ const pages = document.getElementsByClassName('page')
|
|
|
+ pages.forEach(page => {
|
|
|
+ this.milestones.push(page.offsetTop)
|
|
|
+ })
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- ol > li::before {
|
|
|
- font-family: 'Courier', 'Courier New', monospace !important;
|
|
|
- overflow: hidden;
|
|
|
- font-size: 1em;
|
|
|
- line-height: 0;
|
|
|
- content: counter(li) '.';
|
|
|
- color: #1976d2;
|
|
|
- display: inline;
|
|
|
- margin-left: -1.6em;
|
|
|
- margin-right: 0.4em;
|
|
|
- text-align: right;
|
|
|
- counter-increment: li;
|
|
|
- }
|
|
|
-
|
|
|
- blockquote {
|
|
|
- margin: 0.63em 0;
|
|
|
- padding: 0.31em 0.94em;
|
|
|
- border-left: #fbc02d 0.25em solid;
|
|
|
- background: #fffad3;
|
|
|
- position: relative;
|
|
|
-
|
|
|
- &::before {
|
|
|
- content: '!';
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- justify-content: center;
|
|
|
- font-size: 0.75em;
|
|
|
- font-family: monospace;
|
|
|
- color: white;
|
|
|
- position: absolute;
|
|
|
- left: -0.69em;
|
|
|
- top: 1em;
|
|
|
- width: 0.88em;
|
|
|
- height: 0.88em;
|
|
|
- background: #fbc02d;
|
|
|
- border: 0.13em #fbc02d solid;
|
|
|
- border-radius: 50%;
|
|
|
+ handleResize()
|
|
|
+ window.addEventListener('resize', handleResize)
|
|
|
+
|
|
|
+ const handleSpace = e => {
|
|
|
+ if (e.key === ' ') {
|
|
|
+ e.preventDefault()
|
|
|
+ this.nextPage()
|
|
|
+ } else if (e.key === 'ArrowUp' || e.key === 'ArrowLeft') {
|
|
|
+ e.preventDefault()
|
|
|
+ this.lastPage()
|
|
|
+ } else if (e.key === 'ArrowDown' || e.key === 'ArrowRight') {
|
|
|
+ e.preventDefault()
|
|
|
+ this.nextPage()
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- a {
|
|
|
- text-decoration: underline solid transparent;
|
|
|
- transition: 0.2s all ease-out;
|
|
|
-
|
|
|
- &:hover {
|
|
|
- text-decoration: underline solid #ccc;
|
|
|
+ window.addEventListener('keydown', handleSpace)
|
|
|
+ },
|
|
|
+ updated() {
|
|
|
+ this.highlightCode()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ highlightCode() {
|
|
|
+ const preEl = document.querySelectorAll('.code')
|
|
|
+ preEl.forEach(el => {
|
|
|
+ Hljs.highlightBlock(el)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ nextPage() {
|
|
|
+ const top = this.getCurrentScrollTop()
|
|
|
+ this.milestones.some(milestone => {
|
|
|
+ if (top < milestone - 10) {
|
|
|
+ this.scrollToY(top, milestone, 3, position =>
|
|
|
+ window.scrollTo(0, position)
|
|
|
+ )
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ lastPage() {
|
|
|
+ const currentPosition = this.getCurrentScrollTop()
|
|
|
+ let target = currentPosition
|
|
|
+ this.milestones.some(milestone => {
|
|
|
+ if (currentPosition > milestone + 10) {
|
|
|
+ target = milestone
|
|
|
+ } else {
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.scrollToY(currentPosition, target, 3, position =>
|
|
|
+ window.scrollTo(0, position)
|
|
|
+ )
|
|
|
+ },
|
|
|
+ getCurrentScrollTop() {
|
|
|
+ return document.documentElement.scrollTop || document.body.scrollTop
|
|
|
+ },
|
|
|
+ scrollToY(start, end, rate, callback) {
|
|
|
+ this.animating = true
|
|
|
+
|
|
|
+ let step = () => {
|
|
|
+ if (Math.abs(end - start) < 0.5) {
|
|
|
+ callback(end)
|
|
|
+ this.animating = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ start = start + (end - start) / rate
|
|
|
+ callback(start)
|
|
|
+ requestAnimationFrame(step)
|
|
|
+ }
|
|
|
+
|
|
|
+ step()
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- li > a,
|
|
|
- p > a {
|
|
|
- color: #1976d2;
|
|
|
- }
|
|
|
-
|
|
|
- img {
|
|
|
- max-width: 100%;
|
|
|
- max-height: 100vh;
|
|
|
- margin: 0.94em auto 1.88em auto;
|
|
|
- display: block;
|
|
|
- box-shadow: 0 0.13em 0.63em 0 #e5e5e5;
|
|
|
- }
|
|
|
-
|
|
|
- pre {
|
|
|
- padding: 0.63em 0.94em;
|
|
|
- border: gray 0.06em solid;
|
|
|
- }
|
|
|
-
|
|
|
- code {
|
|
|
- overflow: auto;
|
|
|
- word-break: normal;
|
|
|
- padding: 0 0.19em;
|
|
|
- font-family: 'Menlo', 'Courier New', monospace;
|
|
|
- color: #1899ba;
|
|
|
- font-size: 0.88em;
|
|
|
- }
|
|
|
}
|
|
|
-</style>
|
|
|
+</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-// 重置所有默认样式
|
|
|
-body {
|
|
|
- font-family: sans-serif;
|
|
|
-}
|
|
|
-
|
|
|
-html,
|
|
|
-body,
|
|
|
-div,
|
|
|
-h1,
|
|
|
-h2,
|
|
|
-h3,
|
|
|
-h4,
|
|
|
-h5,
|
|
|
-h6,
|
|
|
-p,
|
|
|
-dl,
|
|
|
-dt,
|
|
|
-dd,
|
|
|
-ol,
|
|
|
-ul,
|
|
|
-li,
|
|
|
-fieldset,
|
|
|
-form,
|
|
|
-label,
|
|
|
-input,
|
|
|
-legend,
|
|
|
-table,
|
|
|
-caption,
|
|
|
-tbody,
|
|
|
-tfoot,
|
|
|
-thead,
|
|
|
-tr,
|
|
|
-th,
|
|
|
-td,
|
|
|
-textarea,
|
|
|
-article,
|
|
|
-aside,
|
|
|
-audio,
|
|
|
-canvas,
|
|
|
-figure,
|
|
|
-footer,
|
|
|
-header,
|
|
|
-mark,
|
|
|
-menu,
|
|
|
-nav,
|
|
|
-section,
|
|
|
-time,
|
|
|
-video {
|
|
|
- margin: 0;
|
|
|
- padding: 0;
|
|
|
-}
|
|
|
-
|
|
|
-h1,
|
|
|
-h2,
|
|
|
-h3,
|
|
|
-h4,
|
|
|
-h5,
|
|
|
-h6 {
|
|
|
- font-size: 100%;
|
|
|
- font-weight: normal;
|
|
|
-}
|
|
|
-
|
|
|
-article,
|
|
|
-aside,
|
|
|
-dialog,
|
|
|
-figure,
|
|
|
-footer,
|
|
|
-header,
|
|
|
-hgroup,
|
|
|
-nav,
|
|
|
-section,
|
|
|
-blockquote {
|
|
|
- display: block;
|
|
|
-}
|
|
|
-
|
|
|
-ul,
|
|
|
-ol {
|
|
|
- list-style: none;
|
|
|
-}
|
|
|
-
|
|
|
-img {
|
|
|
- border: 0 none;
|
|
|
- vertical-align: top;
|
|
|
-}
|
|
|
-
|
|
|
-blockquote,
|
|
|
-q {
|
|
|
- quotes: none;
|
|
|
-}
|
|
|
-
|
|
|
-blockquote:before,
|
|
|
-blockquote:after,
|
|
|
-q:before,
|
|
|
-q:after {
|
|
|
- content: none;
|
|
|
-}
|
|
|
-
|
|
|
-table {
|
|
|
- border-collapse: collapse;
|
|
|
- border-spacing: 0;
|
|
|
-}
|
|
|
-
|
|
|
-strong,
|
|
|
-em,
|
|
|
-i {
|
|
|
- font-style: normal;
|
|
|
- font-weight: normal;
|
|
|
-}
|
|
|
-
|
|
|
-ins {
|
|
|
- text-decoration: underline;
|
|
|
-}
|
|
|
-
|
|
|
-del {
|
|
|
- text-decoration: line-through;
|
|
|
-}
|
|
|
-
|
|
|
-mark {
|
|
|
- background: none;
|
|
|
-}
|
|
|
-
|
|
|
-input::-ms-clear {
|
|
|
- display: none !important;
|
|
|
-}
|
|
|
-
|
|
|
-body {
|
|
|
- background: #fff;
|
|
|
-}
|
|
|
-
|
|
|
-a {
|
|
|
- text-decoration: none;
|
|
|
- color: #333;
|
|
|
-}
|
|
|
-
|
|
|
-a:hover {
|
|
|
- text-decoration: underline;
|
|
|
-}
|
|
|
+@import '@/common/reset.scss';
|
|
|
+@import '@/common/mode-common.scss';
|
|
|
+@import '@/common/read-mode.scss';
|
|
|
+@import '@/common/show-mode.scss';
|
|
|
</style>
|