Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Velpro187
uni-app
提交
5e7465a9
U
uni-app
项目概览
Velpro187
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5e7465a9
编写于
3月 31, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: transformAssetUrls
上级
3c2123f7
变更
28
展开全部
隐藏空白更改
内联
并排
Showing
28 changed file
with
1454 addition
and
305 deletion
+1454
-305
package.json
package.json
+5
-5
packages/size-check/vite.config.ts
packages/size-check/vite.config.ts
+2
-8
packages/uni-cli-shared/src/constants.ts
packages/uni-cli-shared/src/constants.ts
+1
-0
packages/uni-cli-shared/src/index.ts
packages/uni-cli-shared/src/index.ts
+1
-1
packages/uni-cli-shared/src/url.ts
packages/uni-cli-shared/src/url.ts
+9
-0
packages/uni-components/src/components/image/index.vue
packages/uni-components/src/components/image/index.vue
+73
-65
packages/uni-core/src/view/plugin/componentInstance.ts
packages/uni-core/src/view/plugin/componentInstance.ts
+0
-5
packages/uni-h5/dist/assets/index-74eeac14.css
packages/uni-h5/dist/assets/index-74eeac14.css
+871
-0
packages/uni-h5/dist/uni-h5.esm.js
packages/uni-h5/dist/uni-h5.esm.js
+49
-47
packages/uni-h5/src/framework/components/page/pageHead.tsx
packages/uni-h5/src/framework/components/page/pageHead.tsx
+1
-1
packages/uni-h5/src/framework/plugin/page.ts
packages/uni-h5/src/framework/plugin/page.ts
+9
-2
packages/uni-h5/src/platform/getRealPath.ts
packages/uni-h5/src/platform/getRealPath.ts
+0
-0
packages/uni-h5/src/platform/index.ts
packages/uni-h5/src/platform/index.ts
+1
-0
packages/uni-h5/vite.config.ts
packages/uni-h5/vite.config.ts
+4
-0
packages/vite-plugin-uni/__tests__/static.spec.ts
packages/vite-plugin-uni/__tests__/static.spec.ts
+15
-0
packages/vite-plugin-uni/package.json
packages/vite-plugin-uni/package.json
+4
-2
packages/vite-plugin-uni/src/configResolved/plugins/copy.ts
packages/vite-plugin-uni/src/configResolved/plugins/copy.ts
+3
-2
packages/vite-plugin-uni/src/configResolved/plugins/index.ts
packages/vite-plugin-uni/src/configResolved/plugins/index.ts
+2
-0
packages/vite-plugin-uni/src/configResolved/plugins/pagesJson.ts
...s/vite-plugin-uni/src/configResolved/plugins/pagesJson.ts
+4
-0
packages/vite-plugin-uni/src/configResolved/plugins/static.ts
...ages/vite-plugin-uni/src/configResolved/plugins/static.ts
+45
-0
packages/vite-plugin-uni/src/configureServer/index.ts
packages/vite-plugin-uni/src/configureServer/index.ts
+4
-0
packages/vite-plugin-uni/src/configureServer/middlewares/static.ts
...vite-plugin-uni/src/configureServer/middlewares/static.ts
+99
-0
packages/vite-plugin-uni/src/configureServer/static.ts
packages/vite-plugin-uni/src/configureServer/static.ts
+46
-0
packages/vite-plugin-uni/src/utils/filter.ts
packages/vite-plugin-uni/src/utils/filter.ts
+10
-0
packages/vite-plugin-uni/src/utils/index.ts
packages/vite-plugin-uni/src/utils/index.ts
+1
-0
packages/vite-plugin-uni/src/vue/compilerOptions.ts
packages/vite-plugin-uni/src/vue/compilerOptions.ts
+25
-2
tsconfig.json
tsconfig.json
+4
-1
yarn.lock
yarn.lock
+166
-164
未找到文件。
package.json
浏览文件 @
5e7465a9
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
"node"
:
">=10.0.0"
"node"
:
">=10.0.0"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"
@dcloudio/types
"
:
"
^2.0.2
0
"
,
"
@dcloudio/types
"
:
"
^2.0.2
4
"
,
"
@microsoft/api-extractor
"
:
"
^7.13.2
"
,
"
@microsoft/api-extractor
"
:
"
^7.13.2
"
,
"
@rollup/plugin-alias
"
:
"
^3.1.1
"
,
"
@rollup/plugin-alias
"
:
"
^3.1.1
"
,
"
@rollup/plugin-commonjs
"
:
"
^17.0.0
"
,
"
@rollup/plugin-commonjs
"
:
"
^17.0.0
"
,
...
@@ -49,9 +49,9 @@
...
@@ -49,9 +49,9 @@
"
@types/node
"
:
"
^14.14.20
"
,
"
@types/node
"
:
"
^14.14.20
"
,
"
@types/puppeteer
"
:
"
^5.4.2
"
,
"
@types/puppeteer
"
:
"
^5.4.2
"
,
"
@typescript-eslint/parser
"
:
"
^4.12.0
"
,
"
@typescript-eslint/parser
"
:
"
^4.12.0
"
,
"
@vitejs/plugin-vue
"
:
"
^1.
0.4
"
,
"
@vitejs/plugin-vue
"
:
"
^1.
2.1
"
,
"
@vitejs/plugin-vue-jsx
"
:
"
^1.1.2
"
,
"
@vitejs/plugin-vue-jsx
"
:
"
^1.1.2
"
,
"
@vue/compiler-sfc
"
:
"
^3.0.
5
"
,
"
@vue/compiler-sfc
"
:
"
^3.0.
10
"
,
"
eslint
"
:
"
^7.17.0
"
,
"
eslint
"
:
"
^7.17.0
"
,
"
fs-extra
"
:
"
^9.0.1
"
,
"
fs-extra
"
:
"
^9.0.1
"
,
"
jest
"
:
"
^26.6.3
"
,
"
jest
"
:
"
^26.6.3
"
,
...
@@ -70,8 +70,8 @@
...
@@ -70,8 +70,8 @@
"
size-limit
"
:
"
^4.10.1
"
,
"
size-limit
"
:
"
^4.10.1
"
,
"
ts-jest
"
:
"
^26.4.4
"
,
"
ts-jest
"
:
"
^26.4.4
"
,
"
typescript
"
:
"
~4.1.3
"
,
"
typescript
"
:
"
~4.1.3
"
,
"
vite
"
:
"
^2.1.
3
"
,
"
vite
"
:
"
^2.1.
5
"
,
"
vue
"
:
"
3.0.
9
"
,
"
vue
"
:
"
3.0.
10
"
,
"
yorkie
"
:
"
^2.0.0
"
"
yorkie
"
:
"
^2.0.0
"
}
}
}
}
packages/size-check/vite.config.ts
浏览文件 @
5e7465a9
import
path
from
'
path
'
import
path
from
'
path
'
import
vue
from
'
@vitejs/plugin-vue
'
import
vue
from
'
@vitejs/plugin-vue
'
import
uni
,
{
uniVueCompilerOptions
}
from
'
@dcloudio/vite-plugin-uni
'
import
uni
,
{
uniVueTemplateOptions
}
from
'
@dcloudio/vite-plugin-uni
'
function
resolve
(
file
:
string
)
{
return
path
.
resolve
(
__dirname
,
file
)
}
/**
/**
* @type {import('vite').UserConfig}
* @type {import('vite').UserConfig}
...
@@ -24,9 +20,7 @@ export default {
...
@@ -24,9 +20,7 @@ export default {
plugins
:
[
plugins
:
[
vue
({
vue
({
template
:
{
template
:
uniVueTemplateOptions
,
compilerOptions
:
uniVueCompilerOptions
,
},
}),
}),
uni
({
inputDir
:
path
.
resolve
(
__dirname
,
'
src
'
)
}),
uni
({
inputDir
:
path
.
resolve
(
__dirname
,
'
src
'
)
}),
],
],
...
...
packages/uni-cli-shared/src/constants.ts
浏览文件 @
5e7465a9
export
const
PUBLIC_DIR
=
'
static
'
export
const
EXTNAME_JS
=
[
'
.js
'
,
'
.ts
'
]
export
const
EXTNAME_JS
=
[
'
.js
'
,
'
.ts
'
]
export
const
EXTNAME_VUE
=
[
'
.vue
'
,
'
.nvue
'
,
'
.fvue
'
]
export
const
EXTNAME_VUE
=
[
'
.vue
'
,
'
.nvue
'
,
'
.fvue
'
]
packages/uni-cli-shared/src/index.ts
浏览文件 @
5e7465a9
export
*
from
'
./url
'
export
*
from
'
./json
'
export
*
from
'
./json
'
export
*
from
'
./query
'
export
*
from
'
./constants
'
export
*
from
'
./constants
'
export
*
from
'
./preprocess/index
'
export
*
from
'
./preprocess/index
'
packages/uni-cli-shared/src/
query
.ts
→
packages/uni-cli-shared/src/
url
.ts
浏览文件 @
5e7465a9
...
@@ -30,3 +30,12 @@ export function parseVueRequest(id: string) {
...
@@ -30,3 +30,12 @@ export function parseVueRequest(id: string) {
query
,
query
,
}
}
}
}
const
importQueryRE
=
/
(\?
|&
)
import
(?:
&|$
)
/
export
const
isImportRequest
=
(
url
:
string
)
=>
importQueryRE
.
test
(
url
)
export
const
queryRE
=
/
\?
.*$/
export
const
hashRE
=
/#.*$/
export
const
cleanUrl
=
(
url
:
string
)
=>
url
.
replace
(
hashRE
,
''
).
replace
(
queryRE
,
''
)
packages/uni-components/src/components/image/index.vue
浏览文件 @
5e7465a9
<
template
>
<
template
>
<uni-image
v-bind=
"$attrs"
>
<uni-image
v-bind=
"$attrs"
>
<div
<div
ref=
"content"
:style=
"modeStyle"
/>
ref=
"content"
<img
:src=
"realImagePath"
/>
:style=
"modeStyle"
/>
<img
:src=
"realImagePath"
>
<v-uni-resize-sensor
<v-uni-resize-sensor
v-if=
"mode === 'widthFix'"
v-if=
"mode === 'widthFix'"
ref=
"sensor"
ref=
"sensor"
...
@@ -13,38 +10,41 @@
...
@@ -13,38 +10,41 @@
</uni-image>
</uni-image>
</
template
>
</
template
>
<
script
>
<
script
>
import
{
getRealPath
}
from
'
@dcloudio/uni-platform
'
export
default
{
export
default
{
name
:
'
Image
'
,
name
:
'
Image
'
,
props
:
{
props
:
{
src
:
{
src
:
{
type
:
String
,
type
:
String
,
default
:
''
default
:
''
,
},
},
mode
:
{
mode
:
{
type
:
String
,
type
:
String
,
default
:
'
scaleToFill
'
default
:
'
scaleToFill
'
,
},
},
// TODO 懒加载
// TODO 懒加载
lazyLoad
:
{
lazyLoad
:
{
type
:
[
Boolean
,
String
],
type
:
[
Boolean
,
String
],
default
:
false
default
:
false
,
}
}
,
},
},
data
()
{
data
()
{
return
{
return
{
originalWidth
:
0
,
originalWidth
:
0
,
originalHeight
:
0
,
originalHeight
:
0
,
availHeight
:
''
availHeight
:
''
,
}
}
},
},
computed
:
{
computed
:
{
ratio
()
{
ratio
()
{
return
this
.
originalWidth
&&
this
.
originalHeight
?
this
.
originalWidth
/
this
.
originalHeight
:
0
return
this
.
originalWidth
&&
this
.
originalHeight
?
this
.
originalWidth
/
this
.
originalHeight
:
0
},
},
realImagePath
()
{
realImagePath
()
{
return
this
.
$
getRealPath
(
this
.
src
)
return
getRealPath
(
this
.
src
)
},
},
modeStyle
()
{
modeStyle
()
{
let
size
=
'
auto
'
let
size
=
'
auto
'
let
position
=
''
let
position
=
''
const
repeat
=
'
no-repeat
'
const
repeat
=
'
no-repeat
'
...
@@ -95,23 +95,23 @@ export default {
...
@@ -95,23 +95,23 @@ export default {
}
}
return
`background-position:
${
position
}
;background-size:
${
size
}
;background-repeat:
${
repeat
}
;`
return
`background-position:
${
position
}
;background-size:
${
size
}
;background-repeat:
${
repeat
}
;`
}
}
,
},
},
watch
:
{
watch
:
{
src
(
newValue
,
oldValue
)
{
src
(
newValue
,
oldValue
)
{
this
.
_setContentImage
()
this
.
_setContentImage
()
this
.
_loadImage
()
this
.
_loadImage
()
},
},
mode
(
newValue
,
oldValue
)
{
mode
(
newValue
,
oldValue
)
{
if
(
oldValue
===
'
widthFix
'
)
{
if
(
oldValue
===
'
widthFix
'
)
{
this
.
$el
.
style
.
height
=
this
.
availHeight
this
.
$el
.
style
.
height
=
this
.
availHeight
}
}
if
(
newValue
===
'
widthFix
'
&&
this
.
ratio
)
{
if
(
newValue
===
'
widthFix
'
&&
this
.
ratio
)
{
this
.
_fixSize
()
this
.
_fixSize
()
}
}
}
}
,
},
},
mounted
()
{
mounted
()
{
this
.
availHeight
=
this
.
$el
.
style
.
height
||
''
this
.
availHeight
=
this
.
$el
.
style
.
height
||
''
this
.
_setContentImage
()
this
.
_setContentImage
()
if
(
!
this
.
realImagePath
)
{
if
(
!
this
.
realImagePath
)
{
...
@@ -120,26 +120,32 @@ export default {
...
@@ -120,26 +120,32 @@ export default {
this
.
_loadImage
()
this
.
_loadImage
()
},
},
methods
:
{
methods
:
{
_resize
()
{
_resize
()
{
if
(
this
.
mode
===
'
widthFix
'
)
{
if
(
this
.
mode
===
'
widthFix
'
)
{
this
.
_fixSize
()
this
.
_fixSize
()
}
}
},
},
_fixSize
()
{
_fixSize
()
{
const
elWidth
=
this
.
_getWidth
()
const
elWidth
=
this
.
_getWidth
()
if
(
elWidth
)
{
if
(
elWidth
)
{
let
height
=
elWidth
/
this
.
ratio
let
height
=
elWidth
/
this
.
ratio
// fix: 解决 Chrome 浏览器上某些情况下导致 1px 缝隙的问题
// fix: 解决 Chrome 浏览器上某些情况下导致 1px 缝隙的问题
if
(
typeof
navigator
&&
navigator
.
vendor
===
'
Google Inc.
'
&&
height
>
10
)
{
if
(
typeof
navigator
&&
navigator
.
vendor
===
'
Google Inc.
'
&&
height
>
10
)
{
height
=
Math
.
round
(
height
/
2
)
*
2
height
=
Math
.
round
(
height
/
2
)
*
2
}
}
this
.
$el
.
style
.
height
=
height
+
'
px
'
this
.
$el
.
style
.
height
=
height
+
'
px
'
}
}
},
},
_setContentImage
()
{
_setContentImage
()
{
this
.
$refs
.
content
.
style
.
backgroundImage
=
this
.
src
?
`url("
${
this
.
realImagePath
}
")`
:
'
none
'
this
.
$refs
.
content
.
style
.
backgroundImage
=
this
.
src
?
`url("
${
this
.
realImagePath
}
")`
:
'
none
'
},
},
_loadImage
()
{
_loadImage
()
{
const
_self
=
this
const
_self
=
this
const
img
=
new
Image
()
const
img
=
new
Image
()
img
.
onload
=
function
(
$event
)
{
img
.
onload
=
function
(
$event
)
{
...
@@ -152,59 +158,61 @@ export default {
...
@@ -152,59 +158,61 @@ export default {
_self
.
$trigger
(
'
load
'
,
$event
,
{
_self
.
$trigger
(
'
load
'
,
$event
,
{
width
:
this
.
width
,
width
:
this
.
width
,
height
:
this
.
height
height
:
this
.
height
,
})
})
}
}
img
.
onerror
=
function
(
$event
)
{
img
.
onerror
=
function
(
$event
)
{
_self
.
$trigger
(
'
error
'
,
$event
,
{
_self
.
$trigger
(
'
error
'
,
$event
,
{
errMsg
:
`GET
${
_self
.
src
}
404 (Not Found)`
errMsg
:
`GET
${
_self
.
src
}
404 (Not Found)`
,
})
})
}
}
img
.
src
=
this
.
realImagePath
img
.
src
=
this
.
realImagePath
},
},
_getWidth
()
{
_getWidth
()
{
const
computedStyle
=
window
.
getComputedStyle
(
this
.
$el
)
const
computedStyle
=
window
.
getComputedStyle
(
this
.
$el
)
const
borderWidth
=
(
parseFloat
(
computedStyle
.
borderLeftWidth
,
10
)
||
0
)
+
(
parseFloat
(
computedStyle
.
borderRightWidth
,
const
borderWidth
=
10
)
||
0
)
(
parseFloat
(
computedStyle
.
borderLeftWidth
,
10
)
||
0
)
+
const
paddingWidth
=
(
parseFloat
(
computedStyle
.
paddingLeft
,
10
)
||
0
)
+
(
parseFloat
(
computedStyle
.
paddingRight
,
10
)
||
(
parseFloat
(
computedStyle
.
borderRightWidth
,
10
)
||
0
)
0
)
const
paddingWidth
=
(
parseFloat
(
computedStyle
.
paddingLeft
,
10
)
||
0
)
+
(
parseFloat
(
computedStyle
.
paddingRight
,
10
)
||
0
)
return
this
.
$el
.
offsetWidth
-
borderWidth
-
paddingWidth
return
this
.
$el
.
offsetWidth
-
borderWidth
-
paddingWidth
}
}
,
}
}
,
}
}
</
script
>
</
script
>
<
style
>
<
style
>
uni-image
{
uni-image
{
width
:
320px
;
width
:
320px
;
height
:
240px
;
height
:
240px
;
display
:
inline-block
;
display
:
inline-block
;
overflow
:
hidden
;
overflow
:
hidden
;
position
:
relative
;
position
:
relative
;
}
}
uni-image
[
hidden
]
{
uni-image
[
hidden
]
{
display
:
none
;
display
:
none
;
}
}
uni-image
>
div
{
uni-image
>
div
{
width
:
100%
;
width
:
100%
;
height
:
100%
;
height
:
100%
;
}
}
uni-image
>
img
{
uni-image
>
img
{
-webkit-touch-callout
:
none
;
-webkit-touch-callout
:
none
;
-webkit-user-select
:
none
;
-webkit-user-select
:
none
;
-moz-user-select
:
none
;
-moz-user-select
:
none
;
display
:
block
;
display
:
block
;
position
:
absolute
;
position
:
absolute
;
top
:
0
;
top
:
0
;
left
:
0
;
left
:
0
;
width
:
100%
;
width
:
100%
;
height
:
100%
;
height
:
100%
;
opacity
:
0
;
opacity
:
0
;
}
}
uni-image
>
.uni-image-will-change
{
uni-image
>
.uni-image-will-change
{
will-change
:
transform
;
will-change
:
transform
;
}
}
</
style
>
</
style
>
packages/uni-core/src/view/plugin/componentInstance.ts
浏览文件 @
5e7465a9
...
@@ -26,8 +26,3 @@ export function $handleEvent(this: ComponentPublicInstance, $event: Event) {
...
@@ -26,8 +26,3 @@ export function $handleEvent(this: ComponentPublicInstance, $event: Event) {
}
}
return
$event
return
$event
}
}
export
function
$getRealPath
(
v
:
string
)
{
// TODO
return
v
}
packages/uni-h5/dist/assets/index-74eeac14.css
0 → 100644
浏览文件 @
5e7465a9
uni-canvas
{
width
:
300px
;
height
:
150px
;
display
:
block
;
position
:
relative
;
}
uni-canvas
>
canvas
{
position
:
absolute
;
top
:
0
;
left
:
0
;
width
:
100%
;
height
:
100%
;
}
uni-checkbox-group
[
hidden
]
{
display
:
none
;
}
.ql-container
{
display
:
block
;
position
:
relative
;
box-sizing
:
border-box
;
-webkit-user-select
:
text
;
user-select
:
text
;
outline
:
none
;
overflow
:
hidden
;
width
:
100%
;
height
:
200px
;
min-height
:
200px
;
}
.ql-container
[
hidden
]
{
display
:
none
;
}
.ql-container
.ql-editor
{
position
:
relative
;
font-size
:
inherit
;
line-height
:
inherit
;
font-family
:
inherit
;
min-height
:
inherit
;
width
:
100%
;
height
:
100%
;
padding
:
0
;
overflow-x
:
hidden
;
overflow-y
:
auto
;
-webkit-tap-highlight-color
:
transparent
;
-webkit-touch-callout
:
none
;
-webkit-overflow-scrolling
:
touch
;
}
.ql-container
.ql-editor
::-webkit-scrollbar
{
width
:
0
!important
;
}
.ql-container
.ql-editor.scroll-disabled
{
overflow
:
hidden
;
}
.ql-container
.ql-image-overlay
{
display
:
flex
;
position
:
absolute
;
box-sizing
:
border-box
;
border
:
1px
dashed
#ccc
;
justify-content
:
center
;
align-items
:
center
;
-webkit-user-select
:
none
;
user-select
:
none
;
}
.ql-container
.ql-image-overlay
.ql-image-size
{
position
:
absolute
;
padding
:
4px
8px
;
text-align
:
center
;
background-color
:
#fff
;
color
:
#888
;
border
:
1px
solid
#ccc
;
box-sizing
:
border-box
;
opacity
:
0.8
;
right
:
4px
;
top
:
4px
;
font-size
:
12px
;
display
:
inline-block
;
width
:
auto
;
}
.ql-container
.ql-image-overlay
.ql-image-toolbar
{
position
:
relative
;
text-align
:
center
;
box-sizing
:
border-box
;
background
:
#000
;
border-radius
:
5px
;
color
:
#fff
;
font-size
:
0
;
min-height
:
24px
;
z-index
:
100
;
}
.ql-container
.ql-image-overlay
.ql-image-toolbar
span
{
display
:
inline-block
;
cursor
:
pointer
;
padding
:
5px
;
font-size
:
12px
;
border-right
:
1px
solid
#fff
;
}
.ql-container
.ql-image-overlay
.ql-image-toolbar
span
:last-child
{
border-right
:
0
;
}
.ql-container
.ql-image-overlay
.ql-image-toolbar
span
.triangle-up
{
padding
:
0
;
position
:
absolute
;
top
:
-12px
;
left
:
50%
;
transform
:
translatex
(
-50%
);
width
:
0
;
height
:
0
;
border-width
:
6px
;
border-style
:
solid
;
border-color
:
transparent
transparent
black
transparent
;
}
.ql-container
.ql-image-overlay
.ql-image-handle
{
position
:
absolute
;
height
:
12px
;
width
:
12px
;
border-radius
:
50%
;
border
:
1px
solid
#ccc
;
box-sizing
:
border-box
;
background
:
#fff
;
}
.ql-container
img
{
display
:
inline-block
;
max-width
:
100%
;
}
.ql-clipboard
p
{
margin
:
0
;
padding
:
0
;
}
.ql-editor
{
box-sizing
:
border-box
;
height
:
100%
;
outline
:
none
;
overflow-y
:
auto
;
tab-size
:
4
;
-moz-tab-size
:
4
;
text-align
:
left
;
white-space
:
pre-wrap
;
word-wrap
:
break-word
;
}
.ql-editor
>
*
{
cursor
:
text
;
}
.ql-editor
p
,
.ql-editor
ol
,
.ql-editor
ul
,
.ql-editor
pre
,
.ql-editor
blockquote
,
.ql-editor
h1
,
.ql-editor
h2
,
.ql-editor
h3
,
.ql-editor
h4
,
.ql-editor
h5
,
.ql-editor
h6
{
margin
:
0
;
padding
:
0
;
counter-reset
:
list-1
list-2
list-3
list-4
list-5
list-6
list-7
list-8
list-9
;
}
.ql-editor
ol
>
li
,
.ql-editor
ul
>
li
{
list-style-type
:
none
;
}
.ql-editor
ul
>
li
::before
{
content
:
'\2022'
;
}
.ql-editor
ul
[
data-checked
=
true
],
.ql-editor
ul
[
data-checked
=
false
]
{
pointer-events
:
none
;
}
.ql-editor
ul
[
data-checked
=
true
]
>
li
*,
.ql-editor
ul
[
data-checked
=
false
]
>
li
*
{
pointer-events
:
all
;
}
.ql-editor
ul
[
data-checked
=
true
]
>
li
::before
,
.ql-editor
ul
[
data-checked
=
false
]
>
li
::before
{
color
:
#777
;
cursor
:
pointer
;
pointer-events
:
all
;
}
.ql-editor
ul
[
data-checked
=
true
]
>
li
::before
{
content
:
'\2611'
;
}
.ql-editor
ul
[
data-checked
=
false
]
>
li
::before
{
content
:
'\2610'
;
}
.ql-editor
li
::before
{
display
:
inline-block
;
white-space
:
nowrap
;
width
:
2em
;
}
.ql-editor
ol
li
{
counter-reset
:
list-1
list-2
list-3
list-4
list-5
list-6
list-7
list-8
list-9
;
counter-increment
:
list-0
;
}
.ql-editor
ol
li
:before
{
content
:
counter
(
list-0
,
decimal
)
'. '
;
}
.ql-editor
ol
li
.ql-indent-1
{
counter-increment
:
list-1
;
}
.ql-editor
ol
li
.ql-indent-1
:before
{
content
:
counter
(
list-1
,
lower-alpha
)
'. '
;
}
.ql-editor
ol
li
.ql-indent-1
{
counter-reset
:
list-2
list-3
list-4
list-5
list-6
list-7
list-8
list-9
;
}
.ql-editor
ol
li
.ql-indent-2
{
counter-increment
:
list-2
;
}
.ql-editor
ol
li
.ql-indent-2
:before
{
content
:
counter
(
list-2
,
lower-roman
)
'. '
;
}
.ql-editor
ol
li
.ql-indent-2
{
counter-reset
:
list-3
list-4
list-5
list-6
list-7
list-8
list-9
;
}
.ql-editor
ol
li
.ql-indent-3
{
counter-increment
:
list-3
;
}
.ql-editor
ol
li
.ql-indent-3
:before
{
content
:
counter
(
list-3
,
decimal
)
'. '
;
}
.ql-editor
ol
li
.ql-indent-3
{
counter-reset
:
list-4
list-5
list-6
list-7
list-8
list-9
;
}
.ql-editor
ol
li
.ql-indent-4
{
counter-increment
:
list-4
;
}
.ql-editor
ol
li
.ql-indent-4
:before
{
content
:
counter
(
list-4
,
lower-alpha
)
'. '
;
}
.ql-editor
ol
li
.ql-indent-4
{
counter-reset
:
list-5
list-6
list-7
list-8
list-9
;
}
.ql-editor
ol
li
.ql-indent-5
{
counter-increment
:
list-5
;
}
.ql-editor
ol
li
.ql-indent-5
:before
{
content
:
counter
(
list-5
,
lower-roman
)
'. '
;
}
.ql-editor
ol
li
.ql-indent-5
{
counter-reset
:
list-6
list-7
list-8
list-9
;
}
.ql-editor
ol
li
.ql-indent-6
{
counter-increment
:
list-6
;
}
.ql-editor
ol
li
.ql-indent-6
:before
{
content
:
counter
(
list-6
,
decimal
)
'. '
;
}
.ql-editor
ol
li
.ql-indent-6
{
counter-reset
:
list-7
list-8
list-9
;
}
.ql-editor
ol
li
.ql-indent-7
{
counter-increment
:
list-7
;
}
.ql-editor
ol
li
.ql-indent-7
:before
{
content
:
counter
(
list-7
,
lower-alpha
)
'. '
;
}
.ql-editor
ol
li
.ql-indent-7
{
counter-reset
:
list-8
list-9
;
}
.ql-editor
ol
li
.ql-indent-8
{
counter-increment
:
list-8
;
}
.ql-editor
ol
li
.ql-indent-8
:before
{
content
:
counter
(
list-8
,
lower-roman
)
'. '
;
}
.ql-editor
ol
li
.ql-indent-8
{
counter-reset
:
list-9
;
}
.ql-editor
ol
li
.ql-indent-9
{
counter-increment
:
list-9
;
}
.ql-editor
ol
li
.ql-indent-9
:before
{
content
:
counter
(
list-9
,
decimal
)
'. '
;
}
.ql-editor
.ql-indent-1
:not
(
.ql-direction-rtl
)
{
padding-left
:
2em
;
}
.ql-editor
li
.ql-indent-1
:not
(
.ql-direction-rtl
)
{
padding-left
:
2em
;
}
.ql-editor
.ql-indent-1.ql-direction-rtl.ql-align-right
{
padding-right
:
2em
;
}
.ql-editor
li
.ql-indent-1.ql-direction-rtl.ql-align-right
{
padding-right
:
2em
;
}
.ql-editor
.ql-indent-2
:not
(
.ql-direction-rtl
)
{
padding-left
:
4em
;
}
.ql-editor
li
.ql-indent-2
:not
(
.ql-direction-rtl
)
{
padding-left
:
4em
;
}
.ql-editor
.ql-indent-2.ql-direction-rtl.ql-align-right
{
padding-right
:
4em
;
}
.ql-editor
li
.ql-indent-2.ql-direction-rtl.ql-align-right
{
padding-right
:
4em
;
}
.ql-editor
.ql-indent-3
:not
(
.ql-direction-rtl
)
{
padding-left
:
6em
;
}
.ql-editor
li
.ql-indent-3
:not
(
.ql-direction-rtl
)
{
padding-left
:
6em
;
}
.ql-editor
.ql-indent-3.ql-direction-rtl.ql-align-right
{
padding-right
:
6em
;
}
.ql-editor
li
.ql-indent-3.ql-direction-rtl.ql-align-right
{
padding-right
:
6em
;
}
.ql-editor
.ql-indent-4
:not
(
.ql-direction-rtl
)
{
padding-left
:
8em
;
}
.ql-editor
li
.ql-indent-4
:not
(
.ql-direction-rtl
)
{
padding-left
:
8em
;
}
.ql-editor
.ql-indent-4.ql-direction-rtl.ql-align-right
{
padding-right
:
8em
;
}
.ql-editor
li
.ql-indent-4.ql-direction-rtl.ql-align-right
{
padding-right
:
8em
;
}
.ql-editor
.ql-indent-5
:not
(
.ql-direction-rtl
)
{
padding-left
:
10em
;
}
.ql-editor
li
.ql-indent-5
:not
(
.ql-direction-rtl
)
{
padding-left
:
10em
;
}
.ql-editor
.ql-indent-5.ql-direction-rtl.ql-align-right
{
padding-right
:
10em
;
}
.ql-editor
li
.ql-indent-5.ql-direction-rtl.ql-align-right
{
padding-right
:
10em
;
}
.ql-editor
.ql-indent-6
:not
(
.ql-direction-rtl
)
{
padding-left
:
12em
;
}
.ql-editor
li
.ql-indent-6
:not
(
.ql-direction-rtl
)
{
padding-left
:
12em
;
}
.ql-editor
.ql-indent-6.ql-direction-rtl.ql-align-right
{
padding-right
:
12em
;
}
.ql-editor
li
.ql-indent-6.ql-direction-rtl.ql-align-right
{
padding-right
:
12em
;
}
.ql-editor
.ql-indent-7
:not
(
.ql-direction-rtl
)
{
padding-left
:
14em
;
}
.ql-editor
li
.ql-indent-7
:not
(
.ql-direction-rtl
)
{
padding-left
:
14em
;
}
.ql-editor
.ql-indent-7.ql-direction-rtl.ql-align-right
{
padding-right
:
14em
;
}
.ql-editor
li
.ql-indent-7.ql-direction-rtl.ql-align-right
{
padding-right
:
14em
;
}
.ql-editor
.ql-indent-8
:not
(
.ql-direction-rtl
)
{
padding-left
:
16em
;
}
.ql-editor
li
.ql-indent-8
:not
(
.ql-direction-rtl
)
{
padding-left
:
16em
;
}
.ql-editor
.ql-indent-8.ql-direction-rtl.ql-align-right
{
padding-right
:
16em
;
}
.ql-editor
li
.ql-indent-8.ql-direction-rtl.ql-align-right
{
padding-right
:
16em
;
}
.ql-editor
.ql-indent-9
:not
(
.ql-direction-rtl
)
{
padding-left
:
18em
;
}
.ql-editor
li
.ql-indent-9
:not
(
.ql-direction-rtl
)
{
padding-left
:
18em
;
}
.ql-editor
.ql-indent-9.ql-direction-rtl.ql-align-right
{
padding-right
:
18em
;
}
.ql-editor
li
.ql-indent-9.ql-direction-rtl.ql-align-right
{
padding-right
:
18em
;
}
.ql-editor
.ql-direction-rtl
{
direction
:
rtl
;
text-align
:
inherit
;
}
.ql-editor
.ql-align-center
{
text-align
:
center
;
}
.ql-editor
.ql-align-justify
{
text-align
:
justify
;
}
.ql-editor
.ql-align-right
{
text-align
:
right
;
}
.ql-editor.ql-blank
::before
{
color
:
rgba
(
0
,
0
,
0
,
0.6
);
content
:
attr
(
data-placeholder
);
font-style
:
italic
;
pointer-events
:
none
;
position
:
absolute
;
}
.ql-container.ql-disabled
.ql-editor
ul
[
data-checked
]
>
li
::before
{
pointer-events
:
none
;
}
.ql-clipboard
{
left
:
-100000px
;
height
:
1px
;
overflow-y
:
hidden
;
position
:
absolute
;
top
:
50%
;
}
uni-image
{
width
:
320px
;
height
:
240px
;
display
:
inline-block
;
overflow
:
hidden
;
position
:
relative
;
}
uni-image
[
hidden
]
{
display
:
none
;
}
uni-image
>
div
{
width
:
100%
;
height
:
100%
;
}
uni-image
>
img
{
-webkit-touch-callout
:
none
;
-webkit-user-select
:
none
;
-moz-user-select
:
none
;
display
:
block
;
position
:
absolute
;
top
:
0
;
left
:
0
;
width
:
100%
;
height
:
100%
;
opacity
:
0
;
}
uni-image
>
.uni-image-will-change
{
will-change
:
transform
;
}
.uni-label-pointer
{
cursor
:
pointer
;
}
uni-movable-view
{
display
:
inline-block
;
width
:
10px
;
height
:
10px
;
top
:
0px
;
left
:
0px
;
position
:
absolute
;
cursor
:
grab
;
}
uni-movable-view
[
hidden
]
{
display
:
none
;
}
uni-navigator
{
height
:
auto
;
width
:
auto
;
display
:
block
;
cursor
:
pointer
;
}
uni-navigator
[
hidden
]
{
display
:
none
;
}
.navigator-hover
{
background-color
:
rgba
(
0
,
0
,
0
,
0.1
);
opacity
:
0.7
;
}
uni-radio
{
-webkit-tap-highlight-color
:
transparent
;
display
:
inline-block
;
cursor
:
pointer
;
}
uni-radio
[
hidden
]
{
display
:
none
;
}
uni-radio
[
disabled
]
{
cursor
:
not-allowed
;
}
uni-radio
.uni-radio-wrapper
{
display
:
-webkit-inline-flex
;
display
:
inline-flex
;
-webkit-align-items
:
center
;
align-items
:
center
;
vertical-align
:
middle
;
}
uni-radio
.uni-radio-input
{
-webkit-appearance
:
none
;
appearance
:
none
;
margin-right
:
5px
;
outline
:
0
;
border
:
1px
solid
#D1D1D1
;
background-color
:
#ffffff
;
border-radius
:
50%
;
width
:
22px
;
height
:
22px
;
position
:
relative
;
}
uni-radio
:not
([
disabled
])
.uni-radio-input
:hover
{
border-color
:
#007aff
;
}
uni-radio
.uni-radio-input.uni-radio-input-checked
:before
{
font
:
normal
normal
normal
14px
/
1
"uni"
;
content
:
"\EA08"
;
color
:
#ffffff
;
font-size
:
18px
;
position
:
absolute
;
top
:
50%
;
left
:
50%
;
transform
:
translate
(
-50%
,
-48%
)
scale
(
0.73
);
-webkit-transform
:
translate
(
-50%
,
-48%
)
scale
(
0.73
);
}
uni-radio
.uni-radio-input.uni-radio-input-disabled
{
background-color
:
#E1E1E1
;
border-color
:
#D1D1D1
;
}
uni-radio
.uni-radio-input.uni-radio-input-disabled
:before
{
color
:
#ADADAD
;
}
uni-radio-group
{
display
:
block
;
}
uni-radio-group
[
hidden
]
{
display
:
none
;
}
@keyframes
once-show
{
from
{
top
:
0
;
}
}
uni-resize-sensor
,
uni-resize-sensor
>
div
{
position
:
absolute
;
left
:
0
;
top
:
0
;
right
:
0
;
bottom
:
0
;
overflow
:
hidden
;
}
uni-resize-sensor
{
display
:
block
;
z-index
:
-1
;
visibility
:
hidden
;
animation
:
once-show
1ms
;
}
uni-resize-sensor
>
div
>
div
{
position
:
absolute
;
left
:
0
;
top
:
0
;
}
uni-resize-sensor
>
div
:first-child
>
div
{
width
:
100000px
;
height
:
100000px
;
}
uni-resize-sensor
>
div
:last-child
>
div
{
width
:
200%
;
height
:
200%
;
}
uni-scroll-view
{
display
:
block
;
width
:
100%
;
}
uni-scroll-view
[
hidden
]
{
display
:
none
;
}
.uni-scroll-view
{
position
:
relative
;
-webkit-overflow-scrolling
:
touch
;
width
:
100%
;
/* display: flex; 时在安卓下会导致scrollWidth和offsetWidth一样 */
height
:
100%
;
max-height
:
inherit
;
}
.uni-scroll-view-content
{
width
:
100%
;
height
:
100%
;
}
.uni-scroll-view-refresher
{
position
:
relative
;
overflow
:
hidden
;
}
.uni-scroll-view-refresh
{
position
:
absolute
;
top
:
0
;
left
:
0
;
right
:
0
;
bottom
:
0
;
display
:
flex
;
flex-direction
:
row
;
justify-content
:
center
;
align-items
:
center
;
}
.uni-scroll-view-refresh-inner
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
line-height
:
0
;
width
:
40px
;
height
:
40px
;
border-radius
:
50%
;
background-color
:
#fff
;
box-shadow
:
0
1px
6px
rgba
(
0
,
0
,
0
,
0.117647
),
0
1px
4px
rgba
(
0
,
0
,
0
,
0.117647
);
}
.uni-scroll-view-refresh__spinner
{
transform-origin
:
center
center
;
animation
:
uni-scroll-view-refresh-rotate
2s
linear
infinite
;
}
.uni-scroll-view-refresh__spinner
>
circle
{
stroke
:
currentColor
;
stroke-linecap
:
round
;
animation
:
uni-scroll-view-refresh-dash
2s
linear
infinite
;
}
@keyframes
uni-scroll-view-refresh-rotate
{
0
%
{
transform
:
rotate
(
0deg
);
}
100
%
{
transform
:
rotate
(
360deg
);
}
}
@keyframes
uni-scroll-view-refresh-dash
{
0
%
{
stroke-dasharray
:
1
,
200
;
stroke-dashoffset
:
0
;
}
50
%
{
stroke-dasharray
:
89
,
200
;
stroke-dashoffset
:
-35px
;
}
100
%
{
stroke-dasharray
:
89
,
200
;
stroke-dashoffset
:
-124px
;
}
}
uni-swiper-item
{
display
:
block
;
overflow
:
hidden
;
will-change
:
transform
;
position
:
absolute
;
width
:
100%
;
height
:
100%
;
cursor
:
grab
;
}
uni-swiper-item
[
hidden
]
{
display
:
none
;
}
uni-switch
{
-webkit-tap-highlight-color
:
transparent
;
display
:
inline-block
;
cursor
:
pointer
;
}
uni-switch
[
hidden
]
{
display
:
none
;
}
uni-switch
[
disabled
]
{
cursor
:
not-allowed
;
}
uni-switch
.uni-switch-wrapper
{
display
:
-webkit-inline-flex
;
display
:
inline-flex
;
-webkit-align-items
:
center
;
align-items
:
center
;
vertical-align
:
middle
;
}
uni-switch
.uni-switch-input
{
-webkit-appearance
:
none
;
appearance
:
none
;
position
:
relative
;
width
:
52px
;
height
:
32px
;
margin-right
:
5px
;
border
:
1px
solid
#DFDFDF
;
outline
:
0
;
border-radius
:
16px
;
box-sizing
:
border-box
;
background-color
:
#DFDFDF
;
transition
:
background-color
0.1s
,
border
0.1s
;
}
uni-switch
[
disabled
]
.uni-switch-input
{
opacity
:
.7
;
}
uni-switch
.uni-switch-input
:before
{
content
:
" "
;
position
:
absolute
;
top
:
0
;
left
:
0
;
width
:
50px
;
height
:
30px
;
border-radius
:
15px
;
background-color
:
#FDFDFD
;
transition
:
-webkit-transform
0.3s
;
transition
:
transform
0.3s
;
transition
:
transform
0.3s
,
-webkit-transform
0.3s
;
}
uni-switch
.uni-switch-input
:after
{
content
:
" "
;
position
:
absolute
;
top
:
0
;
left
:
0
;
width
:
30px
;
height
:
30px
;
border-radius
:
15px
;
background-color
:
#FFFFFF
;
box-shadow
:
0
1px
3px
rgba
(
0
,
0
,
0
,
0.4
);
transition
:
-webkit-transform
0.3s
;
transition
:
transform
0.3s
;
transition
:
transform
0.3s
,
-webkit-transform
0.3s
;
}
uni-switch
.uni-switch-input.uni-switch-input-checked
{
border-color
:
#007aff
;
background-color
:
#007aff
;
}
uni-switch
.uni-switch-input.uni-switch-input-checked
:before
{
-webkit-transform
:
scale
(
0
);
transform
:
scale
(
0
);
}
uni-switch
.uni-switch-input.uni-switch-input-checked
:after
{
-webkit-transform
:
translateX
(
20px
);
transform
:
translateX
(
20px
);
}
uni-switch
.uni-checkbox-input
{
margin-right
:
5px
;
-webkit-appearance
:
none
;
appearance
:
none
;
outline
:
0
;
border
:
1px
solid
#D1D1D1
;
background-color
:
#FFFFFF
;
border-radius
:
3px
;
width
:
22px
;
height
:
22px
;
position
:
relative
;
color
:
#007aff
;
}
uni-switch
:not
([
disabled
])
.uni-checkbox-input
:hover
{
border-color
:
#007aff
;
}
uni-switch
.uni-checkbox-input.uni-checkbox-input-checked
:before
{
font
:
normal
normal
normal
14px
/
1
"uni"
;
content
:
"\EA08"
;
color
:
inherit
;
font-size
:
22px
;
position
:
absolute
;
top
:
50%
;
left
:
50%
;
transform
:
translate
(
-50%
,
-48%
)
scale
(
0.73
);
-webkit-transform
:
translate
(
-50%
,
-48%
)
scale
(
0.73
);
}
uni-switch
.uni-checkbox-input.uni-checkbox-input-disabled
{
background-color
:
#E1E1E1
;
}
uni-switch
.uni-checkbox-input.uni-checkbox-input-disabled
:before
{
color
:
#ADADAD
;
}
uni-text
[
selectable
]
{
cursor
:
auto
;
user-select
:
text
;
-webkit-user-select
:
text
;
}
uni-textarea
{
width
:
300px
;
height
:
150px
;
display
:
block
;
position
:
relative
;
font-size
:
16px
;
line-height
:
normal
;
white-space
:
pre-wrap
;
word-break
:
break-all
;
}
uni-textarea
[
hidden
]
{
display
:
none
;
}
.uni-textarea-wrapper
,
.uni-textarea-placeholder
,
.uni-textarea-line
,
.uni-textarea-compute
,
.uni-textarea-textarea
{
outline
:
none
;
border
:
none
;
padding
:
0
;
margin
:
0
;
text-decoration
:
inherit
;
}
.uni-textarea-wrapper
{
display
:
block
;
position
:
relative
;
width
:
100%
;
height
:
100%
;
}
.uni-textarea-placeholder
,
.uni-textarea-line
,
.uni-textarea-compute
,
.uni-textarea-textarea
{
position
:
absolute
;
width
:
100%
;
height
:
100%
;
left
:
0
;
top
:
0
;
white-space
:
inherit
;
word-break
:
inherit
;
}
.uni-textarea-placeholder
{
color
:
grey
;
overflow
:
hidden
;
}
.uni-textarea-line
,
.uni-textarea-compute
{
visibility
:
hidden
;
height
:
auto
;
}
.uni-textarea-line
{
width
:
1em
;
}
.uni-textarea-textarea
{
resize
:
none
;
background
:
none
;
color
:
inherit
;
opacity
:
1
;
-webkit-text-fill-color
:
currentcolor
;
font
:
inherit
;
line-height
:
inherit
;
letter-spacing
:
inherit
;
text-align
:
inherit
;
text-indent
:
inherit
;
text-transform
:
inherit
;
text-shadow
:
inherit
;
}
/* 用于解决 iOS textarea 内部默认边距 */
.uni-textarea-textarea-fix-margin
{
width
:
auto
;
right
:
0
;
margin
:
0
-3px
;
}
.uni-async-error
{
position
:
absolute
;
left
:
0
;
right
:
0
;
top
:
0
;
bottom
:
0
;
color
:
#999
;
padding
:
100px
10px
;
text-align
:
center
;
}
.uni-async-loading
{
box-sizing
:
border-box
;
width
:
100%
;
padding
:
50px
;
text-align
:
center
;
}
.uni-async-loading
.uni-loading
{
width
:
30px
;
height
:
30px
;
}
packages/uni-h5/dist/uni-h5.esm.js
浏览文件 @
5e7465a9
...
@@ -445,15 +445,11 @@ function $handleEvent($event) {
...
@@ -445,15 +445,11 @@ function $handleEvent($event) {
}
}
return
$event
;
return
$event
;
}
}
function
$getRealPath
(
v2
)
{
return
v2
;
}
var
instance
=
/* @__PURE__ */
Object
.
freeze
({
var
instance
=
/* @__PURE__ */
Object
.
freeze
({
__proto__
:
null
,
__proto__
:
null
,
[
Symbol
.
toStringTag
]:
"
Module
"
,
[
Symbol
.
toStringTag
]:
"
Module
"
,
$trigger
,
$trigger
,
$handleEvent
,
$handleEvent
$getRealPath
});
});
const
CLASS_RE
=
/^
\s
+|
\s
+$/g
;
const
CLASS_RE
=
/^
\s
+|
\s
+$/g
;
const
WXS_CLASS_RE
=
/
\s
+/
;
const
WXS_CLASS_RE
=
/
\s
+/
;
...
@@ -891,6 +887,12 @@ function createPageState(type) {
...
@@ -891,6 +887,12 @@ function createPageState(type) {
function
isPage
(
vm
)
{
function
isPage
(
vm
)
{
return
vm
.
$options
.
mpType
===
"
page
"
;
return
vm
.
$options
.
mpType
===
"
page
"
;
}
}
function
normalizeRoute
(
path
)
{
if
(
path
.
indexOf
(
"
/
"
)
===
0
)
{
return
path
.
substr
(
1
);
}
return
path
;
}
function
initPublicPage
(
route
)
{
function
initPublicPage
(
route
)
{
if
(
!
route
)
{
if
(
!
route
)
{
const
{
path
}
=
__uniRoutes
[
0
];
const
{
path
}
=
__uniRoutes
[
0
];
...
@@ -899,7 +901,7 @@ function initPublicPage(route) {
...
@@ -899,7 +901,7 @@ function initPublicPage(route) {
return
{
return
{
id
,
id
,
path
:
route
.
path
,
path
:
route
.
path
,
route
:
route
.
meta
.
pagePath
,
route
:
normalizeRoute
(
route
.
meta
.
route
||
route
.
path
)
,
fullPath
:
route
.
meta
.
isEntry
?
route
.
meta
.
pagePath
:
route
.
fullPath
,
fullPath
:
route
.
meta
.
isEntry
?
route
.
meta
.
pagePath
:
route
.
fullPath
,
options
:
{},
options
:
{},
meta
:
usePageMeta
()
meta
:
usePageMeta
()
...
@@ -908,7 +910,7 @@ function initPublicPage(route) {
...
@@ -908,7 +910,7 @@ function initPublicPage(route) {
function
initPage
(
vm
)
{
function
initPage
(
vm
)
{
currentPages
.
push
(
vm
);
currentPages
.
push
(
vm
);
const
route
=
vm
.
$route
;
const
route
=
vm
.
$route
;
vm
.
__page__
=
initPublicPage
(
route
);
vm
.
$page
=
initPublicPage
(
route
);
}
}
function
routeCache
(
key
,
cache
,
pruneCacheEntry
)
{
function
routeCache
(
key
,
cache
,
pruneCacheEntry
)
{
const
pageId
=
parseInt
(
key
.
split
(
SEP
)[
1
]);
const
pageId
=
parseInt
(
key
.
split
(
SEP
)[
1
]);
...
@@ -3303,7 +3305,41 @@ var index$1 = defineComponent({
...
@@ -3303,7 +3305,41 @@ var index$1 = defineComponent({
return
()
=>
createVNode
(
"
uni-icon
"
,
null
,
[
path
.
value
.
d
&&
createSvgIconVNode
(
path
.
value
.
d
,
props
.
color
||
path
.
value
.
c
,
rpx2px
(
props
.
size
))]);
return
()
=>
createVNode
(
"
uni-icon
"
,
null
,
[
path
.
value
.
d
&&
createSvgIconVNode
(
path
.
value
.
d
,
props
.
color
||
path
.
value
.
c
,
rpx2px
(
props
.
size
))]);
}
}
});
});
var
index_vue_vue_type_style_index_0_lang$d
=
"
\n
uni-image {
\r\n
width: 320px;
\r\n
height: 240px;
\r\n
display: inline-block;
\r\n
overflow: hidden;
\r\n
position: relative;
\n
}
\n
uni-image[hidden] {
\r\n
display: none;
\n
}
\n
uni-image>div {
\r\n
width: 100%;
\r\n
height: 100%;
\n
}
\n
uni-image>img {
\r\n
-webkit-touch-callout: none;
\r\n
-webkit-user-select: none;
\r\n
-moz-user-select: none;
\r\n
display: block;
\r\n
position: absolute;
\r\n
top: 0;
\r\n
left: 0;
\r\n
width: 100%;
\r\n
height: 100%;
\r\n
opacity: 0;
\n
}
\n
uni-image>.uni-image-will-change {
\r\n
will-change: transform;
\n
}
\r\n
"
;
const
SCHEME_RE
=
/^
([
a-z-
]
+:
)?\/\/
/i
;
const
DATA_RE
=
/^data:.*,.*/
;
function
addBase
(
filePath
)
{
const
base
=
__uniConfig
.
router
.
base
;
if
(
!
base
)
{
return
filePath
;
}
if
(
base
!==
"
/
"
)
{
if
((
"
/
"
+
filePath
).
indexOf
(
base
)
===
0
)
{
return
"
/
"
+
filePath
;
}
}
return
base
+
filePath
;
}
function
getRealPath$1
(
filePath
)
{
if
(
__uniConfig
.
router
.
base
===
"
./
"
)
{
filePath
=
filePath
.
replace
(
/^
\.\/
static
\/
/
,
"
/static/
"
);
}
if
(
filePath
.
indexOf
(
"
/
"
)
===
0
)
{
if
(
filePath
.
indexOf
(
"
//
"
)
===
0
)
{
filePath
=
"
https:
"
+
filePath
;
}
else
{
return
addBase
(
filePath
.
substr
(
1
));
}
}
if
(
SCHEME_RE
.
test
(
filePath
)
||
DATA_RE
.
test
(
filePath
)
||
filePath
.
indexOf
(
"
blob:
"
)
===
0
)
{
return
filePath
;
}
const
pages
=
getCurrentPages
();
if
(
pages
.
length
)
{
return
addBase
(
getRealRoute
(
pages
[
pages
.
length
-
1
].
$page
.
route
,
filePath
).
substr
(
1
));
}
return
filePath
;
}
var
index_vue_vue_type_style_index_0_lang$d
=
"
\n
uni-image {
\r\n
width: 320px;
\r\n
height: 240px;
\r\n
display: inline-block;
\r\n
overflow: hidden;
\r\n
position: relative;
\n
}
\n
uni-image[hidden] {
\r\n
display: none;
\n
}
\n
uni-image > div {
\r\n
width: 100%;
\r\n
height: 100%;
\n
}
\n
uni-image > img {
\r\n
-webkit-touch-callout: none;
\r\n
-webkit-user-select: none;
\r\n
-moz-user-select: none;
\r\n
display: block;
\r\n
position: absolute;
\r\n
top: 0;
\r\n
left: 0;
\r\n
width: 100%;
\r\n
height: 100%;
\r\n
opacity: 0;
\n
}
\n
uni-image > .uni-image-will-change {
\r\n
will-change: transform;
\n
}
\r\n
"
;
const
_sfc_main$j
=
{
const
_sfc_main$j
=
{
name
:
"
Image
"
,
name
:
"
Image
"
,
props
:
{
props
:
{
...
@@ -3332,7 +3368,7 @@ const _sfc_main$j = {
...
@@ -3332,7 +3368,7 @@ const _sfc_main$j = {
return
this
.
originalWidth
&&
this
.
originalHeight
?
this
.
originalWidth
/
this
.
originalHeight
:
0
;
return
this
.
originalWidth
&&
this
.
originalHeight
?
this
.
originalWidth
/
this
.
originalHeight
:
0
;
},
},
realImagePath
()
{
realImagePath
()
{
return
this
.
$getRealPath
(
this
.
src
);
return
getRealPath$1
(
this
.
src
);
},
},
modeStyle
()
{
modeStyle
()
{
let
size
=
"
auto
"
;
let
size
=
"
auto
"
;
...
@@ -8094,7 +8130,7 @@ const reLaunch = /* @__PURE__ */ createAsyncApi("reLaunch", () => {
...
@@ -8094,7 +8130,7 @@ const reLaunch = /* @__PURE__ */ createAsyncApi("reLaunch", () => {
});
});
const
switchTab
=
/* @__PURE__ */
createAsyncApi
(
"
switchTab
"
,
()
=>
{
const
switchTab
=
/* @__PURE__ */
createAsyncApi
(
"
switchTab
"
,
()
=>
{
});
});
const
getRealPath
$1
=
/* @__PURE__ */
createSyncApi
(
"
getRealPath
"
,
(
path
)
=>
{
const
getRealPath
=
/* @__PURE__ */
createSyncApi
(
"
getRealPath
"
,
(
path
)
=>
{
return
path
;
return
path
;
});
});
var
api
=
/* @__PURE__ */
Object
.
freeze
({
var
api
=
/* @__PURE__ */
Object
.
freeze
({
...
@@ -8119,7 +8155,7 @@ var api = /* @__PURE__ */ Object.freeze({
...
@@ -8119,7 +8155,7 @@ var api = /* @__PURE__ */ Object.freeze({
redirectTo
,
redirectTo
,
reLaunch
,
reLaunch
,
switchTab
,
switchTab
,
getRealPath
:
getRealPath$1
getRealPath
});
});
const
uni$1
=
api
;
const
uni$1
=
api
;
const
UniServiceJSBridge$1
=
extend
(
ServiceJSBridge
,
{
const
UniServiceJSBridge$1
=
extend
(
ServiceJSBridge
,
{
...
@@ -8216,40 +8252,6 @@ function usePageHeadTransparent(headRef, {titleColor, coverage, backgroundColor}
...
@@ -8216,40 +8252,6 @@ function usePageHeadTransparent(headRef, {titleColor, coverage, backgroundColor}
});
});
});
});
}
}
const
SCHEME_RE
=
/^
([
a-z-
]
+:
)?\/\/
/i
;
const
DATA_RE
=
/^data:.*,.*/
;
function
addBase
(
filePath
)
{
const
base
=
__uniConfig
.
router
.
base
;
if
(
!
base
)
{
return
filePath
;
}
if
(
base
!==
"
/
"
)
{
if
((
"
/
"
+
filePath
).
indexOf
(
base
)
===
0
)
{
return
"
/
"
+
filePath
;
}
}
return
base
+
filePath
;
}
function
getRealPath
(
filePath
)
{
if
(
__uniConfig
.
router
.
base
===
"
./
"
)
{
filePath
=
filePath
.
replace
(
/^
\.\/
static
\/
/
,
"
/static/
"
);
}
if
(
filePath
.
indexOf
(
"
/
"
)
===
0
)
{
if
(
filePath
.
indexOf
(
"
//
"
)
===
0
)
{
filePath
=
"
https:
"
+
filePath
;
}
else
{
return
addBase
(
filePath
.
substr
(
1
));
}
}
if
(
SCHEME_RE
.
test
(
filePath
)
||
DATA_RE
.
test
(
filePath
)
||
filePath
.
indexOf
(
"
blob:
"
)
===
0
)
{
return
filePath
;
}
const
pages
=
getCurrentPages
();
if
(
pages
.
length
)
{
return
addBase
(
getRealRoute
(
pages
[
pages
.
length
-
1
].
$page
.
route
,
filePath
).
substr
(
1
));
}
return
filePath
;
}
const
ICON_PATH_BACK
=
"
M21.781 7.844l-9.063 8.594 9.063 8.594q0.25 0.25 0.25 0.609t-0.25 0.578q-0.25 0.25-0.578 0.25t-0.578-0.25l-9.625-9.125q-0.156-0.125-0.203-0.297t-0.047-0.359q0-0.156 0.047-0.328t0.203-0.297l9.625-9.125q0.25-0.25 0.578-0.25t0.578 0.25q0.25 0.219 0.25 0.578t-0.25 0.578z
"
;
const
ICON_PATH_BACK
=
"
M21.781 7.844l-9.063 8.594 9.063 8.594q0.25 0.25 0.25 0.609t-0.25 0.578q-0.25 0.25-0.578 0.25t-0.578-0.25l-9.625-9.125q-0.156-0.125-0.203-0.297t-0.047-0.359q0-0.156 0.047-0.328t0.203-0.297l9.625-9.125q0.25-0.25 0.578-0.25t0.578 0.25q0.25 0.219 0.25 0.578t-0.25 0.578z
"
;
const
ICON_PATHS
=
{
const
ICON_PATHS
=
{
none
:
""
,
none
:
""
,
...
@@ -8439,7 +8441,7 @@ function usePageHeadButtons(navigationBar) {
...
@@ -8439,7 +8441,7 @@ function usePageHeadButtons(navigationBar) {
const
fonts
=
Object
.
create
(
null
);
const
fonts
=
Object
.
create
(
null
);
buttons
.
forEach
((
btn
)
=>
{
buttons
.
forEach
((
btn
)
=>
{
if
(
btn
.
fontSrc
&&
!
btn
.
fontFamily
)
{
if
(
btn
.
fontSrc
&&
!
btn
.
fontFamily
)
{
const
fontSrc
=
getRealPath
(
btn
.
fontSrc
);
const
fontSrc
=
getRealPath
$1
(
btn
.
fontSrc
);
let
fontFamily
=
fonts
[
fontSrc
];
let
fontFamily
=
fonts
[
fontSrc
];
if
(
!
fontFamily
)
{
if
(
!
fontFamily
)
{
fontFamily
=
`font
${
Date
.
now
()}
`
;
fontFamily
=
`font
${
Date
.
now
()}
`
;
...
@@ -9243,4 +9245,4 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
...
@@ -9243,4 +9245,4 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
]);
]);
}
}
_sfc_main
.
render
=
_sfc_render
;
_sfc_main
.
render
=
_sfc_render
;
export
{
_sfc_main$1
as
AsyncErrorComponent
,
_sfc_main
as
AsyncLoadingComponent
,
_sfc_main$p
as
Audio
,
_sfc_main$o
as
Canvas
,
_sfc_main$n
as
Checkbox
,
_sfc_main$m
as
CheckboxGroup
,
_sfc_main$l
as
Editor
,
_sfc_main$k
as
Form
,
index$1
as
Icon
,
_sfc_main$j
as
Image
,
_sfc_main$i
as
Input
,
_sfc_main$h
as
Label
,
_sfc_main$g
as
MovableView
,
_sfc_main$f
as
Navigator
,
index
as
PageComponent
,
_sfc_main$e
as
Progress
,
_sfc_main$d
as
Radio
,
_sfc_main$c
as
RadioGroup
,
_sfc_main$b
as
ResizeSensor
,
_sfc_main$a
as
RichText
,
_sfc_main$9
as
ScrollView
,
_sfc_main$8
as
Slider
,
_sfc_main$7
as
SwiperItem
,
_sfc_main$6
as
Switch
,
_sfc_main$5
as
Text
,
_sfc_main$4
as
Textarea
,
UniServiceJSBridge$1
as
UniServiceJSBridge
,
UniViewJSBridge$1
as
UniViewJSBridge
,
_sfc_main$3
as
View
,
addInterceptor
,
arrayBufferToBase64
,
base64ToArrayBuffer
,
canIUse
,
createIntersectionObserver
,
createSelectorQuery
,
getApp$1
as
getApp
,
getCurrentPages$1
as
getCurrentPages
,
getImageInfo
,
getRealPath
$1
as
getRealPath
,
getSystemInfo
,
getSystemInfoSync
,
makePhoneCall
,
navigateBack
,
navigateTo
,
openDocument
,
index$2
as
plugin
,
promiseInterceptor
,
reLaunch
,
redirectTo
,
removeInterceptor
,
switchTab
,
uni$1
as
uni
,
upx2px
};
export
{
_sfc_main$1
as
AsyncErrorComponent
,
_sfc_main
as
AsyncLoadingComponent
,
_sfc_main$p
as
Audio
,
_sfc_main$o
as
Canvas
,
_sfc_main$n
as
Checkbox
,
_sfc_main$m
as
CheckboxGroup
,
_sfc_main$l
as
Editor
,
_sfc_main$k
as
Form
,
index$1
as
Icon
,
_sfc_main$j
as
Image
,
_sfc_main$i
as
Input
,
_sfc_main$h
as
Label
,
_sfc_main$g
as
MovableView
,
_sfc_main$f
as
Navigator
,
index
as
PageComponent
,
_sfc_main$e
as
Progress
,
_sfc_main$d
as
Radio
,
_sfc_main$c
as
RadioGroup
,
_sfc_main$b
as
ResizeSensor
,
_sfc_main$a
as
RichText
,
_sfc_main$9
as
ScrollView
,
_sfc_main$8
as
Slider
,
_sfc_main$7
as
SwiperItem
,
_sfc_main$6
as
Switch
,
_sfc_main$5
as
Text
,
_sfc_main$4
as
Textarea
,
UniServiceJSBridge$1
as
UniServiceJSBridge
,
UniViewJSBridge$1
as
UniViewJSBridge
,
_sfc_main$3
as
View
,
addInterceptor
,
arrayBufferToBase64
,
base64ToArrayBuffer
,
canIUse
,
createIntersectionObserver
,
createSelectorQuery
,
getApp$1
as
getApp
,
getCurrentPages$1
as
getCurrentPages
,
getImageInfo
,
getRealPath
,
getSystemInfo
,
getSystemInfoSync
,
makePhoneCall
,
navigateBack
,
navigateTo
,
openDocument
,
index$2
as
plugin
,
promiseInterceptor
,
reLaunch
,
redirectTo
,
removeInterceptor
,
switchTab
,
uni$1
as
uni
,
upx2px
};
packages/uni-h5/src/framework/components/page/pageHead.tsx
浏览文件 @
5e7465a9
import
{
computed
,
defineComponent
,
Ref
,
ref
}
from
'
vue
'
import
{
computed
,
defineComponent
,
Ref
,
ref
}
from
'
vue
'
import
{
isArray
}
from
'
@vue/shared
'
import
{
isArray
}
from
'
@vue/shared
'
import
{
Input
}
from
'
@dcloudio/uni-components
'
import
{
Input
}
from
'
@dcloudio/uni-components
'
import
{
getRealPath
}
from
'
@dcloudio/uni-platform
'
import
{
ICON_PATH_SEARCH
,
createSvgIconVNode
}
from
'
@dcloudio/uni-core
'
import
{
ICON_PATH_SEARCH
,
createSvgIconVNode
}
from
'
@dcloudio/uni-core
'
import
{
usePageMeta
}
from
'
../../plugin/provide
'
import
{
usePageMeta
}
from
'
../../plugin/provide
'
import
{
import
{
...
@@ -9,7 +10,6 @@ import {
...
@@ -9,7 +10,6 @@ import {
}
from
'
./transparent
'
}
from
'
./transparent
'
import
{
updateStyle
}
from
'
../../../helpers/dom
'
import
{
updateStyle
}
from
'
../../../helpers/dom
'
import
{
getRealPath
}
from
'
../../../helpers/getRealPath
'
const
ICON_PATH_BACK
=
const
ICON_PATH_BACK
=
'
M21.781 7.844l-9.063 8.594 9.063 8.594q0.25 0.25 0.25 0.609t-0.25 0.578q-0.25 0.25-0.578 0.25t-0.578-0.25l-9.625-9.125q-0.156-0.125-0.203-0.297t-0.047-0.359q0-0.156 0.047-0.328t0.203-0.297l9.625-9.125q0.25-0.25 0.578-0.25t0.578 0.25q0.25 0.219 0.25 0.578t-0.25 0.578z
'
'
M21.781 7.844l-9.063 8.594 9.063 8.594q0.25 0.25 0.25 0.609t-0.25 0.578q-0.25 0.25-0.578 0.25t-0.578-0.25l-9.625-9.125q-0.156-0.125-0.203-0.297t-0.047-0.359q0-0.156 0.047-0.328t0.203-0.297l9.625-9.125q0.25-0.25 0.578-0.25t0.578 0.25q0.25 0.219 0.25 0.578t-0.25 0.578z
'
...
...
packages/uni-h5/src/framework/plugin/page.ts
浏览文件 @
5e7465a9
...
@@ -26,6 +26,13 @@ export function isPage(vm: ComponentPublicInstance) {
...
@@ -26,6 +26,13 @@ export function isPage(vm: ComponentPublicInstance) {
return
vm
.
$options
.
mpType
===
'
page
'
return
vm
.
$options
.
mpType
===
'
page
'
}
}
function
normalizeRoute
(
path
:
string
)
{
if
(
path
.
indexOf
(
'
/
'
)
===
0
)
{
return
path
.
substr
(
1
)
}
return
path
}
function
initPublicPage
(
route
:
RouteLocationNormalizedLoaded
)
{
function
initPublicPage
(
route
:
RouteLocationNormalizedLoaded
)
{
if
(
!
route
)
{
if
(
!
route
)
{
const
{
path
}
=
__uniRoutes
[
0
]
const
{
path
}
=
__uniRoutes
[
0
]
...
@@ -34,7 +41,7 @@ function initPublicPage(route: RouteLocationNormalizedLoaded) {
...
@@ -34,7 +41,7 @@ function initPublicPage(route: RouteLocationNormalizedLoaded) {
return
{
return
{
id
,
id
,
path
:
route
.
path
,
path
:
route
.
path
,
route
:
route
.
meta
.
pagePath
,
route
:
normalizeRoute
((
route
.
meta
.
route
as
string
)
||
route
.
path
)
,
fullPath
:
route
.
meta
.
isEntry
?
route
.
meta
.
pagePath
:
route
.
fullPath
,
fullPath
:
route
.
meta
.
isEntry
?
route
.
meta
.
pagePath
:
route
.
fullPath
,
options
:
{},
// $route.query
options
:
{},
// $route.query
meta
:
usePageMeta
(),
meta
:
usePageMeta
(),
...
@@ -44,7 +51,7 @@ function initPublicPage(route: RouteLocationNormalizedLoaded) {
...
@@ -44,7 +51,7 @@ function initPublicPage(route: RouteLocationNormalizedLoaded) {
export
function
initPage
(
vm
:
ComponentPublicInstance
)
{
export
function
initPage
(
vm
:
ComponentPublicInstance
)
{
currentPages
.
push
(
vm
as
Page
.
PageInstance
)
currentPages
.
push
(
vm
as
Page
.
PageInstance
)
const
route
=
vm
.
$route
const
route
=
vm
.
$route
;(
vm
as
any
).
__page__
=
initPublicPage
(
route
)
;(
vm
as
any
).
$page
=
initPublicPage
(
route
)
}
}
// TODO
// TODO
...
...
packages/uni-h5/src/
helpers
/getRealPath.ts
→
packages/uni-h5/src/
platform
/getRealPath.ts
浏览文件 @
5e7465a9
文件已移动
packages/uni-h5/src/platform/index.ts
0 → 100644
浏览文件 @
5e7465a9
export
*
from
'
./getRealPath
'
packages/uni-h5/vite.config.ts
浏览文件 @
5e7465a9
...
@@ -43,6 +43,10 @@ export default defineConfig({
...
@@ -43,6 +43,10 @@ export default defineConfig({
find
:
'
@dcloudio/uni-components
'
,
find
:
'
@dcloudio/uni-components
'
,
replacement
:
resolve
(
'
../uni-components/src/index.ts
'
),
replacement
:
resolve
(
'
../uni-components/src/index.ts
'
),
},
},
{
find
:
'
@dcloudio/uni-platform
'
,
replacement
:
resolve
(
'
./src/platform/index.ts
'
),
},
],
],
},
},
plugins
:
[
plugins
:
[
...
...
packages/vite-plugin-uni/__tests__/static.spec.ts
0 → 100644
浏览文件 @
5e7465a9
import
{
createPublicFileFilter
}
from
'
../src/utils
'
describe
(
'
static
'
,
()
=>
{
test
(
'
filter
'
,
()
=>
{
const
filter
=
createPublicFileFilter
(
'
/
'
)
expect
(
filter
(
'
logo.png
'
)).
toBe
(
false
)
expect
(
filter
(
'
/static/logo.png
'
)).
toBe
(
true
)
expect
(
filter
(
'
/static/test/logo.png
'
)).
toBe
(
true
)
expect
(
filter
(
'
/uni_modules/fxy-components/logo.png
'
)).
toBe
(
false
)
expect
(
filter
(
'
/uni_modules/fxy-components/static/logo.png
'
)).
toBe
(
true
)
expect
(
filter
(
'
/uni_modules/fxy-components/static/test/logo.png
'
)).
toBe
(
true
)
})
})
packages/vite-plugin-uni/package.json
浏览文件 @
5e7465a9
...
@@ -27,16 +27,18 @@
...
@@ -27,16 +27,18 @@
"fs-extra"
:
"^9.0.1"
,
"fs-extra"
:
"^9.0.1"
,
"jsonc-parser"
:
"^3.0.0"
,
"jsonc-parser"
:
"^3.0.0"
,
"magic-string"
:
"^0.25.7"
,
"magic-string"
:
"^0.25.7"
,
"mime"
:
"^2.5.2"
,
"rollup-plugin-copy"
:
"^3.4.0"
,
"rollup-plugin-copy"
:
"^3.4.0"
,
"slash"
:
"^3.0.0"
"slash"
:
"^3.0.0"
},
},
"peerDependencies"
:
{
"peerDependencies"
:
{
"@dcloudio/uni-cli-shared"
:
"^3.0.0"
,
"@dcloudio/uni-cli-shared"
:
"^3.0.0"
,
"@dcloudio/uni-shared"
:
"^3.0.0"
,
"@dcloudio/uni-shared"
:
"^3.0.0"
,
"@vue/shared"
:
"^3.0.
7
"
,
"@vue/shared"
:
"^3.0.
10
"
,
"vite"
:
"^2.1.
1
"
"vite"
:
"^2.1.
5
"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"@types/mime"
:
"^2.0.3"
,
"@types/sass"
:
"^1.16.0"
"@types/sass"
:
"^1.16.0"
},
},
"uni-app"
:
{
"uni-app"
:
{
...
...
packages/vite-plugin-uni/src/configResolved/plugins/copy.ts
浏览文件 @
5e7465a9
import
path
from
'
path
'
import
path
from
'
path
'
import
{
Plugin
}
from
'
vite
'
import
{
Plugin
}
from
'
vite
'
import
copy
from
'
rollup-plugin-copy
'
import
copy
from
'
rollup-plugin-copy
'
import
{
PUBLIC_DIR
}
from
'
@dcloudio/uni-cli-shared
'
import
{
VitePluginUniResolvedOptions
}
from
'
../..
'
import
{
VitePluginUniResolvedOptions
}
from
'
../..
'
export
function
uniCopyPlugin
({
export
function
uniCopyPlugin
({
...
@@ -11,11 +12,11 @@ export function uniCopyPlugin({
...
@@ -11,11 +12,11 @@ export function uniCopyPlugin({
return
copy
({
return
copy
({
targets
:
[
targets
:
[
{
{
src
:
path
.
resolve
(
inputDir
,
'
static
'
),
src
:
path
.
resolve
(
inputDir
,
PUBLIC_DIR
),
dest
:
outputDir
,
dest
:
outputDir
,
},
},
{
{
src
:
path
.
resolve
(
inputDir
,
'
uni_modules/*/
static
'
),
src
:
path
.
resolve
(
inputDir
,
'
uni_modules/*/
'
+
PUBLIC_DIR
),
dest
:
outputDir
,
dest
:
outputDir
,
rename
:
(
name
,
extension
,
fullPath
)
=>
{
rename
:
(
name
,
extension
,
fullPath
)
=>
{
return
path
.
relative
(
inputDir
,
fullPath
)
return
path
.
relative
(
inputDir
,
fullPath
)
...
...
packages/vite-plugin-uni/src/configResolved/plugins/index.ts
浏览文件 @
5e7465a9
...
@@ -14,6 +14,7 @@ import { uniPagesJsonPlugin } from './pagesJson'
...
@@ -14,6 +14,7 @@ import { uniPagesJsonPlugin } from './pagesJson'
import
{
uniManifestJsonPlugin
}
from
'
./manifestJson
'
import
{
uniManifestJsonPlugin
}
from
'
./manifestJson
'
import
{
uniPageVuePlugin
}
from
'
./pageVue
'
import
{
uniPageVuePlugin
}
from
'
./pageVue
'
import
{
uniCopyPlugin
}
from
'
./copy
'
import
{
uniCopyPlugin
}
from
'
./copy
'
import
{
uniStaticPlugin
}
from
'
./static
'
const
debugPlugin
=
debug
(
'
uni:plugin
'
)
const
debugPlugin
=
debug
(
'
uni:plugin
'
)
...
@@ -93,6 +94,7 @@ export function resolvePlugins(
...
@@ -93,6 +94,7 @@ export function resolvePlugins(
)
)
addPlugin
(
plugins
,
uniPageVuePlugin
({
command
}),
'
vite:vue
'
)
addPlugin
(
plugins
,
uniPageVuePlugin
({
command
}),
'
vite:vue
'
)
addPlugin
(
plugins
,
uniJsonPlugin
(
options
),
'
vite:json
'
,
'
pre
'
)
addPlugin
(
plugins
,
uniJsonPlugin
(
options
),
'
vite:json
'
,
'
pre
'
)
addPlugin
(
plugins
,
uniStaticPlugin
(
options
,
config
),
'
vite:asset
'
,
'
pre
'
)
if
(
command
===
'
build
'
)
{
if
(
command
===
'
build
'
)
{
addPlugin
(
plugins
,
uniCopyPlugin
(
options
),
plugins
.
length
)
addPlugin
(
plugins
,
uniCopyPlugin
(
options
),
plugins
.
length
)
}
}
...
...
packages/vite-plugin-uni/src/configResolved/plugins/pagesJson.ts
浏览文件 @
5e7465a9
...
@@ -152,6 +152,10 @@ function normalizePagesRoute(pagesJson: UniApp.PagesJson): PageRouteOptions[] {
...
@@ -152,6 +152,10 @@ function normalizePagesRoute(pagesJson: UniApp.PagesJson): PageRouteOptions[] {
pageOptions
.
style
pageOptions
.
style
)
)
if
(
isEntry
)
{
;(
meta
as
any
).
route
=
pageOptions
.
path
}
return
{
return
{
name
,
name
,
path
:
pageOptions
.
path
,
path
:
pageOptions
.
path
,
...
...
packages/vite-plugin-uni/src/configResolved/plugins/static.ts
0 → 100644
浏览文件 @
5e7465a9
import
debug
from
'
debug
'
import
{
Plugin
,
ResolvedConfig
}
from
'
vite
'
import
{
cleanUrl
}
from
'
@dcloudio/uni-cli-shared
'
import
{
UniPluginFilterOptions
}
from
'
.
'
import
{
createPublicFileFilter
}
from
'
../../utils
'
const
debugStatic
=
debug
(
'
uni:static
'
)
/**
* 提供static等目录静态资源加载
* @param _options
* @param config
* @returns
*/
export
function
uniStaticPlugin
(
_options
:
UniPluginFilterOptions
,
config
:
ResolvedConfig
):
Plugin
{
const
filter
=
createPublicFileFilter
()
return
{
name
:
'
vite:uni-static
'
,
resolveId
(
id
)
{
if
(
!
config
.
assetsInclude
(
cleanUrl
(
id
)))
{
return
}
const
publicFile
=
filter
(
id
)
if
(
publicFile
)
{
debugStatic
(
id
)
return
id
}
},
async
load
(
id
)
{
if
(
!
config
.
assetsInclude
(
cleanUrl
(
id
)))
{
return
}
if
(
filter
(
id
))
{
return
`export default
${
JSON
.
stringify
(
fileToUrl
(
id
,
config
))}
`
}
},
}
}
function
fileToUrl
(
id
:
string
,
config
:
ResolvedConfig
)
{
return
config
.
base
+
id
.
slice
(
1
)
}
packages/vite-plugin-uni/src/configureServer/index.ts
浏览文件 @
5e7465a9
import
{
Plugin
}
from
'
vite
'
import
{
Plugin
}
from
'
vite
'
import
{
VitePluginUniResolvedOptions
}
from
'
..
'
import
{
VitePluginUniResolvedOptions
}
from
'
..
'
import
{
serveEasycom
}
from
'
./easycom
'
import
{
serveEasycom
}
from
'
./easycom
'
import
{
serveStatic
}
from
'
./static
'
export
function
createConfigureServer
(
export
function
createConfigureServer
(
options
:
VitePluginUniResolvedOptions
options
:
VitePluginUniResolvedOptions
...
@@ -8,5 +9,8 @@ export function createConfigureServer(
...
@@ -8,5 +9,8 @@ export function createConfigureServer(
return
function
(
server
)
{
return
function
(
server
)
{
options
.
devServer
=
server
options
.
devServer
=
server
serveEasycom
(
server
,
options
)
serveEasycom
(
server
,
options
)
return
()
=>
{
serveStatic
(
server
,
options
)
}
}
}
}
}
packages/vite-plugin-uni/src/configureServer/middlewares/static.ts
0 → 100644
浏览文件 @
5e7465a9
import
fs
,
{
Stats
}
from
'
fs
'
import
url
from
'
url
'
import
mime
from
'
mime/lite
'
import
{
IncomingMessage
,
OutgoingHttpHeaders
,
ServerResponse
}
from
'
http
'
function
normalizeFile
(
filename
:
string
,
isEtag
:
boolean
)
{
const
stats
=
fs
.
statSync
(
filename
)
return
{
stats
,
headers
:
normalizeHeaders
(
filename
,
stats
,
isEtag
),
}
}
function
normalizeHeaders
(
filename
:
string
,
stats
:
Stats
,
isEtag
:
boolean
)
{
const
headers
:
OutgoingHttpHeaders
=
{
'
Content-Length
'
:
stats
.
size
,
'
Content-Type
'
:
mime
.
getType
(
filename
)
||
''
,
'
Last-Modified
'
:
stats
.
mtime
.
toUTCString
(),
}
if
(
isEtag
)
{
headers
[
'
ETag
'
]
=
`W/"
${
stats
.
size
}
-
${
stats
.
mtime
.
getTime
()}
"`
}
return
headers
}
function
send
(
req
:
IncomingMessage
,
res
:
ServerResponse
,
filename
:
string
,
stats
:
Stats
,
headers
:
OutgoingHttpHeaders
)
{
let
code
=
200
headers
=
{
...
headers
}
const
opts
:
{
end
?:
number
start
?:
number
}
=
{}
for
(
const
key
in
headers
)
{
const
value
=
res
.
getHeader
(
key
)
if
(
value
)
{
headers
[
key
]
=
value
}
}
if
(
res
.
getHeader
(
'
content-type
'
))
{
headers
[
'
Content-Type
'
]
=
res
.
getHeader
(
'
content-type
'
)
}
if
(
req
.
headers
.
range
)
{
code
=
206
const
[
x
,
y
]
=
req
.
headers
.
range
.
replace
(
'
bytes=
'
,
''
).
split
(
'
-
'
)
const
end
=
(
opts
.
end
=
parseInt
(
y
,
10
)
||
stats
.
size
-
1
)
const
start
=
(
opts
.
start
=
parseInt
(
x
,
10
)
||
0
)
if
(
start
>=
stats
.
size
||
end
>=
stats
.
size
)
{
res
.
setHeader
(
'
Content-Range
'
,
`bytes */
${
stats
.
size
}
`
)
res
.
statusCode
=
416
return
res
.
end
()
}
headers
[
'
Content-Range
'
]
=
`bytes
${
start
}
-
${
end
}
/
${
stats
.
size
}
`
headers
[
'
Content-Length
'
]
=
end
-
start
+
1
headers
[
'
Accept-Ranges
'
]
=
'
bytes
'
}
res
.
writeHead
(
code
,
headers
)
fs
.
createReadStream
(
filename
,
opts
).
pipe
(
res
)
}
interface
UniStaticMiddlewareOptions
{
etag
:
boolean
resolve
:
(
pathname
:
string
)
=>
string
|
void
}
type
NextHandler
=
()
=>
void
|
Promise
<
void
>
export
function
uniStaticMiddleware
(
opts
:
UniStaticMiddlewareOptions
)
{
const
isEtag
=
!!
opts
.
etag
return
function
(
req
:
IncomingMessage
,
res
:
ServerResponse
,
next
:
NextHandler
)
{
const
pathname
=
url
.
parse
(
req
.
url
!
).
pathname
if
(
!
pathname
)
{
return
next
()
}
const
filename
=
opts
.
resolve
(
pathname
)
if
(
!
filename
)
{
return
next
()
}
const
data
=
normalizeFile
(
filename
,
isEtag
)
if
(
!
data
)
{
return
next
()
}
if
(
isEtag
&&
req
.
headers
[
'
if-none-match
'
]
===
data
.
headers
[
'
ETag
'
])
{
res
.
writeHead
(
304
)
return
res
.
end
()
}
return
send
(
req
,
res
,
filename
,
data
.
stats
,
data
.
headers
)
}
}
packages/vite-plugin-uni/src/configureServer/static.ts
0 → 100644
浏览文件 @
5e7465a9
import
fs
from
'
fs
'
import
path
from
'
path
'
import
debug
from
'
debug
'
import
{
ViteDevServer
}
from
'
vite
'
import
{
isImportRequest
}
from
'
@dcloudio/uni-cli-shared
'
import
{
VitePluginUniResolvedOptions
}
from
'
..
'
import
{
uniStaticMiddleware
}
from
'
./middlewares/static
'
import
{
createPublicFileFilter
}
from
'
../utils
'
const
debugStatic
=
debug
(
'
uni:static
'
)
/**
* devServer时提供static等目录的静态资源服务
* @param server
* @param param
*/
export
const
serveStatic
=
(
server
:
ViteDevServer
,
{
inputDir
}:
VitePluginUniResolvedOptions
)
=>
{
const
filter
=
createPublicFileFilter
()
const
serve
=
uniStaticMiddleware
({
etag
:
true
,
resolve
(
pathname
)
{
if
(
!
filter
(
pathname
))
{
return
}
const
filename
=
path
.
join
(
inputDir
,
pathname
)
if
(
fs
.
existsSync
(
filename
))
{
debugStatic
(
filename
,
'
success
'
)
return
filename
}
else
{
debugStatic
(
filename
,
'
fail
'
)
}
},
})
server
.
middlewares
.
use
((
req
,
res
,
next
)
=>
{
// skip import request
if
(
isImportRequest
(
req
.
url
!
))
{
return
next
()
}
return
serve
(
req
,
res
,
next
)
})
}
packages/vite-plugin-uni/src/utils/filter.ts
0 → 100644
浏览文件 @
5e7465a9
import
path
from
'
path
'
import
{
createFilter
}
from
'
@rollup/pluginutils
'
import
{
PUBLIC_DIR
}
from
'
@dcloudio/uni-cli-shared
'
export
function
createPublicFileFilter
(
base
:
string
=
'
/
'
)
{
const
publicDir
=
path
.
join
(
base
,
PUBLIC_DIR
+
'
/**/*
'
)
const
uniModulesDir
=
path
.
join
(
base
,
'
uni_modules/*/
'
+
PUBLIC_DIR
+
'
/**/*
'
)
return
createFilter
([
publicDir
,
uniModulesDir
])
}
packages/vite-plugin-uni/src/utils/index.ts
浏览文件 @
5e7465a9
export
*
from
'
./filter
'
export
*
from
'
./define
'
export
*
from
'
./define
'
export
*
from
'
./pagesJson
'
export
*
from
'
./pagesJson
'
packages/vite-plugin-uni/src/vue/compilerOptions.ts
浏览文件 @
5e7465a9
import
{
ElementNode
,
NodeTransform
}
from
'
@vue/compiler-core
'
import
{
ElementNode
,
NodeTransform
}
from
'
@vue/compiler-core
'
import
{
CompilerOptions
}
from
'
@vue/compiler-sfc
'
import
{
CompilerOptions
,
SFCTemplateCompileOptions
}
from
'
@vue/compiler-sfc
'
import
{
isNativeTag
}
from
'
@dcloudio/uni-shared
'
import
{
isNativeTag
}
from
'
@dcloudio/uni-shared
'
const
transform
:
NodeTransform
=
(
node
)
=>
{
const
transform
:
NodeTransform
=
(
node
,
ctx
)
=>
{
if
(
if
(
process
.
env
.
UNI_PLATFORM
!==
'
mp-weixin
'
&&
process
.
env
.
UNI_PLATFORM
!==
'
mp-weixin
'
&&
(
node
as
ElementNode
).
tag
===
'
match-media
'
(
node
as
ElementNode
).
tag
===
'
match-media
'
...
@@ -17,3 +17,26 @@ export const uniVueCompilerOptions: CompilerOptions = {
...
@@ -17,3 +17,26 @@ export const uniVueCompilerOptions: CompilerOptions = {
isNativeTag
,
isNativeTag
,
nodeTransforms
:
[
transform
],
nodeTransforms
:
[
transform
],
}
}
export
const
uniVueTransformAssetUrls
:
SFCTemplateCompileOptions
[
'
transformAssetUrls
'
]
=
{
tags
:
{
audio
:
[
'
src
'
],
video
:
[
'
src
'
,
'
poster
'
],
img
:
[
'
src
'
],
image
:
[
'
src
'
],
'
cover-image
'
:
[
'
src
'
],
// h5
'
v-uni-audio
'
:
[
'
src
'
],
'
v-uni-video
'
:
[
'
src
'
,
'
poster
'
],
'
v-uni-image
'
:
[
'
src
'
],
'
v-uni-cover-image
'
:
[
'
src
'
],
// nvue
'
u-image
'
:
[
'
src
'
],
'
u-video
'
:
[
'
src
'
,
'
poster
'
],
},
}
export
const
uniVueTemplateOptions
:
Partial
<
SFCTemplateCompileOptions
>
=
{
compilerOptions
:
uniVueCompilerOptions
,
transformAssetUrls
:
uniVueTransformAssetUrls
,
}
tsconfig.json
浏览文件 @
5e7465a9
...
@@ -27,7 +27,10 @@
...
@@ -27,7 +27,10 @@
"rootDir"
:
"."
,
"rootDir"
:
"."
,
"paths"
:
{
"paths"
:
{
"@dcloudio/*"
:
[
"packages/*/src"
],
"@dcloudio/*"
:
[
"packages/*/src"
],
"@dcloudio/uni-mp-polyfill"
:
[
"packages/uni-mp-core/src/runtime/polyfill"
]
"@dcloudio/uni-mp-polyfill"
:
[
"packages/uni-mp-core/src/runtime/polyfill"
],
"@dcloudio/uni-platform"
:
[
"packages/uni-h5/src/platform/index.ts"
]
}
}
},
},
"include"
:
[
"include"
:
[
...
...
yarn.lock
浏览文件 @
5e7465a9
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录