mirror of https://github.com/Requarks/wiki.git
10 changed files with 117 additions and 14 deletions
Split View
Diff Options
-
4client/js/app.js
-
51client/js/components/anchor.vue
-
2client/js/store/index.js
-
23client/js/store/modules/anchor.js
-
1package.json
-
11server/libs/markdown.js
-
2server/views/pages/admin/users.pug
-
3server/views/pages/view.pug
-
2server/views/pages/welcome.pug
-
32yarn.lock
@ -1,16 +1,53 @@ |
|||
<template> |
|||
<div> |
|||
<p>{{ msg }}</p> |
|||
<input type="text" v-model="msg" /> |
|||
</div> |
|||
<template lang="pug"> |
|||
.modal(v-bind:class='{ "is-active": isShown }') |
|||
.modal-background |
|||
.modal-container |
|||
.modal-content |
|||
header.is-blue |
|||
span Copy link to this section |
|||
section |
|||
p.control.is-fullwidth |
|||
input.input(type='text', ref='anchorURLinput', v-model='anchorURL') |
|||
footer |
|||
a.button.is-grey.is-outlined(v-on:click='cancel') Discard |
|||
a.button.is-blue(v-clipboard='anchorURL', @success="clipboardSuccess", @error="clipboardError") Copy to Clipboard |
|||
</template> |
|||
|
|||
<script> |
|||
import * as _ from 'lodash' |
|||
|
|||
export default { |
|||
name: 'anchor', |
|||
data () { |
|||
return { |
|||
msg: 'Welcome to Your Vue.js App' |
|||
return {} |
|||
}, |
|||
computed: { |
|||
anchorURL () { |
|||
return window.location.href.split('#')[0] + '#' + this.$store.state.anchor.hash |
|||
}, |
|||
isShown () { |
|||
return this.$store.state.anchor.shown |
|||
} |
|||
}, |
|||
methods: { |
|||
cancel () { |
|||
this.$store.dispatch('anchorClose') |
|||
}, |
|||
clipboardSuccess () { |
|||
this.$store.dispatch('alert', { |
|||
style: 'blue', |
|||
icon: 'clipboard', |
|||
msg: 'The URL has been copied to your clipboard.' |
|||
}) |
|||
this.$store.dispatch('anchorClose') |
|||
}, |
|||
clipboardError () { |
|||
this.$store.dispatch('alert', { |
|||
style: 'red', |
|||
icon: 'clipboard', |
|||
msg: 'Clipboard copy failed. Copy the URL manually.' |
|||
}) |
|||
this.$refs.anchorURLinput.select() |
|||
} |
|||
} |
|||
} |
|||
|
@ -0,0 +1,23 @@ |
|||
'use strict' |
|||
|
|||
export default { |
|||
state: { |
|||
shown: false, |
|||
hash: '' |
|||
}, |
|||
getters: {}, |
|||
mutations: { |
|||
anchorChange: (state, opts) => { |
|||
state.shown = (opts.shown === true) |
|||
state.hash = opts.hash || '' |
|||
} |
|||
}, |
|||
actions: { |
|||
anchorOpen({ commit, dispatch }, hash) { |
|||
commit('anchorChange', { shown: true, hash }) |
|||
}, |
|||
anchorClose({ commit, dispatch }) { |
|||
commit('anchorChange', { shown: false }) |
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save