Skip to content

Commit ffed15a

Browse files
committed
doc: 文档完善
1 parent 0b32355 commit ffed15a

Some content is hidden

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

50 files changed

+611
-15086
lines changed

.env.doc

-1
This file was deleted.

.env.docdev

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
NODE_ENV = development
2+
3+
VUE_APP_ENV = doc

.env.docpro

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
NODE_ENV = production
2+
3+
VUE_APP_ENV = doc

config/config.build.iframe.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
* @Author: zhanghan
33
* @Date: 2022-11-28 09:13:53
44
* @LastEditors: zhanghan
5-
* @LastEditTime: 2023-01-10 15:07:37
5+
* @LastEditTime: 2023-01-11 15:23:46
66
* @Descripttion: iframe开发环境配置
77
*/
88
const path = require('path')
9-
// 获取当前工作目录
10-
const cwd = process.cwd()
9+
// 获取基于当前路径的目标文件
10+
const resolve = (dir) => path.join(__dirname, '../', dir)
1111

1212
module.exports = {
13-
publicPath: '/file-viewer',
13+
publicPath: './',
1414
// 放在public下供项目演示时作为iframe入口使用
15-
outputDir: path.join(cwd, '/public/file-viewer'),
15+
outputDir: resolve('/public/file-viewer'),
1616
pages: {
1717
index: {
1818
entry: 'examples/main.js',

config/config.doc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
* @Author: zhanghan
33
* @Date: 2022-11-28 09:13:53
44
* @LastEditors: zhanghan
5-
* @LastEditTime: 2023-01-11 09:26:20
5+
* @LastEditTime: 2023-01-11 13:33:12
66
* @Descripttion: 文档环境配置
77
*/
88

99
module.exports = {
1010
outputDir: './docs',
11-
publicPath: '/file-viewer-doc',
11+
publicPath: './',
1212
assetsDir: 'static',
1313
pages: {
1414
index: {

doc/views/Home.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Author: zhanghan
33
* @Date: 2023-01-10 14:28:29
44
* @LastEditors: zhanghan
5-
* @LastEditTime: 2023-01-11 11:45:47
5+
* @LastEditTime: 2023-01-11 13:51:05
66
* @Descripttion: 首页
77
-->
88
<template>
@@ -15,7 +15,7 @@
1515
<iframe
1616
scrolling="auto"
1717
seamless
18-
src="/file-viewer/index.html?shoHead=true&&fileUrl=https://home.sharecorner.top/fileTest/pdf.pdf"
18+
src="./file-viewer/index.html?shoHead=true&&fileUrl=https://home.sharecorner.top/fileTest/pdf.pdf"
1919
style="border:0;height: 100%;width:100%"
2020
/>
2121
</div>

doc/views/Start.vue

+46-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Author: zhanghan
33
* @Date: 2023-01-10 14:28:29
44
* @LastEditors: zhanghan
5-
* @LastEditTime: 2023-01-11 11:49:50
5+
* @LastEditTime: 2023-01-11 16:20:52
66
* @Descripttion: 快速上手
77
-->
88
<template>
@@ -24,23 +24,35 @@
2424
>
2525
file-viewer
2626
</a>
27+
2728
<br />
28-
(必须包含file-viewer文件夹,不可重命名,若需要重命名可下载源码重新修改构建)
2929
</h4>
30-
<h4>2、将下载后的文件夹放在项目public文件夹中作为外部公共资源使用</h4>
30+
<h4>
31+
2、将下载后的file-viewer文件夹整个放在项目公共文件夹中作为外部公共资源使用。
32+
<br />
33+
(以vue-cli为例,放置在项目public文件夹下;其他框架自行选择合适的公共路径放置)
34+
</h4>
3135
<h3>注意事项:</h3>
32-
<h4>* 本项目示例链接随时失效,请勿直接用于生产环境</h4>
33-
<h4>* 被浏览的文件链接必须同源或本身支持跨域访问</h4>
36+
<h4>* 本项目示例链接随时失效,请勿直接用于生产环境。</h4>
37+
<h4>* 被浏览的文件链接必须同源或本身支持跨域访问。</h4>
38+
<h4>
39+
*
40+
若发布生产的项目不在服务器域名根目录,记得配置打包的前缀路径,打包后资源才能被正常引用。(以vue-cli为例,配置
41+
<code>vue.config.js</code>
42+
43+
<code>publicPath: './'</code>
44+
; 其他框架请自行选择合适的配置文件进行配置)
45+
</h4>
3446
<br />
3547

36-
<h4>一般url传入使用</h4>
48+
<h3>一般url传入使用</h3>
3749
<section class="demo">
3850
<div
3951
class="section-content swiper"
4052
style="height: 500px;overflow: hidden;"
4153
>
4254
<iframe
43-
src="/file-viewer/index.html?fileUrl=https://home.sharecorner.top/fileTest/pdf.pdf"
55+
src="./file-viewer/index.html?fileUrl=https://home.sharecorner.top/fileTest/pdf.pdf"
4456
scrolling="auto"
4557
style="border:0;height: 100%;width:100%"
4658
/>
@@ -54,7 +66,19 @@
5466
</Collapse>
5567
</section>
5668

57-
<h4>支持二进制文件流消息推送</h4>
69+
<h3>支持二进制文件流消息推送</h3>
70+
<h3>注意事项:</h3>
71+
<h4>
72+
*
73+
若为node环境,且发布生产的项目不在服务器域名根目录,这将导致生产和开发环境的引用路径不一致(由于动态赋值的路径只会被编译器原样解析,需要特别注意通过配置打包的前缀路径也不会对此次生效,例如
74+
<code>vue-cli</code>
75+
76+
<code>publicPath</code>
77+
),可通过
78+
<code>process.env.NODE_ENV</code>
79+
进行手动判断。
80+
</h4>
81+
<h4>* 若为浏览器环境,若有需要可在前面配置统一前缀路径即可。</h4>
5882
<section class="demo">
5983
<div
6084
class="section-content swiper"
@@ -101,7 +125,7 @@ import { config } from '../config'
101125

102126
const iframeSnippet = `
103127
<iframe
104-
src="/file-viewer/index.html?fileUrl=https://home.sharecorner.top/fileTest/pdf.pdf"
128+
src="./file-viewer/index.html?fileUrl=https://home.sharecorner.top/fileTest/pdf.pdf"
105129
scrolling="auto"
106130
style="border:0;height: 100%;width:100%"
107131
/>
@@ -119,7 +143,12 @@ export default {
119143
context: {
120144
// 查看器的地址
121145
// 自己项目内部署需要将编译后的产物file-viewer放在public文件夹中使用,编译后的产物需要下载,下载链接在文档上
122-
origin: location.origin + '/file-viewer/index.html',
146+
// 若为node环境,且发布生产的项目不在服务器域名根目录,这将导致生产和开发环境的引用路径不一致(由于动态赋值的路径只会被编译器原样解析,需要特别注意通过配置打包的前缀路径也不会对此次生效,例如vue-cli的publicPath),可通过process.env.NODE_ENV进行手动判断
147+
// origin: location.origin + process.env.NODE_ENV === 'production'
148+
? '/你的前缀路径(没有可去除)/file-viewer/index.html'
149+
: '/file-viewer/index.html',
150+
// 若为浏览器环境,若有需要可在/file-viewer前面配置统一前缀路径即可
151+
origin: location.origin + '/你的前缀路径(没有可去除)/file-viewer/index.html',
123152
// 目标frame
124153
frame: null,
125154
// 浏览的文件url
@@ -221,7 +250,12 @@ export default {
221250
context: {
222251
// 查看器的地址
223252
// 自己项目内部署需要将编译后的产物file-viewer放在public文件夹中使用,编译后的产物需要下载,下载链接在文档上
224-
origin: location.origin + '/file-viewer/index.html',
253+
// 若为node环境,且发布生产的项目不在服务器域名根目录,这将导致生产和开发环境的引用路径不一致(由于动态赋值的路径只会被编译器原样解析,需要特别注意通过配置打包的前缀路径也不会对此次生效,例如vue-cli的publicPath),可通过process.env.NODE_ENV进行手动判断
254+
origin:
255+
location.origin +
256+
(process.env.NODE_ENV === 'production'
257+
? '/file-viewer-doc/file-viewer/index.html'
258+
: '/file-viewer/index.html'),
225259
// 目标frame
226260
frame: null,
227261
// 浏览的文件url
@@ -231,6 +265,7 @@ export default {
231265
},
232266
mounted() {
233267
this.loadFromUrl()
268+
console.log('process.env.NODE_ENV', process.env.NODE_ENV)
234269
},
235270
methods: {
236271
// 获取文件二进制流

docs/file-viewer/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/file-viewer/favicon.ico"><title>@zuiyouliao/vue-file-viewer</title><link href="/file-viewer/static/css/chunk-vendors.14348074.css" rel="preload" as="style"><link href="/file-viewer/static/css/index.56a4c341.css" rel="preload" as="style"><link href="/file-viewer/static/js/chunk-vendors.9c26e4cb.js" rel="preload" as="script"><link href="/file-viewer/static/js/index.d6d27d52.js" rel="preload" as="script"><link href="/file-viewer/static/css/chunk-vendors.14348074.css" rel="stylesheet"><link href="/file-viewer/static/css/index.56a4c341.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but @zuiyouliao/vue-file-viewer doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/file-viewer/static/js/chunk-vendors.9c26e4cb.js"></script><script src="/file-viewer/static/js/index.d6d27d52.js"></script></body></html>
1+
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon.ico"><title>@zuiyouliao/vue-file-viewer</title><link href="static/css/chunk-vendors.14348074.css" rel="preload" as="style"><link href="static/css/index.56a4c341.css" rel="preload" as="style"><link href="static/js/chunk-vendors.101c5e96.js" rel="preload" as="script"><link href="static/js/index.24e10c2b.js" rel="preload" as="script"><link href="static/css/chunk-vendors.14348074.css" rel="stylesheet"><link href="static/css/index.56a4c341.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but @zuiyouliao/vue-file-viewer doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="static/js/chunk-vendors.101c5e96.js"></script><script src="static/js/index.24e10c2b.js"></script></body></html>

0 commit comments

Comments
 (0)