├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.yml
│ ├── docs_feedback.yml
│ ├── feature_request.yml
│ └── question.yml
└── workflows
│ └── static.yml
├── .gitignore
├── LICENSE
├── README.en.md
├── README.md
├── demos
├── vue2-demo
│ ├── .gitignore
│ ├── .npmrc
│ ├── README.md
│ ├── babel.config.js
│ ├── jsconfig.json
│ ├── package.json
│ ├── pnpm-lock.yaml
│ ├── public
│ │ ├── favicon.ico
│ │ └── index.html
│ ├── src
│ │ ├── App.vue
│ │ ├── assets
│ │ │ └── logo.png
│ │ ├── main.js
│ │ ├── router
│ │ │ └── index.js
│ │ ├── style.css
│ │ └── views
│ │ │ ├── PrintAsyncUrl.vue
│ │ │ ├── PrintBasic.vue
│ │ │ ├── PrintBasicTwo.vue
│ │ │ ├── PrintCanvas.vue
│ │ │ ├── PrintForm.vue
│ │ │ ├── PrintIframe.vue
│ │ │ └── PrintUrl.vue
│ └── vue.config.js
└── vue3-demo
│ ├── .gitignore
│ ├── .vscode
│ └── extensions.json
│ ├── README.md
│ ├── index.html
│ ├── package.json
│ ├── public
│ ├── vite.svg
│ └── vue3-print.pdf
│ ├── src
│ ├── App.vue
│ ├── assets
│ │ ├── shared-styles.css
│ │ ├── styles
│ │ │ └── common.css
│ │ └── vue.svg
│ ├── components
│ │ └── PrintPageLayout.vue
│ ├── main.ts
│ ├── router
│ │ └── index.ts
│ ├── style.css
│ ├── utils
│ │ └── common.ts
│ ├── views
│ │ ├── CustomPreviewTools.vue
│ │ ├── PrintAdvanced.vue
│ │ ├── PrintAsyncUrl.vue
│ │ ├── PrintBaiduMap.vue
│ │ ├── PrintBasic.vue
│ │ ├── PrintBasicTwo.vue
│ │ ├── PrintCallbacks.vue
│ │ ├── PrintCanvas.vue
│ │ ├── PrintForm.vue
│ │ ├── PrintIframe.vue
│ │ ├── PrintPaperSizes.vue
│ │ ├── PrintPdf.vue
│ │ ├── PrintPreviewSize.vue
│ │ ├── PrintTable.vue
│ │ └── PrintUrl.vue
│ └── vite-env.d.ts
│ ├── tsconfig.app.json
│ ├── tsconfig.json
│ ├── tsconfig.node.json
│ └── vite.config.ts
├── docs
├── .vitepress
│ └── config.mts
├── guide
│ ├── api.md
│ ├── faq.md
│ ├── getting-started.md
│ ├── impl-principle.md
│ ├── life-cycle.md
│ ├── migration-from-vue-print-nb.md
│ ├── preview-tools.md
│ └── what-is-vue-print-next.md
├── index.md
├── package.json
└── public
│ └── logo.png
├── index.html
├── package.json
├── pnpm-lock.yaml
├── pnpm-workspace.yaml
├── public
├── favicon.ico
└── logo.png
├── src
├── App.vue
├── assets
│ └── logo.png
├── components
│ └── HelloWorld.vue
├── index.css
├── main.ts
├── print
│ ├── index.ts
│ └── packages
│ │ ├── VuePrintNext.ts
│ │ └── vPrint.ts
└── vite-env.d.ts
├── tsconfig.app.json
├── tsconfig.json
├── tsconfig.node.json
├── types
└── index.d.ts
└── vite.config.ts
/.github/ISSUE_TEMPLATE/bug_report.yml:
--------------------------------------------------------------------------------
1 | name: '🐞 Bug report'
2 | description: Create a report to help us improve / 创建报告以帮助我们改进
3 | title: '[Bug]: '
4 | labels: ['status: waiting for maintainer']
5 | body:
6 | - type: markdown
7 | attributes:
8 | value: |
9 | Report errors and exceptions found in the project.
10 |
11 | Before submitting a new bug/issue, please check the links below to see if there is a solution or if the issue has already been reported:
12 |
13 | 在提交新 issue 之前,先通过以下链接检查是否存在相同问题:
14 |
15 | > [Issues](https://github.com/Alessandro-Pang/vue-print-next/issues) | [Closed Issues](https://github.com/Alessandro-Pang/vue-print-next/issues?q=is%3Aissue+is%3Aclosed)
16 |
17 | - type: textarea
18 | id: description
19 | attributes:
20 | label: Describe the bug / 问题描述
21 | placeholder: |
22 | Please provide a clear and concise description of the bug you encountered. Include screenshots if they help explain the problem better.
23 | 请提供清晰简洁的问题描述。如果可以的话,请添加截图以便更好地说明问题。
24 |
25 | If you need to share code, please use Markdown code block syntax as shown below:
26 | 如果包含代码块,请使用下面展示的 Markdown 代码块语法:
27 |
28 | ```javascript
29 | // Your code here
30 | ```
31 | validations:
32 | required: true
33 |
34 | - type: input
35 | id: link
36 | attributes:
37 | label: Reproduction link / 复现链接
38 | placeholder: |
39 | Provide a link to a minimal reproduction of the issue, such as on CodeSandbox or StackBlitz.
40 | CodeSandbox / StackBlitz / ...
41 |
42 | 提供一个最小复现问题的链接,例如 CodeSandbox 或 StackBlitz。
43 | validations:
44 | required: false
45 |
46 | - type: textarea
47 | id: steps
48 | attributes:
49 | label: Steps to Reproduce the Bug or Issue / 重现步骤
50 | placeholder: |
51 | List the steps to reproduce the bug. For example:
52 | 1. Go to '...'
53 | 2. Click on '...'
54 | 3. Scroll down to '...'
55 | 4. See error
56 | validations:
57 | required: false
58 |
59 | - type: dropdown
60 | id: version
61 | attributes:
62 | label: Version / 版本
63 | options:
64 | - Please select / 请选择
65 | - 1.x
66 | - 0.x
67 | validations:
68 | required: true
69 |
70 | - type: checkboxes
71 | id: OS
72 | attributes:
73 | label: OS / 操作系统
74 | options:
75 | - label: macOS
76 | - label: Windows
77 | - label: Linux
78 | - label: Others / 其他
79 | validations:
80 | required: true
81 |
82 | - type: checkboxes
83 | id: Browser
84 | attributes:
85 | label: Browser / 浏览器
86 | options:
87 | - label: Chrome
88 | - label: Edge
89 | - label: Firefox
90 | - label: Safari (Limited support / 有限支持)
91 | - label: IE (Nonsupport / 不支持)
92 | - label: Others / 其他
93 | validations:
94 | required: true
95 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/docs_feedback.yml:
--------------------------------------------------------------------------------
1 | name: '📚 Docs Feedback'
2 | description: Improve documentation to make it more user-friendly and accessible / 助力打造更易于上手操作以及便捷查阅的文档
3 | labels: ['status: waiting for maintainer', 'docs-feedback']
4 | title: '[docs] '
5 | body:
6 | - type: input
7 | id: page-url
8 | attributes:
9 | label: Related Page / 相关页面
10 | description: Which page of the documentation is this about? / 这是关于文档的哪个页面?
11 | placeholder: https://alexpang.cn/vue-print-next/docs/
12 | validations:
13 | required: true
14 | - type: dropdown
15 | id: issue-kind
16 | attributes:
17 | label: Kind of Issue / 问题类型
18 | description: What kind of problem are you facing? / 您遇到了什么类型的问题?
19 | options:
20 | - Unclear explanations / 解释不清
21 | - Missing information / 信息缺失
22 | - Broken demo / 示例损坏
23 | - Other / 其他
24 | validations:
25 | required: true
26 | - type: textarea
27 | id: issue-description
28 | attributes:
29 | label: Issue Description / 问题描述
30 | description: |
31 | Let us know what went wrong when you were using this documentation and what we could do to improve it / 请告知您在使用此文档时遇到的问题以及我们可以改进的地方
32 | placeholder: |
33 | Please describe the issue in detail. / 请详细描述问题。
34 | - type: textarea
35 | id: context
36 | attributes:
37 | label: Context / 上下文
38 | description: What are you trying to accomplish? Providing context helps us come up with a solution that is more useful in the real world / 您希望实现什么目标?提供上下文有助于我们提出更实用的解决方案
39 | placeholder: |
40 | Describe your goal or task. / 描述您的目标或任务。
41 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.yml:
--------------------------------------------------------------------------------
1 | name: '💡 Feature Request'
2 | description: I have a suggestion (and may want to implement it) / 我有一个建议(或者想参与贡献)
3 | title: '[Feat]: '
4 | labels: ['status: waiting for maintainer']
5 | body:
6 | - type: textarea
7 | id: description
8 | attributes:
9 | label: Describe the feature / 功能描述
10 | validations:
11 | required: true
12 |
13 | - type: dropdown
14 | attributes:
15 | label: Are you willing to contribute? / 是否愿意参与贡献?
16 | options:
17 | - Please select / 请选择
18 | - ✅ Yes / 是
19 | - ❌ No / 否
20 | validations:
21 | required: true
22 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/question.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: '💬 Question'
3 | description: Ask questions about the project / 提问关于项目的问题
4 | title: '[Ques]: '
5 | labels: ['status: waiting for maintainer']
6 | body:
7 | - type: textarea
8 | id: description
9 | attributes:
10 | label: Describe the Question / 问题描述
11 | placeholder: |
12 | Please provide a clear and concise description of the question you have. / 请提供清晰简洁的问题描述。
13 | Include any relevant context or details that might help in understanding your question. / 包含任何可能有助于理解您问题的相关背景或细节。
14 |
15 | ---
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.github/workflows/static.yml:
--------------------------------------------------------------------------------
1 | # Simple workflow for deploying static content to GitHub Pages
2 | name: Deploy static content to Pages
3 |
4 | on:
5 | # Runs on pushes targeting the default branch
6 | push:
7 | branches: ['master']
8 |
9 | # Allows you to run this workflow manually from the Actions tab
10 | workflow_dispatch:
11 |
12 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13 | permissions:
14 | contents: read
15 | pages: write
16 | id-token: write
17 |
18 | # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19 | # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20 | concurrency:
21 | group: 'pages'
22 | cancel-in-progress: false
23 |
24 | jobs:
25 | # Single deploy job since we're just deploying
26 | deploy:
27 | environment:
28 | name: github-pages
29 | url: ${{ steps.deployment.outputs.page_url }}
30 | runs-on: ubuntu-latest
31 | steps:
32 | - name: Checkout
33 | uses: actions/checkout@v4
34 | - name: Setup Pages
35 | uses: actions/configure-pages@v4
36 | - run: npm install -g pnpm@^7
37 | - run: pnpm install
38 | - run: pnpm build
39 | - run: pnpm -r build
40 | - run: mkdir web && cp -r ./demos/vue3-demo/dist ./web/vue3-demo && cp -r ./docs/.vitepress/dist ./web/docs
41 | - name: Upload artifact
42 | uses: actions/upload-pages-artifact@v3
43 | with:
44 | # Upload entire repository
45 | path: './web'
46 | - name: Deploy to GitHub Pages
47 | id: deployment
48 | uses: actions/deploy-pages@v4
49 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | pnpm-debug.log*
8 | lerna-debug.log*
9 |
10 | node_modules
11 | dist
12 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
26 | docs/.vitepress/cache
27 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 zi.yang
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
14 |
15 | 
16 |
17 | [English](./README.en.md) | 简体中文
18 |
19 | > Vue 打印插件,简单、快速、方便、轻巧,支持 Vue 2 和 Vue 3。
20 |
21 | 本插件基于 [vue3-print-nb](https://github.com/Power-kxLee/vue3-print-nb) 开发,并使用 TypeScript 完全重写,以更好地支持 Vue 3 的 setup 函数和组合式 API。
22 |
23 | ## 📚 文档
24 |
25 | 在线文档:[https://alexpang.cn/vue-print-next/docs](https://alexpang.cn/vue-print-next/docs)
26 |
27 | ## ✨ 特性
28 |
29 | - 支持 Vue 2 和 Vue 3,兼容性强
30 | - 支持指令调用和手动调用 `VuePrintNext` 方法进行打印
31 | - 完全支持 Vue 3 的 setup 函数和组合式 API
32 | - 支持全局和局部内容打印,以及打印预览功能
33 | - 支持设置指定 class 样式的元素忽略打印
34 | - 支持通过 css 选择器、手动传入 Dom 节点进行局部打印
35 | - 支持自定义纸张尺寸和方向
36 | - 支持深色模式和窗口模式
37 | - 支持打印工具栏自定义配置
38 | - 支持响应式设计,适配不同设备
39 | - 提供丰富的回调函数,满足各种打印场景需求
40 |
41 | ## 🔍 Demo
42 |
43 | 项目中提供了 Vue2 和 Vue3 的 demo 源码,可以 clone 下本项目后进行查看
44 |
45 | - **Vue2:** /demos/vue2-demo
46 | - **Vue3:** /demos/vue3-demo
47 |
48 | 在线 demo:[https://alexpang.cn/vue-print-next/vue3-demo](https://alexpang.cn/vue-print-next/vue3-demo)
49 |
50 | ## 📦 安装
51 |
52 | 你可以通过 npm、yarn 或 pnpm 安装该插件:
53 |
54 | ```bash
55 | npm install vue-print-next --save
56 | # or
57 | yarn add vue-print-next
58 | # or
59 | pnpm add vue-print-next
60 | ```
61 |
62 | ## 🚀 快速开始
63 |
64 | ### 1. 全局使用插件
65 |
66 | 在你的 `main.ts` 或 `main.js` 文件中:
67 |
68 | ```typescript
69 | import {createApp} from 'vue';
70 | import App from './App.vue';
71 | import {printPlugin} from 'vue-print-next';
72 |
73 | const app = createApp(App);
74 | app.use(printPlugin);
75 | app.mount('#app');
76 | ```
77 |
78 | ### 2. Vue3 在组件中使用指令
79 |
80 | ```html
81 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
这是需要打印的局部内容
92 |
更多内容...
93 |
94 |
95 |
96 | ```
97 |
98 | ### 3. Vue2 在组件中使用指令
99 |
100 | ```html
101 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
这是需要打印的局部内容
118 |
更多内容...
119 |
120 |
121 |
122 | ```
123 |
124 | ### 4. 使用 `VuePrintNext` 类
125 |
126 | 如果你需要更复杂的打印逻辑,可以直接使用 `VuePrintNext` 类:
127 |
128 | ```html
129 |
136 |
137 |
138 |
144 |
145 | ```
146 |
147 | ## 📋 API 详解
148 |
149 | ### `vPrint` 指令
150 |
151 | - **全屏打印**:``
152 | - **局部打印**:``,其中 `#printMe` 是需要打印的 DOM 元素选择器。
153 |
154 | ### `VuePrintNext` 类
155 |
156 | 用于手动调用打印功能。
157 |
158 | #### 参数说明
159 |
160 | | 参数 | 类型 | 说明 | 默认值 |
161 | |-----------------------------|---------------------------|-------------------------------------|------------|
162 | | `el` | `string` \| `HtmlElement` | 需要打印的元素,支持 css 选择器或 dom 节点 | - |
163 | | `standard` | `string` | 文档类型,默认是html5,可选 html5,loose,strict | 'html5' |
164 | | `noPrintSelector` | `string[]` \| `string` | 打印时需要忽略的 css 选择器 | - |
165 | | `popTitle` | `string` | 打印时的页眉 | 默认当前 title |
166 | | `preview` | `boolean` | 是否启用打印预览功能 | `false` |
167 | | `previewTitle` | `string` | 预览窗口的标题 | '打印预览' |
168 | | `previewPrintBtnLabel` | `string` | 预览窗口中的打印按钮标签 | '打印' |
169 | | `extraCss` | `string` | 额外的 CSS 文件路径 | - |
170 | | `extraHead` | `string` | 额外的 `` 内容 | - |
171 | | `url` | `string` | 打印指定的网址内容 | - |
172 | | `asyncUrl` | `function` | 异步加载 URL 内容的方法 | - |
173 | | `zIndex` | `number` | 预览窗口的 `z-index`值 | 20002 |
174 | | `paperSize` | `string` | 纸张尺寸,可选值包括 'A0' 到 'A8'、'Letter'、'Legal'、'Tabloid'、'custom' | 'A4' |
175 | | `orientation` | `string` | 纸张方向,可选值为 'portrait'(纵向)或 'landscape'(横向) | 'portrait' |
176 | | `customSize` | `object` | 自定义纸张尺寸,仅当 paperSize 为 'custom' 时生效 | - |
177 | | `darkMode` | `boolean` | 预览窗口是否默认使用深色模式 | `false` |
178 | | `windowMode` | `boolean` | 预览窗口是否默认使用弹窗模式(非全屏) | `false` |
179 | | `defaultScale` | `number` | 预览窗口默认缩放比例 | 1 |
180 | | `previewTools` | `object \| boolean` | 预览工具栏配置,控制显示哪些工具按钮(zoom、theme、fullscreen) | `{ zoom: true, theme: true, fullscreen: true }` |
181 | | `openCallback` | `function` | 打印窗口打开时的回调 | - |
182 | | `closeCallback` | `function` | 打印窗口关闭时的回调 | - |
183 | | `beforeOpenCallback` | `function` | 打印窗口打开前的回调(打印预览使用) | - |
184 | | `previewBeforeOpenCallback` | `function` | 预览框架 iframe 加载前的回调(预览使用) | - |
185 | | `previewOpenCallback` | `function` | 预览框架 iframe 加载完成后的回调(预览使用) | - |
186 |
187 | ## 🌰 使用示例
188 |
189 | ### 打印整个页面
190 |
191 | ```html
192 |
193 | ```
194 |
195 | ### 打印局部内容
196 |
197 | 通过指定 `id` 参数打印局部内容:
198 |
199 | ```html
200 |
203 |
204 |
205 | ```
206 |
207 | ### 使用 ref 获取打印元素
208 |
209 | 允许传入一个 dom 节点,如下,可以通过 `ref` 获取打印元素
210 |
211 | ```html
212 |
222 |
223 |
224 |
227 |
228 |
229 |
230 | ```
231 |
232 | ### 传递对象参数
233 |
234 | ```html
235 |
236 |
241 |
242 |
243 |
244 |
245 |
258 | ```
259 |
260 | ### 打印 URL
261 |
262 | 通过指定 URL 打印,并确保你的 URL 符合同源策略:
263 |
264 | ```html
265 |
266 |
267 |
268 |
269 |
274 | ```
275 |
276 | ### 忽略不需要打印的元素
277 |
278 | 通过设置 `noPrintSelector` 参数忽略不需要打印的元素:
279 |
280 | ```html
281 |
282 |
283 |
葫芦娃,葫芦娃
284 |
这是不需要打印
285 |
一根藤上七朵花
286 |
这是不需要打印
287 |
风吹雨打都不怕
288 |
这是不需要打印
289 |
290 |
291 |
292 |
293 |
300 | ```
301 |
302 | ### 异步加载 URL 内容
303 |
304 | 如果你的 URL 需要异步加载,可以使用以下方法:
305 |
306 | ```html
307 |
308 |
309 |
310 |
311 |
320 | ```
321 |
322 | ### 设置纸张尺寸和方向
323 |
324 | 可以通过 `paperSize` 和 `orientation` 参数设置打印纸张的尺寸和方向:
325 |
326 | ```html
327 |
328 |
331 |
332 |
333 |
334 |
342 | ```
343 |
344 | ### 自定义纸张尺寸
345 |
346 | 当需要使用非标准纸张尺寸时,可以设置 `paperSize` 为 `'custom'` 并提供 `customSize` 参数:
347 |
348 | ```html
349 |
350 |
353 |
354 |
355 |
356 |
368 | ```
369 |
370 | ### 深色模式和窗口模式
371 |
372 | 可以通过 `darkMode` 和 `windowMode` 参数设置预览界面的显示模式:
373 |
374 | ```html
375 |
376 |
379 |
380 |
381 |
382 |
391 | ```
392 |
393 | ### 自定义预览工具栏
394 |
395 | 可以通过 `previewTools` 参数自定义预览工具栏的显示:
396 |
397 | ```html
398 |
399 |
402 |
403 |
404 |
405 |
417 | ```
418 |
419 | ## 🤝 贡献指南
420 |
421 | 1. Fork 本仓库
422 | 2. 创建你的特性分支 (`git checkout -b feature/amazing-feature`)
423 | 3. 提交你的更改 (`git commit -m 'Add some amazing feature'`)
424 | 4. 推送到分支 (`git push origin feature/amazing-feature`)
425 | 5. 开启一个 Pull Request
426 |
427 | ## ⭐ Star History
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 | ## 👥 Supporters
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 | ## 📄 License
456 |
457 | [MIT](http://opensource.org/licenses/MIT)
458 |
459 | ---
460 |
461 | 欢迎在 [GitHub Issues](https://github.com/Alessandro-Pang/vue-print-next/issues) 上讨论并提出问题或提交 Pull Request!
462 |
--------------------------------------------------------------------------------
/demos/vue2-demo/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 |
6 | # local env files
7 | .env.local
8 | .env.*.local
9 |
10 | # Log files
11 | npm-debug.log*
12 | yarn-debug.log*
13 | yarn-error.log*
14 | pnpm-debug.log*
15 |
16 | # Editor directories and files
17 | .idea
18 | .vscode
19 | *.suo
20 | *.ntvs*
21 | *.njsproj
22 | *.sln
23 | *.sw?
24 |
--------------------------------------------------------------------------------
/demos/vue2-demo/.npmrc:
--------------------------------------------------------------------------------
1 | shamefully-hoist=true
2 |
--------------------------------------------------------------------------------
/demos/vue2-demo/README.md:
--------------------------------------------------------------------------------
1 | # vue2-demo
2 |
3 | ## Project setup
4 | ```
5 | pnpm install
6 | ```
7 |
8 | ### Compiles and hot-reloads for development
9 | ```
10 | pnpm run serve
11 | ```
12 |
13 | ### Compiles and minifies for production
14 | ```
15 | pnpm run build
16 | ```
17 |
18 | ### Lints and fixes files
19 | ```
20 | pnpm run lint
21 | ```
22 |
23 | ### Customize configuration
24 | See [Configuration Reference](https://cli.vuejs.org/config/).
25 |
--------------------------------------------------------------------------------
/demos/vue2-demo/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | '@vue/cli-plugin-babel/preset'
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/demos/vue2-demo/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "module": "esnext",
5 | "baseUrl": "./",
6 | "moduleResolution": "node",
7 | "paths": {
8 | "@/*": [
9 | "src/*"
10 | ]
11 | },
12 | "lib": [
13 | "esnext",
14 | "dom",
15 | "dom.iterable",
16 | "scripthost"
17 | ]
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/demos/vue2-demo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue2-demo",
3 | "version": "0.1.0",
4 | "private": true,
5 | "scripts": {
6 | "dev": "vue-cli-service serve",
7 | "build": "vue-cli-service build",
8 | "lint": "vue-cli-service lint"
9 | },
10 | "dependencies": {
11 | "core-js": "^3.8.3",
12 | "echarts": "^5.5.1",
13 | "vue": "^2.6.14",
14 | "vue-print-next": "workspace:*",
15 | "vue-router": "^3.6.5"
16 | },
17 | "devDependencies": {
18 | "@babel/core": "^7.12.16",
19 | "@babel/eslint-parser": "^7.12.16",
20 | "@vue/cli-plugin-babel": "~5.0.0",
21 | "@vue/cli-plugin-eslint": "~5.0.0",
22 | "@vue/cli-service": "~5.0.0",
23 | "eslint": "^7.32.0",
24 | "eslint-plugin-vue": "^8.0.3",
25 | "vue-template-compiler": "^2.6.14"
26 | },
27 | "eslintConfig": {
28 | "root": true,
29 | "env": {
30 | "node": true
31 | },
32 | "extends": [
33 | "plugin:vue/essential",
34 | "eslint:recommended"
35 | ],
36 | "parserOptions": {
37 | "parser": "@babel/eslint-parser"
38 | },
39 | "rules": {}
40 | },
41 | "browserslist": [
42 | "> 1%",
43 | "last 2 versions",
44 | "not dead"
45 | ]
46 | }
47 |
--------------------------------------------------------------------------------
/demos/vue2-demo/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alessandro-Pang/vue-print-next/af8f1d342e4845cf991de66a8fbe00862d106abc/demos/vue2-demo/public/favicon.ico
--------------------------------------------------------------------------------
/demos/vue2-demo/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | <%= htmlWebpackPlugin.options.title %>
9 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/demos/vue2-demo/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
36 |
37 |
97 |
--------------------------------------------------------------------------------
/demos/vue2-demo/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Alessandro-Pang/vue-print-next/af8f1d342e4845cf991de66a8fbe00862d106abc/demos/vue2-demo/src/assets/logo.png
--------------------------------------------------------------------------------
/demos/vue2-demo/src/main.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './App.vue'
3 | import {printPlugin} from "vue-print-next";
4 | import './style.css'
5 | import router from "./router";
6 | import VueRouter from "vue-router";
7 |
8 | Vue.config.productionTip = false
9 |
10 | Vue.use(printPlugin)
11 | Vue.use(VueRouter)
12 |
13 | new Vue({
14 | router,
15 | render: h => h(App),
16 | }).$mount('#app')
17 |
--------------------------------------------------------------------------------
/demos/vue2-demo/src/router/index.js:
--------------------------------------------------------------------------------
1 | import VueRouter from 'vue-router'
2 |
3 | import PrintBasic from '../views/PrintBasic.vue'
4 | import PrintBasic2 from '../views/PrintBasicTwo.vue'
5 | import PrintCanvas from '../views/PrintCanvas.vue'
6 | import PrintAsyncUrl from '../views/PrintAsyncUrl.vue'
7 | import PrintUrl from '../views/PrintUrl.vue'
8 | import PrintForm from '../views/PrintForm.vue'
9 | import PrintIframe from '../views/PrintIframe.vue'
10 | export const routes = [
11 | {path: '/', redirect: '/print-basic'},
12 | {path: '/print-basic', component: PrintBasic, meta: {title:'基本打印用例'}},
13 | {path: '/print-basic2', component: PrintBasic2, meta: {title:'基本打印用例2'}},
14 | {path: '/print-canvas', component: PrintCanvas, meta: {title:'Canvas 打印示例'}},
15 | {path: '/print-url', component: PrintUrl, meta: {title:'Url 打印示例'}},
16 | {path: '/print-async-url', component: PrintAsyncUrl, meta: {title:'异步 URL 打印示例'}},
17 | {path: '/print-form', component: PrintForm, meta: {title:'Form 表单打印示例'}},
18 | {path: '/print-iframe', component: PrintIframe, meta: {title:'Iframe 嵌套打印示例'}},
19 | ]
20 |
21 | const router = new VueRouter({
22 | mode: 'history',
23 | routes,
24 | })
25 |
26 | export default router
27 |
--------------------------------------------------------------------------------
/demos/vue2-demo/src/style.css:
--------------------------------------------------------------------------------
1 | :root {
2 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3 | line-height: 1.5;
4 | font-weight: 400;
5 |
6 | font-synthesis: none;
7 | text-rendering: optimizeLegibility;
8 | -webkit-font-smoothing: antialiased;
9 | -moz-osx-font-smoothing: grayscale;
10 | }
11 |
12 | a {
13 | font-weight: 500;
14 | color: #646cff;
15 | text-decoration: inherit;
16 | }
17 | a:hover {
18 | color: #747bff;
19 | }
20 |
21 | html, body {
22 | height: 100%;
23 | width: 100%;
24 | margin: 0;
25 | padding: 0;
26 | -webkit-print-color-adjust: exact;
27 | -moz-print-color-adjust: exact;
28 | -ms-print-color-adjust: exact;
29 | print-color-adjust: exact;
30 | }
31 |
32 | h1 {
33 | font-size: 3.2em;
34 | line-height: 1.1;
35 | }
36 |
37 | button {
38 | border-radius: 8px;
39 | border: 1px solid transparent;
40 | padding: 0.6em 1.2em;
41 | font-size: 1em;
42 | font-weight: 500;
43 | font-family: inherit;
44 | background-color: #f9f9f9;
45 | cursor: pointer;
46 | transition: border-color 0.25s;
47 | }
48 |
49 | button:hover {
50 | border-color: #646cff;
51 | }
52 | button:focus,
53 | button:focus-visible {
54 | outline: 4px auto -webkit-focus-ring-color;
55 | }
56 |
57 | .card {
58 | padding: 2em;
59 | }
60 |
61 | * {
62 | box-sizing: border-box;
63 | }
64 |
65 | #app {
66 | margin: 0 auto;
67 | text-align: center;
68 | height: 100%;
69 | width: 100%;
70 | }
71 |
72 |
73 | .a4-page {
74 | width: 595px;
75 | height: 842px;
76 | }
77 |
78 | .mt-m {
79 | margin-top: 1rem;
80 | }
81 |
--------------------------------------------------------------------------------
/demos/vue2-demo/src/views/PrintAsyncUrl.vue:
--------------------------------------------------------------------------------
1 |
27 |
28 |
29 |
30 |
打印指定 URL 中的内容
31 |
打印地址: /print-form
32 |
33 |
loading...
34 |
35 |
36 |
37 |
40 |
--------------------------------------------------------------------------------
/demos/vue2-demo/src/views/PrintBasic.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
测试基本打印功能
11 |
12 |
13 |
14 |
15 | Edit
16 | components/HelloWorld.vue
to test HMR
17 |
18 |
19 |
20 |
21 | Check out
22 | create-vue, the official Vue + Vite starter
23 |
24 |
25 | Learn more about IDE Support for Vue in the
26 | Vue Docs Scaling up Guide.
27 |
28 |
Click on the Vite and Vue logos to learn more
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
60 |
84 |
--------------------------------------------------------------------------------
/demos/vue2-demo/src/views/PrintBasicTwo.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
葫芦娃
5 |
葫芦娃 葫芦娃
6 |
一根藤上七朵花
7 |
风吹雨打都不怕
8 |
啦啦啦啦
9 |
叮当当咚咚当当 葫芦娃
10 |
叮当当咚咚当当 本领大
11 |
啦啦啦啦
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
35 |
37 |
--------------------------------------------------------------------------------
/demos/vue2-demo/src/views/PrintCanvas.vue:
--------------------------------------------------------------------------------
1 |
199 |
200 |
201 |
205 |
206 |
207 |
213 |
214 |
215 |
--------------------------------------------------------------------------------
/demos/vue2-demo/src/views/PrintForm.vue:
--------------------------------------------------------------------------------
1 |
2 |
50 |
51 |
52 |
97 |
99 |
--------------------------------------------------------------------------------
/demos/vue2-demo/src/views/PrintIframe.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
测试打印 iframe
5 |
6 |
7 |
8 |
9 |
10 |
11 |
14 |
16 |
--------------------------------------------------------------------------------
/demos/vue2-demo/src/views/PrintUrl.vue:
--------------------------------------------------------------------------------
1 |
22 |
23 |
24 |
29 |
30 |
31 |
34 |
--------------------------------------------------------------------------------
/demos/vue2-demo/vue.config.js:
--------------------------------------------------------------------------------
1 | const { defineConfig } = require('@vue/cli-service')
2 | module.exports = defineConfig({
3 | transpileDependencies: true
4 | })
5 |
--------------------------------------------------------------------------------
/demos/vue3-demo/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | pnpm-debug.log*
8 | lerna-debug.log*
9 |
10 | node_modules
11 | dist
12 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
--------------------------------------------------------------------------------
/demos/vue3-demo/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": ["Vue.volar"]
3 | }
4 |
--------------------------------------------------------------------------------
/demos/vue3-demo/README.md:
--------------------------------------------------------------------------------
1 | # Vue 3 + TypeScript + Vite
2 |
3 | This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `
12 |
13 |