Skip to content

Commit 5ba9d55

Browse files
committed
module 2 - vue cli
1 parent 1251cd8 commit 5ba9d55

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+509
-25768
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ dist
1010
.basement
1111
config.local.js
1212
basement_dist
13+
mod2
14+
mod3

docs/.vuepress/config.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ module.exports = {
4343
text: 'Vuex',
4444
link: '/vuex/',
4545
},
46+
{
47+
text: 'Advanced',
48+
link: '/advanced/',
49+
},
4650
{
4751
text: 'AscoMusic',
4852
link: '/project/',
@@ -74,7 +78,6 @@ module.exports = {
7478
collapsable: false,
7579
children: [
7680
'',
77-
'custom',
7881
'router'
7982
]
8083
}
@@ -88,12 +91,24 @@ module.exports = {
8891
]
8992
}
9093
],
94+
'/advanced/': [
95+
{
96+
title: 'Conceptos Avanzados',
97+
collapsable: false,
98+
children: [
99+
'',
100+
'production',
101+
]
102+
}
103+
],
91104
'/project/': [
92105
{
93106
title: 'AscoMusic',
94107
collapsable: false,
95108
children: [
96109
'',
110+
'views',
111+
'api',
97112
]
98113
}
99114
],

docs/advanced/README.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Plugins & Servicios
2+
```js
3+
MyPlugin.install = function (Vue, options) {
4+
// 1. agregar método global o propiedad
5+
Vue.myGlobalMethod = function () {
6+
// algo de lógica...
7+
}
8+
9+
// 2. agregar un recurso global
10+
Vue.directive('my-directive', {
11+
bind (el, binding, vnode, oldVnode) {
12+
// algo de lógica...
13+
}
14+
...
15+
})
16+
17+
// 3. inyectar algunas opciones de componentes
18+
Vue.mixin({
19+
created: function () {
20+
// algo de lógica...
21+
}
22+
...
23+
})
24+
25+
// 4. agregar un método de instancia
26+
Vue.prototype.$myMethod = function (methodOptions) {
27+
// algo de lógica...
28+
}
29+
}
30+
```
31+
32+
# Filtros
33+
```js
34+
const msToMm = {}
35+
36+
function convertMsToMm (ms) {
37+
const min = Math.floor(ms / 60000)
38+
const sec = ((ms % 60000) / 1000).toFixed(0)
39+
40+
return `${min}:${sec < 10 ? `00` : sec} min`
41+
}
42+
43+
msToMm.install = function (Vue) {
44+
Vue.filter('msToMm', val => {
45+
return convertMsToMm(val)
46+
})
47+
}
48+
49+
export default msToMm
50+
51+
```
52+
53+
# Mixins
54+
```js
55+
const myOwnMixin = {
56+
data() {
57+
return {}
58+
},
59+
methods: {},
60+
computed: {}
61+
}
62+
}
63+
64+
export default myOwnMixin
65+
```
66+
67+
68+
# Directivas
69+
```js
70+
const blur = {}
71+
72+
function setBlur (el, binding) {
73+
el.style.filter = !binding.value ? 'blur(3px)' : '(none)'
74+
el.style.filter = !binding.value ? 'not-allowed' : 'inherit'
75+
76+
el.querySelectorAll('a').forEach(element => {
77+
if (!binding.value) {
78+
element.setAttribute('disabled', true)
79+
} else {
80+
element.removeAttribute('disabled')
81+
}
82+
})
83+
}
84+
85+
blur.install = function (Vue) {
86+
Vue.directive('blur', {
87+
bind (el, binding) {
88+
setBlur(el, binding)
89+
}
90+
})
91+
}
92+
93+
export default blur
94+
```
95+
96+
97+
# Watchers
98+
```js
99+
export default {
100+
data() {
101+
return {
102+
value: 0
103+
}
104+
},
105+
watch: {
106+
value(val) {
107+
console.log('algo ha cambiado!!!')
108+
}
109+
}
110+
}
111+
```

