├── .gitignore ├── src └── plugins │ └── preview │ ├── index.js │ └── preview.vue ├── README.md └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /src/plugins/preview/index.js: -------------------------------------------------------------------------------- 1 | import Vue2Preview from './preview.vue' 2 | 3 | export default { 4 | install(Vue, options) { 5 | Vue.mixin({ 6 | components: { 7 | 'vue-preview': Vue2Preview 8 | } 9 | }) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vue preview plugin 2 | 3 | > 一个Vue集成[PhotoSwipe](https://github.com/dimsemenov/PhotoSwipe)图片预览插件,支持 vue-cli2 和 vue-cli3 4 | 5 | ![](https://img.shields.io/npm/dm/vue2-preview.svg) 6 | ![](https://img.shields.io/npm/v/vue2-preview.svg) 7 | 8 | ## Requirements 9 | 10 | [PhotoSwipe](https://github.com/dimsemenov/PhotoSwipe) 11 | 12 | ## Installation 13 | 14 | ```bash 15 | npm i vue2-preview -S 16 | ``` 17 | 18 | ## Usage 19 | 20 | ### Install plugin 21 | 22 | ``` javascript 23 | import VuePreview from 'vue2-preview' 24 | Vue.use(VuePreview) 25 | ``` 26 | 27 | ### Examples 28 | 29 | ```jsx 30 | 42 | 43 | 73 | ``` 74 | 75 | ### 参数说明: 76 | 77 | | 参数 | 说明 | 类型 | 必需 78 | | :--: | :--: | :--: | :--: 79 | | list |图片列表 | Array | 是 80 | | thumbImageStyle |缩略图的样式| Object | 否 81 | | previewBoxStyle |缩略图容器的样式| Object | 否 82 | | tapToClose |是否允许单击关闭| Boolean | 否 83 | | close |监听预览窗口关闭的事件(关闭前触发)| Function | 否 84 | | destroy |监听预览窗口销毁的事件(关闭后触发)| Function | 否 85 | 86 | ## License 87 | 88 | ![](https://img.shields.io/badge/license-MIT-blue.svg) 89 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue2-preview", 3 | "version": "1.0.5", 4 | "description": "A Vue2 image preview plugin", 5 | "main": "src/plugins/preview/index.js", 6 | "scripts": { 7 | "dev": "node build/dev-server.js", 8 | "build": "node build/build.js", 9 | "unit": "karma start test/unit/karma.conf.js --single-run", 10 | "e2e": "node test/e2e/runner.js", 11 | "test": "npm run unit && npm run e2e", 12 | "lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs" 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "git+https://github.com/daidaitu1314/vue2-preview.git" 17 | }, 18 | "keywords": [ 19 | "vue", 20 | "preview", 21 | "photoswipe" 22 | ], 23 | "author": "liulongbin", 24 | "license": "MIT", 25 | "bugs": { 26 | "url": "https://github.com/daidaitu1314/vue2-preview/issues" 27 | }, 28 | "dependencies": { 29 | "photoswipe": "^4.1.2" 30 | }, 31 | "devDependencies": { 32 | "autoprefixer": "^6.4.0", 33 | "babel-core": "^6.0.0", 34 | "babel-eslint": "^7.0.0", 35 | "babel-loader": "^6.0.0", 36 | "babel-plugin-transform-runtime": "^6.0.0", 37 | "babel-preset-es2015": "^6.0.0", 38 | "babel-preset-stage-2": "^6.0.0", 39 | "babel-register": "^6.0.0", 40 | "connect-history-api-fallback": "^1.1.0", 41 | "css-loader": "^0.25.0", 42 | "eslint": "^3.7.1", 43 | "eslint-friendly-formatter": "^2.0.5", 44 | "eslint-loader": "^1.5.0", 45 | "eslint-plugin-html": "^1.3.0", 46 | "eslint-config-standard": "^6.1.0", 47 | "eslint-plugin-promise": "^2.0.1", 48 | "eslint-plugin-standard": "^2.0.1", 49 | "eventsource-polyfill": "^0.9.6", 50 | "express": "^4.13.3", 51 | "extract-text-webpack-plugin": "^1.0.1", 52 | "file-loader": "^0.9.0", 53 | "function-bind": "^1.0.2", 54 | "html-webpack-plugin": "^2.8.1", 55 | "http-proxy-middleware": "^0.17.2", 56 | "json-loader": "^0.5.4", 57 | "karma": "^1.3.0", 58 | "karma-coverage": "^1.1.1", 59 | "karma-mocha": "^1.2.0", 60 | "karma-phantomjs-launcher": "^1.0.0", 61 | "karma-sinon-chai": "^1.2.0", 62 | "karma-sourcemap-loader": "^0.3.7", 63 | "karma-spec-reporter": "0.0.26", 64 | "karma-webpack": "^1.7.0", 65 | "lolex": "^1.4.0", 66 | "mocha": "^3.1.0", 67 | "chai": "^3.5.0", 68 | "sinon": "^1.17.3", 69 | "sinon-chai": "^2.8.0", 70 | "inject-loader": "^2.0.1", 71 | "isparta-loader": "^2.0.0", 72 | "phantomjs-prebuilt": "^2.1.3", 73 | "chromedriver": "^2.21.2", 74 | "cross-spawn": "^4.0.2", 75 | "nightwatch": "^0.9.8", 76 | "selenium-server": "2.53.1", 77 | "opn": "^4.0.2", 78 | "ora": "^0.3.0", 79 | "shelljs": "^0.7.4", 80 | "url-loader": "^0.5.7", 81 | "vue": "^2.0.1", 82 | "vue-loader": "^9.4.0", 83 | "vue-style-loader": "^1.0.0", 84 | "webpack": "^1.13.2", 85 | "webpack-dev-middleware": "^1.8.3", 86 | "webpack-hot-middleware": "^2.12.2", 87 | "webpack-merge": "^0.14.1" 88 | } 89 | } -------------------------------------------------------------------------------- /src/plugins/preview/preview.vue: -------------------------------------------------------------------------------- 1 | 76 | 77 | 195 | --------------------------------------------------------------------------------