docs/advanced/production.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Puesta en producción
2+
3+
$ npm run build
4+
5+
## Github Pages
6+
7+
$ npm i gh-pages
8+
9+
> publish.js
10+
```js
11+
const ghpages = require('gh-pages')
12+
const BRANCH = 'gh-pages'
13+
const FOLDER_DIST = 'dist'
14+
15+
const TODAY = new Date().toLocaleString()
16+
17+
console.log(`start publishing folder ${FOLDER_DIST} to ${BRANCH}`)
18+
19+
ghpages.publish(FOLDER_DIST, {
20+
branch: BRANCH,
21+
message: `Publishing folder ${FOLDER_DIST} to ${BRANCH} in ${TODAY}`
22+
}, () => {
23+
console.log(`done publishing folder ${FOLDER_DIST} to ${BRANCH}`)
24+
})
25+
26+
```
27+
28+
$ node publish.js
29+
30+
31+
## vue.config.js
32+
33+
```js
34+
module.exports = {
35+
publicPath: '/adc-music'
36+
}
37+
```

docs/cli/custom.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

docs/cli/router.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,33 @@
11
# Enrutamiento
2+
```js
3+
import Vue from "vue";
4+
import VueRouter from "vue-router";
5+
import Home from "@/views/HelloWorld";
26

7+
Vue.use(VueRouter);
38

4-
# Peticiones HTTP
9+
const routes = [
10+
{
11+
path: "/",
12+
name: "Home",
13+
component: Home // importacion desde una variable
14+
},
15+
{
16+
path: "/todo-list",
17+
name: "TodoList",
18+
component: () => import('@/views/TodoList') // importación directa
19+
}
20+
];
21+
22+
const router = new VueRouter({
23+
mode: 'history', // por defecto es hash
24+
routes
25+
});
526

27+
export default router;
628

7-
# Poniendo en producción
29+
```
30+
31+
# Peticiones HTTP
832

9-
# Vue config.js
33+
$ npm i axios

docs/project/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,14 @@
22

33
[Demo](https://adc-music.herokuapp.com/)
44

5-
## API Backend
5+
## Instalación
6+
$ vue create adc-music
7+
$ cd adc-music
8+
$ npm run serve
9+
10+
## Features
11+
- Babel
12+
- Vue Router
13+
- Vuex
14+
- Buefy
15+
- Axios

docs/project/api.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# API Backend
2+
3+
> **API Root** https://adc-spotify-api.herokuapp.com
4+
5+
## User Login
6+
7+
> **GET** /callback?code=AQAgj5zSW8HfWdU0e8gI....
8+
9+
### Query params
10+
| Name | Type | Description
11+
|---|---|---|
12+
| **code** | *string* | Código de autorización devuelto por OAuth de Spotify |
13+
14+
15+
### Response
16+
```json
17+
HTTP/1.0 200 OK
18+
19+
{
20+
"access_token":"BQDcJpa-mzM12bDO85YV3_vkm6u...q2X29d5KtYikezw-QY43ldjQ",
21+
"token_type":"Bearer",
22+
"expires_in":3600,
23+
"refresh_token":"AQCD1uBOMwE5E0tf1rYA5...ygeE8BwgDEin4s",
24+
"scope":"user-read-email user-read-private"
25+
}
26+
```
27+
## Search Track
28+
29+
> **GET** /search?q=rock&type=track&offset=0
30+
### Query params
31+
| Name | Type | Description
32+
|---|---|---|
33+
| **q** | *string* | Artista, género, canción a buscar |
34+
| **type** | *string* | **track** / **album** / **artist** |
35+
| **offset** | *number* | desplazamiento por paginación |
36+
37+
38+
### Response
39+
```json
40+
HTTP/1.0 200 OK
41+
42+
{
43+
"tracks": {
44+
"href":"https://api.spotify.com/v1/search?query=f&type=track&offset=0&limit=20",
45+
"items":[...],
46+
"limit":20,
47+
"next":"https://api.spotify.com/v1/search?query=f&type=track&offset=0&limit=20","offset":0,
48+
"previous":null,
49+
"total":98
50+
}
51+
}
52+
```

0 commit comments

Comments
 (0)