Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
genary
uni-app
提交
72ad6aef
U
uni-app
项目概览
genary
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
72ad6aef
编写于
10月 18, 2021
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(mp): css
上级
0eb7ff2b
变更
34
隐藏空白更改
内联
并排
Showing
34 changed file
with
207 addition
and
196 deletion
+207
-196
packages/uni-api/src/helpers/api/promise.ts
packages/uni-api/src/helpers/api/promise.ts
+7
-7
packages/uni-app-plus/dist/uni-app-service.es.js
packages/uni-app-plus/dist/uni-app-service.es.js
+7
-0
packages/uni-cli-shared/src/json/manifest.ts
packages/uni-cli-shared/src/json/manifest.ts
+18
-5
packages/uni-cli-shared/src/postcss/plugins/uniapp.ts
packages/uni-cli-shared/src/postcss/plugins/uniapp.ts
+1
-1
packages/uni-h5-vite/src/plugins/ssr.ts
packages/uni-h5-vite/src/plugins/ssr.ts
+4
-1
packages/uni-h5-vite/src/utils/ssr.ts
packages/uni-h5-vite/src/utils/ssr.ts
+1
-1
packages/uni-h5/dist/uni-h5.cjs.js
packages/uni-h5/dist/uni-h5.cjs.js
+0
-5
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+0
-5
packages/uni-mp-alipay/dist/uni.api.esm.js
packages/uni-mp-alipay/dist/uni.api.esm.js
+7
-7
packages/uni-mp-baidu/dist/uni.api.esm.js
packages/uni-mp-baidu/dist/uni.api.esm.js
+7
-7
packages/uni-mp-compiler/__tests__/class.spec.ts
packages/uni-mp-compiler/__tests__/class.spec.ts
+9
-2
packages/uni-mp-compiler/__tests__/style.spec.ts
packages/uni-mp-compiler/__tests__/style.spec.ts
+14
-0
packages/uni-mp-compiler/__tests__/test.spec.ts
packages/uni-mp-compiler/__tests__/test.spec.ts
+3
-3
packages/uni-mp-compiler/src/transforms/transformClass.ts
packages/uni-mp-compiler/src/transforms/transformClass.ts
+2
-1
packages/uni-mp-compiler/src/transforms/transformStyle.ts
packages/uni-mp-compiler/src/transforms/transformStyle.ts
+3
-1
packages/uni-mp-compiler/src/transforms/vIf.ts
packages/uni-mp-compiler/src/transforms/vIf.ts
+2
-1
packages/uni-mp-kuaishou/dist/uni.api.esm.js
packages/uni-mp-kuaishou/dist/uni.api.esm.js
+7
-7
packages/uni-mp-qq/dist/uni.api.esm.js
packages/uni-mp-qq/dist/uni.api.esm.js
+7
-7
packages/uni-mp-toutiao/dist/uni.api.esm.js
packages/uni-mp-toutiao/dist/uni.api.esm.js
+7
-7
packages/uni-mp-vite/src/index.ts
packages/uni-mp-vite/src/index.ts
+6
-0
packages/uni-mp-vite/src/plugin/index.ts
packages/uni-mp-vite/src/plugin/index.ts
+3
-0
packages/uni-mp-vite/src/plugins/renderjs.ts
packages/uni-mp-vite/src/plugins/renderjs.ts
+33
-0
packages/uni-mp-vue/dist/vue.runtime.esm.js
packages/uni-mp-vue/dist/vue.runtime.esm.js
+0
-1
packages/uni-mp-vue/lib/vue.runtime.esm.js
packages/uni-mp-vue/lib/vue.runtime.esm.js
+0
-1
packages/uni-mp-weixin/dist/uni.api.esm.js
packages/uni-mp-weixin/dist/uni.api.esm.js
+7
-7
packages/uni-mp-weixin/dist/uni.compiler.js
packages/uni-mp-weixin/dist/uni.compiler.js
+6
-0
packages/uni-mp-weixin/src/plugin/index.ts
packages/uni-mp-weixin/src/plugin/index.ts
+6
-0
packages/uni-quickapp-webview/dist/uni.api.esm.js
packages/uni-quickapp-webview/dist/uni.api.esm.js
+7
-7
packages/uni-shared/dist/uni-shared.cjs.js
packages/uni-shared/dist/uni-shared.cjs.js
+9
-0
packages/uni-shared/dist/uni-shared.d.ts
packages/uni-shared/dist/uni-shared.d.ts
+6
-0
packages/uni-shared/dist/uni-shared.es.js
packages/uni-shared/dist/uni-shared.es.js
+9
-1
packages/uni-shared/src/dom/style.ts
packages/uni-shared/src/dom/style.ts
+9
-0
packages/vite-plugin-uni/src/utils/index.ts
packages/vite-plugin-uni/src/utils/index.ts
+0
-1
packages/vite-plugin-uni/src/utils/postcss.ts
packages/vite-plugin-uni/src/utils/postcss.ts
+0
-110
未找到文件。
packages/uni-api/src/helpers/api/promise.ts
浏览文件 @
72ad6aef
...
...
@@ -16,13 +16,13 @@ function hasCallback(args: unknown) {
}
export
function
handlePromise
(
promise
:
Promise
<
unknown
>
)
{
if
(
__UNI_FEATURE_PROMISE__
)
{
return
promise
.
then
((
data
)
=>
{
return
[
null
,
data
]
})
.
catch
((
err
)
=>
[
err
])
}
//
if (__UNI_FEATURE_PROMISE__) {
//
return promise
//
.then((data) => {
//
return [null, data]
//
})
//
.catch((err) => [err])
//
}
return
promise
}
...
...
packages/uni-app-plus/dist/uni-app-service.es.js
浏览文件 @
72ad6aef
...
...
@@ -1064,6 +1064,13 @@ var serviceContext = (function (vue) {
return false;
}
function handlePromise(promise) {
// if (false) {
// return promise
// .then((data) => {
// return [null, data]
// })
// .catch((err) => [err])
// }
return promise;
}
function promisify(name, fn) {
...
...
packages/uni-cli-shared/src/json/manifest.ts
浏览文件 @
72ad6aef
import
fs
from
'
fs
'
import
path
from
'
path
'
import
{
extend
}
from
'
@vue/shared
'
import
{
once
,
defaultRpx2Unit
}
from
'
@dcloudio/uni-shared
'
import
{
once
,
defaultRpx2Unit
,
defaultMiniProgramRpx2Unit
,
}
from
'
@dcloudio/uni-shared
'
import
{
parseJson
}
from
'
./json
'
...
...
@@ -13,10 +17,19 @@ export const parseManifestJson = (inputDir: string) => {
export
const
parseManifestJsonOnce
=
once
(
parseManifestJson
)
export
const
parseRpx2UnitOnce
=
once
((
inputDir
:
string
)
=>
{
const
{
h5
}
=
parseManifestJsonOnce
(
inputDir
)
return
extend
({},
defaultRpx2Unit
,
(
h5
&&
h5
.
rpx
)
||
{})
})
export
const
parseRpx2UnitOnce
=
once
(
(
inputDir
:
string
,
platform
:
UniApp
.
PLATFORM
)
=>
{
const
rpx2unit
=
platform
===
'
h5
'
||
platform
===
'
app
'
?
defaultRpx2Unit
:
defaultMiniProgramRpx2Unit
const
platformOptions
=
parseManifestJsonOnce
(
inputDir
)[
platform
]
if
(
platformOptions
&&
platformOptions
.
rpx
)
{
return
extend
({},
rpx2unit
,
platformOptions
)
}
return
extend
({},
rpx2unit
)
}
)
interface
CompilerCompatConfig
{
MODE
?:
2
|
3
...
...
packages/uni-cli-shared/src/postcss/plugins/uniapp.ts
浏览文件 @
72ad6aef
...
...
@@ -101,7 +101,7 @@ const uniapp = (opts?: UniAppCssProcessorOptions) => {
return
{
OnceExit
(
root
)
{
root
.
walkDecls
(
walkDecls
(
rpx2unit
))
root
.
walkRules
(
walkRules
(
page
))
page
&&
root
.
walkRules
(
walkRules
(
page
))
},
}
},
...
...
packages/uni-h5-vite/src/plugins/ssr.ts
浏览文件 @
72ad6aef
...
...
@@ -55,7 +55,10 @@ export function uniSSRPlugin(): Plugin {
chunk
.
code
=
generateSsrDefineCode
(
resolvedConfig
,
parseRpx2UnitOnce
(
process
.
env
.
UNI_INPUT_DIR
)
parseRpx2UnitOnce
(
process
.
env
.
UNI_INPUT_DIR
,
process
.
env
.
UNI_PLATFORM
)
)
+
'
\n
'
+
chunk
.
code
...
...
packages/uni-h5-vite/src/utils/ssr.ts
浏览文件 @
72ad6aef
...
...
@@ -132,7 +132,7 @@ export function rewriteSsrNativeTag() {
}
export
function
rewriteSsrRenderStyle
(
inputDir
:
string
)
{
const
{
unit
,
unitRatio
,
unitPrecision
}
=
parseRpx2UnitOnce
(
inputDir
)
const
{
unit
,
unitRatio
,
unitPrecision
}
=
parseRpx2UnitOnce
(
inputDir
,
'
h5
'
)
const
rpx2unit
=
createRpx2Unit
(
unit
,
unitRatio
,
unitPrecision
)
const
shared
=
require
(
'
@vue/shared
'
)
const
oldStringifyStyle
=
shared
.
stringifyStyle
...
...
packages/uni-h5/dist/uni-h5.cjs.js
浏览文件 @
72ad6aef
...
...
@@ -1243,11 +1243,6 @@ function hasCallback(args) {
return
false
;
}
function
handlePromise
(
promise
)
{
if
(
__UNI_FEATURE_PROMISE__
)
{
return
promise
.
then
((
data
)
=>
{
return
[
null
,
data
];
}).
catch
((
err
)
=>
[
err
]);
}
return
promise
;
}
function
promisify
(
name
,
fn
)
{
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
72ad6aef
...
...
@@ -2522,11 +2522,6 @@ function hasCallback(args) {
return false;
}
function handlePromise(promise) {
if (__UNI_FEATURE_PROMISE__) {
return promise.then((data) => {
return [null, data];
}).catch((err) => [err]);
}
return promise;
}
function promisify(name, fn) {
...
...
packages/uni-mp-alipay/dist/uni.api.esm.js
浏览文件 @
72ad6aef
...
...
@@ -289,13 +289,13 @@ function invokeApi(method, api, options, ...params) {
}
function
handlePromise
(
promise
)
{
if
(
__UNI_FEATURE_PROMISE__
)
{
return
promise
.
then
((
data
)
=>
{
return
[
null
,
data
];
})
.
catch
((
err
)
=>
[
err
]);
}
//
if (__UNI_FEATURE_PROMISE__) {
//
return promise
//
.then((data) => {
// return [null, data]
//
})
// .catch((err) => [err])
//
}
return
promise
;
}
...
...
packages/uni-mp-baidu/dist/uni.api.esm.js
浏览文件 @
72ad6aef
...
...
@@ -289,13 +289,13 @@ function invokeApi(method, api, options, ...params) {
}
function
handlePromise
(
promise
)
{
if
(
__UNI_FEATURE_PROMISE__
)
{
return
promise
.
then
((
data
)
=>
{
return
[
null
,
data
];
})
.
catch
((
err
)
=>
[
err
]);
}
//
if (__UNI_FEATURE_PROMISE__) {
//
return promise
//
.then((data) => {
// return [null, data]
//
})
// .catch((err) => [err])
//
}
return
promise
;
}
...
...
packages/uni-mp-compiler/__tests__/class.spec.ts
浏览文件 @
72ad6aef
...
...
@@ -58,10 +58,10 @@ describe('compiler: transform class', () => {
})
test
(
'
v-bind:class object syntax
'
,
()
=>
{
assert
(
`<view :class="{ red:
isRed
}"/>`
,
`<view :class="{ red:
\`\$
{isRed}
\`
}"/>`
,
`<view class="{{[a && 'red']}}"/>`
,
`(_ctx, _cache) => {
return { a:
_ctx.isRed
}
return { a:
\`\$
{_ctx.isRed}
\`
}
}`
)
assert
(
...
...
@@ -103,6 +103,13 @@ describe('compiler: transform class', () => {
)
})
test
(
'
v-bind:class array syntax
'
,
()
=>
{
assert
(
`<view :class="[classA,
\`\$
{classB}
\`
]"/>`
,
`<view class="{{[a, b]}}"/>`
,
`(_ctx, _cache) => {
return { a: _normalizeClass(_ctx.classA), b: _normalizeClass(
\`\$
{_ctx.classB}
\`
) }
}`
)
assert
(
`<view :class="[classA, classB]"/>`
,
`<view class="{{[a, b]}}"/>`
,
...
...
packages/uni-mp-compiler/__tests__/style.spec.ts
浏览文件 @
72ad6aef
...
...
@@ -50,6 +50,13 @@ describe('compiler: transform style', () => {
)
})
test
(
'
v-bind:style object syntax
'
,
()
=>
{
assert
(
`<view :style="{ color:
\`\$
{green}px
\`
}"/>`
,
`<view style="{{'color:' + a}}"/>`
,
`(_ctx, _cache) => {
return { a:
\`\$
{_ctx.green}px
\`
}
}`
)
assert
(
`<view :style="{ color: 'green' }"/>`
,
`<view style="{{'color:' + 'green'}}"/>`
,
...
...
@@ -98,6 +105,13 @@ describe('compiler: transform style', () => {
)
})
test
(
'
v-bind:style array syntax
'
,
()
=>
{
assert
(
`<view :style="[styleA,
\`\$
{styleB}
\`
]"/>`
,
`<view style="{{a + ';' + b}}"/>`
,
`(_ctx, _cache) => {
return { a: _normalizeStyle(_ctx.styleA), b: _normalizeStyle(
\`\$
{_ctx.styleB}
\`
) }
}`
)
assert
(
`<view :style="[styleA, styleB]"/>`
,
`<view style="{{a + ';' + b}}"/>`
,
...
...
packages/uni-mp-compiler/__tests__/test.spec.ts
浏览文件 @
72ad6aef
...
...
@@ -34,10 +34,10 @@ function assert(
describe
(
'
compiler
'
,
()
=>
{
test
(
'
scope
'
,
()
=>
{
assert
(
`<view
v-for="(item,weekIndex) in weeks" :key="weekIndex" :data-id="item.id"><view v-for="(weeks,weeksIndex) in item" :key="weeksIndex" :data-id="weeks.id"/></view
>`
,
`<view
wx:for="{{a}}" wx:for-item="item" wx:key="b" data-id="{{item.c}}"><view wx:for="{{item.a}}" wx:for-item="weeks" wx:key="a" data-id="{{weeks.b}}"/></view
>`
,
`<view
:style="{ color:
\`\$
{green}px
\`
}"/
>`
,
`<view
style="{{'color:' + a}}"/
>`
,
`(_ctx, _cache) => {
return { a:
_vFor(_ctx.weeks, (item, weekIndex) => { return { a: _vFor(item, (weeks, weeksIndex) => { return { a: weeksIndex, b: weeks.id }; }), b: weekIndex, c: item.id }; })
}
return { a:
\`\$
{_ctx.green}px
\`
}
}`
)
})
...
...
packages/uni-mp-compiler/src/transforms/transformClass.ts
浏览文件 @
72ad6aef
...
...
@@ -18,6 +18,7 @@ import {
LogicalExpression
,
logicalExpression
,
StringLiteral
,
isTemplateLiteral
,
}
from
'
@babel/types
'
import
{
DirectiveNode
,
...
...
@@ -156,7 +157,7 @@ function rewriteClassObjectExpression(
key
as
Expression
)
as
Identifier
}
if
(
isLiteral
(
value
))
{
if
(
isLiteral
(
value
)
&&
!
isTemplateLiteral
(
value
)
)
{
return
}
else
{
const
newExpr
=
parseExprWithRewrite
(
...
...
packages/uni-mp-compiler/src/transforms/transformStyle.ts
浏览文件 @
72ad6aef
...
...
@@ -13,6 +13,7 @@ import {
isObjectProperty
,
binaryExpression
,
isIdentifier
,
isTemplateLiteral
,
}
from
'
@babel/types
'
import
{
DirectiveNode
,
...
...
@@ -159,7 +160,8 @@ function rewriteStyleObjectExpression(
prop
.
key
=
parseStringLiteral
(
prop
.
key
)
prop
.
key
.
value
=
hyphenate
(
prop
.
key
.
value
)
+
'
:
'
}
if
(
isLiteral
(
value
))
{
// {fontSize:`${fontSize}px`} => {'font-size':a}
if
(
isLiteral
(
value
)
&&
!
isTemplateLiteral
(
value
))
{
return
}
else
{
const
newExpr
=
parseExprWithRewrite
(
...
...
packages/uni-mp-compiler/src/transforms/vIf.ts
浏览文件 @
72ad6aef
...
...
@@ -2,6 +2,7 @@ import {
ConditionalExpression
,
isConditionalExpression
,
isLiteral
,
isTemplateLiteral
,
isSpreadElement
,
ObjectExpression
,
}
from
'
@babel/types
'
...
...
@@ -55,7 +56,7 @@ export const transformIf = createStructuralDirectiveTransform(
condition
,
})
if
(
condition
)
{
if
(
!
isLiteral
(
condition
))
{
if
(
!
isLiteral
(
condition
)
||
isTemplateLiteral
(
condition
)
)
{
ifOptions
.
condition
=
rewriteExpression
(
dir
.
exp
!
,
context
,
...
...
packages/uni-mp-kuaishou/dist/uni.api.esm.js
浏览文件 @
72ad6aef
...
...
@@ -289,13 +289,13 @@ function invokeApi(method, api, options, ...params) {
}
function
handlePromise
(
promise
)
{
if
(
__UNI_FEATURE_PROMISE__
)
{
return
promise
.
then
((
data
)
=>
{
return
[
null
,
data
];
})
.
catch
((
err
)
=>
[
err
]);
}
//
if (__UNI_FEATURE_PROMISE__) {
//
return promise
//
.then((data) => {
// return [null, data]
//
})
// .catch((err) => [err])
//
}
return
promise
;
}
...
...
packages/uni-mp-qq/dist/uni.api.esm.js
浏览文件 @
72ad6aef
...
...
@@ -289,13 +289,13 @@ function invokeApi(method, api, options, ...params) {
}
function
handlePromise
(
promise
)
{
if
(
__UNI_FEATURE_PROMISE__
)
{
return
promise
.
then
((
data
)
=>
{
return
[
null
,
data
];
})
.
catch
((
err
)
=>
[
err
]);
}
//
if (__UNI_FEATURE_PROMISE__) {
//
return promise
//
.then((data) => {
// return [null, data]
//
})
// .catch((err) => [err])
//
}
return
promise
;
}
...
...
packages/uni-mp-toutiao/dist/uni.api.esm.js
浏览文件 @
72ad6aef
...
...
@@ -289,13 +289,13 @@ function invokeApi(method, api, options, ...params) {
}
function
handlePromise
(
promise
)
{
if
(
__UNI_FEATURE_PROMISE__
)
{
return
promise
.
then
((
data
)
=>
{
return
[
null
,
data
];
})
.
catch
((
err
)
=>
[
err
]);
}
//
if (__UNI_FEATURE_PROMISE__) {
//
return promise
//
.then((data) => {
// return [null, data]
//
})
// .catch((err) => [err])
//
}
return
promise
;
}
...
...
packages/uni-mp-vite/src/index.ts
浏览文件 @
72ad6aef
import
{
extend
}
from
'
@vue/shared
'
import
{
initProvide
,
uniViteInjectPlugin
}
from
'
@dcloudio/uni-cli-shared
'
import
{
uniMiniProgramPlugin
,
UniMiniProgramPluginOptions
}
from
'
./plugin
'
import
{
uniUsingComponentsPlugin
}
from
'
./plugins/usingComponents
'
import
{
uniMainJsPlugin
}
from
'
./plugins/mainJs
'
...
...
@@ -5,6 +7,8 @@ import { uniManifestJsonPlugin } from './plugins/manifestJson'
import
{
uniPagesJsonPlugin
}
from
'
./plugins/pagesJson
'
import
{
uniEntryPlugin
}
from
'
./plugins/entry
'
import
{
SFCScriptCompileOptions
}
from
'
@vue/compiler-sfc
'
import
{
uniRenderjsPlugin
}
from
'
./plugins/renderjs
'
export
{
UniMiniProgramPluginOptions
}
from
'
./plugin
'
export
default
(
options
:
UniMiniProgramPluginOptions
)
=>
{
return
[
...
...
@@ -12,6 +16,8 @@ export default (options: UniMiniProgramPluginOptions) => {
uniManifestJsonPlugin
(
options
),
uniPagesJsonPlugin
(
options
),
uniEntryPlugin
(
options
),
uniViteInjectPlugin
(
extend
({},
options
.
vite
.
inject
,
initProvide
())),
uniRenderjsPlugin
(),
uniMiniProgramPlugin
(
options
),
(
options
:
{
vueOptions
?:
{
script
?:
Partial
<
SFCScriptCompileOptions
>
}
...
...
packages/uni-mp-vite/src/plugin/index.ts
浏览文件 @
72ad6aef
...
...
@@ -20,6 +20,9 @@ export interface UniMiniProgramPluginOptions {
vite
:
{
alias
:
AliasOptions
copyOptions
:
CopyOptions
inject
:
{
[
name
:
string
]:
[
string
,
string
]
}
}
global
:
string
app
:
{
...
...
packages/uni-mp-vite/src/plugins/renderjs.ts
0 → 100644
浏览文件 @
72ad6aef
import
debug
from
'
debug
'
import
{
Plugin
}
from
'
vite
'
import
{
missingModuleName
,
parseRenderjs
}
from
'
@dcloudio/uni-cli-shared
'
const
debugRenderjs
=
debug
(
'
vite:uni:renderjs
'
)
export
function
uniRenderjsPlugin
():
Plugin
{
return
{
name
:
'
vite:uni-mp-renderjs
'
,
transform
(
code
,
id
)
{
const
{
type
,
name
}
=
parseRenderjs
(
id
)
if
(
!
type
)
{
return
}
debugRenderjs
(
id
)
if
(
!
name
)
{
this
.
error
(
missingModuleName
(
type
,
code
))
}
if
(
type
===
'
wxs
'
)
{
console
.
log
(
'
wxs
'
,
id
,
code
)
// this.emitFile({
// type: 'asset',
// fileName: '',
// source: code,
// })
}
return
{
code
:
'
export default {}
'
,
}
},
}
}
packages/uni-mp-vue/dist/vue.runtime.esm.js
浏览文件 @
72ad6aef
...
...
@@ -4684,7 +4684,6 @@ function setupRenderEffect(instance) {
patch
(
instance
,
renderComponentRoot
(
instance
));
}
else
{
instance
.
render
&&
instance
.
render
.
call
(
instance
.
proxy
);
// updateComponent
const
{
bu
,
u
}
=
instance
;
effect
.
allowRecurse
=
false
;
...
...
packages/uni-mp-vue/lib/vue.runtime.esm.js
浏览文件 @
72ad6aef
...
...
@@ -4616,7 +4616,6 @@ function setupRenderEffect(instance) {
patch
(
instance
,
renderComponentRoot
(
instance
));
}
else
{
instance
.
render
&&
instance
.
render
.
call
(
instance
.
proxy
);
// updateComponent
const
{
bu
,
u
}
=
instance
;
effect
.
allowRecurse
=
false
;
...
...
packages/uni-mp-weixin/dist/uni.api.esm.js
浏览文件 @
72ad6aef
...
...
@@ -253,13 +253,13 @@ function invokeApi(method, api, options, ...params) {
}
function
handlePromise
(
promise
)
{
if
(
__UNI_FEATURE_PROMISE__
)
{
return
promise
.
then
((
data
)
=>
{
return
[
null
,
data
];
})
.
catch
((
err
)
=>
[
err
]);
}
//
if (__UNI_FEATURE_PROMISE__) {
//
return promise
//
.then((data) => {
// return [null, data]
//
})
// .catch((err) => [err])
//
}
return
promise
;
}
...
...
packages/uni-mp-weixin/dist/uni.compiler.js
浏览文件 @
72ad6aef
...
...
@@ -69,6 +69,12 @@ const uniMiniProgramWeixinPlugin = {
const
projectConfigFilename
=
'
project.config.json
'
;
const
options
=
{
vite
:
{
inject
:
{
uni
:
[
uniCliShared
.
resolveBuiltIn
(
'
@dcloudio/uni-mp-weixin/dist/uni.api.esm.js
'
),
'
default
'
,
],
},
alias
:
{
'
uni-mp-runtime
'
:
uniCliShared
.
resolveBuiltIn
(
'
@dcloudio/uni-mp-weixin/dist/uni.mp.esm.js
'
),
},
...
...
packages/uni-mp-weixin/src/plugin/index.ts
浏览文件 @
72ad6aef
...
...
@@ -21,6 +21,12 @@ const projectConfigFilename = 'project.config.json'
const
options
:
UniMiniProgramPluginOptions
=
{
vite
:
{
inject
:
{
uni
:
[
resolveBuiltIn
(
'
@dcloudio/uni-mp-weixin/dist/uni.api.esm.js
'
),
'
default
'
,
],
},
alias
:
{
'
uni-mp-runtime
'
:
resolveBuiltIn
(
'
@dcloudio/uni-mp-weixin/dist/uni.mp.esm.js
'
...
...
packages/uni-quickapp-webview/dist/uni.api.esm.js
浏览文件 @
72ad6aef
...
...
@@ -289,13 +289,13 @@ function invokeApi(method, api, options, ...params) {
}
function
handlePromise
(
promise
)
{
if
(
__UNI_FEATURE_PROMISE__
)
{
return
promise
.
then
((
data
)
=>
{
return
[
null
,
data
];
})
.
catch
((
err
)
=>
[
err
]);
}
//
if (__UNI_FEATURE_PROMISE__) {
//
return promise
//
.then((data) => {
// return [null, data]
//
})
// .catch((err) => [err])
//
}
return
promise
;
}
...
...
packages/uni-shared/dist/uni-shared.cjs.js
浏览文件 @
72ad6aef
...
...
@@ -168,12 +168,20 @@ const defaultRpx2Unit = {
unitRatio
:
10
/
320
,
unitPrecision
:
5
,
};
const
defaultMiniProgramRpx2Unit
=
{
unit
:
'
rpx
'
,
unitRatio
:
1
,
unitPrecision
:
1
,
};
function
createRpx2Unit
(
unit
,
unitRatio
,
unitPrecision
)
{
// ignore: rpxCalcIncludeWidth
return
(
val
)
=>
val
.
replace
(
unitRE
,
(
m
,
$1
)
=>
{
if
(
!
$1
)
{
return
m
;
}
if
(
unitRatio
===
1
)
{
return
`
${
$1
}${
unit
}
`
;
}
const
value
=
toFixed
(
parseFloat
(
$1
)
*
unitRatio
,
unitPrecision
);
return
value
===
0
?
'
0
'
:
`
${
value
}${
unit
}
`
;
});
...
...
@@ -1212,6 +1220,7 @@ exports.createUniEvent = createUniEvent;
exports
.
debounce
=
debounce
;
exports
.
decode
=
decode
;
exports
.
decodedQuery
=
decodedQuery
;
exports
.
defaultMiniProgramRpx2Unit
=
defaultMiniProgramRpx2Unit
;
exports
.
defaultRpx2Unit
=
defaultRpx2Unit
;
exports
.
formatAppLog
=
formatAppLog
;
exports
.
formatDateTime
=
formatDateTime
;
...
...
packages/uni-shared/dist/uni-shared.d.ts
浏览文件 @
72ad6aef
...
...
@@ -132,6 +132,12 @@ export declare function decode(text: string | number): string;
export
declare
function
decodedQuery
(
query
?:
Record
<
string
,
any
>
):
Record
<
string
,
string
>
;
export
declare
const
defaultMiniProgramRpx2Unit
:
{
unit
:
string
;
unitRatio
:
number
;
unitPrecision
:
number
;
};
export
declare
const
defaultRpx2Unit
:
{
unit
:
string
;
unitRatio
:
number
;
...
...
packages/uni-shared/dist/uni-shared.es.js
浏览文件 @
72ad6aef
...
...
@@ -164,12 +164,20 @@ const defaultRpx2Unit = {
unitRatio
:
10
/
320
,
unitPrecision
:
5
,
};
const
defaultMiniProgramRpx2Unit
=
{
unit
:
'
rpx
'
,
unitRatio
:
1
,
unitPrecision
:
1
,
};
function
createRpx2Unit
(
unit
,
unitRatio
,
unitPrecision
)
{
// ignore: rpxCalcIncludeWidth
return
(
val
)
=>
val
.
replace
(
unitRE
,
(
m
,
$1
)
=>
{
if
(
!
$1
)
{
return
m
;
}
if
(
unitRatio
===
1
)
{
return
`
${
$1
}${
unit
}
`
;
}
const
value
=
toFixed
(
parseFloat
(
$1
)
*
unitRatio
,
unitPrecision
);
return
value
===
0
?
'
0
'
:
`
${
value
}${
unit
}
`
;
});
...
...
@@ -1107,4 +1115,4 @@ function getEnvLocale() {
return
(
lang
&&
lang
.
replace
(
/
[
.:
]
.*/
,
''
))
||
'
en
'
;
}
export
{
ACTION_TYPE_ADD_EVENT
,
ACTION_TYPE_ADD_WXS_EVENT
,
ACTION_TYPE_CREATE
,
ACTION_TYPE_EVENT
,
ACTION_TYPE_INSERT
,
ACTION_TYPE_PAGE_CREATE
,
ACTION_TYPE_PAGE_CREATED
,
ACTION_TYPE_PAGE_SCROLL
,
ACTION_TYPE_REMOVE
,
ACTION_TYPE_REMOVE_ATTRIBUTE
,
ACTION_TYPE_REMOVE_EVENT
,
ACTION_TYPE_SET_ATTRIBUTE
,
ACTION_TYPE_SET_TEXT
,
ATTR_CHANGE_PREFIX
,
ATTR_CLASS
,
ATTR_INNER_HTML
,
ATTR_STYLE
,
ATTR_TEXT_CONTENT
,
ATTR_V_OWNER_ID
,
ATTR_V_RENDERJS
,
ATTR_V_SHOW
,
BACKGROUND_COLOR
,
BUILT_IN_TAGS
,
COMPONENT_NAME_PREFIX
,
COMPONENT_PREFIX
,
COMPONENT_SELECTOR_PREFIX
,
DATA_RE
,
EventChannel
,
EventModifierFlags
,
I18N_JSON_DELIMITERS
,
JSON_PROTOCOL
,
LINEFEED
,
NAVBAR_HEIGHT
,
NODE_TYPE_COMMENT
,
NODE_TYPE_ELEMENT
,
NODE_TYPE_PAGE
,
NODE_TYPE_TEXT
,
ON_ADD_TO_FAVORITES
,
ON_APP_ENTER_BACKGROUND
,
ON_APP_ENTER_FOREGROUND
,
ON_BACK_PRESS
,
ON_ERROR
,
ON_HIDE
,
ON_KEYBOARD_HEIGHT_CHANGE
,
ON_LAUNCH
,
ON_LOAD
,
ON_NAVIGATION_BAR_BUTTON_TAP
,
ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED
,
ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED
,
ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED
,
ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED
,
ON_PAGE_NOT_FOUND
,
ON_PAGE_SCROLL
,
ON_PULL_DOWN_REFRESH
,
ON_REACH_BOTTOM
,
ON_REACH_BOTTOM_DISTANCE
,
ON_READY
,
ON_RESIZE
,
ON_SHARE_APP_MESSAGE
,
ON_SHARE_TIMELINE
,
ON_SHOW
,
ON_TAB_ITEM_TAP
,
ON_THEME_CHANGE
,
ON_UNHANDLE_REJECTION
,
ON_UNLOAD
,
ON_WEB_INVOKE_APP_SERVICE
,
ON_WXS_INVOKE_CALL_METHOD
,
PLUS_RE
,
PRIMARY_COLOR
,
RENDERJS_MODULES
,
RESPONSIVE_MIN_WIDTH
,
SCHEME_RE
,
SELECTED_COLOR
,
TABBAR_HEIGHT
,
TAGS
,
UNI_SSR
,
UNI_SSR_DATA
,
UNI_SSR_GLOBAL_DATA
,
UNI_SSR_STORE
,
UNI_SSR_TITLE
,
UniBaseNode
,
UniCommentNode
,
UniElement
,
UniEvent
,
UniInputElement
,
UniLifecycleHooks
,
UniNode
,
UniTextAreaElement
,
UniTextNode
,
WEB_INVOKE_APPSERVICE
,
WXS_MODULES
,
WXS_PROTOCOL
,
addFont
,
cache
,
cacheStringFunction
,
callOptions
,
createRpx2Unit
,
createUniEvent
,
debounce
,
decode
,
decodedQuery
,
defaultRpx2Unit
,
formatAppLog
,
formatDateTime
,
formatLog
,
getCustomDataset
,
getEnvLocale
,
getLen
,
getValueByDataPath
,
initCustomDataset
,
invokeArrayFns
,
isBuiltInComponent
,
isCustomElement
,
isNativeTag
,
isRootHook
,
isServiceCustomElement
,
isServiceNativeTag
,
normalizeDataset
,
normalizeEventType
,
normalizeTarget
,
once
,
parseEventName
,
parseQuery
,
parseUrl
,
passive
,
plusReady
,
removeLeadingSlash
,
resolveOwnerEl
,
resolveOwnerVm
,
sanitise
,
scrollTo
,
stringifyQuery
,
updateElementStyle
};
export
{
ACTION_TYPE_ADD_EVENT
,
ACTION_TYPE_ADD_WXS_EVENT
,
ACTION_TYPE_CREATE
,
ACTION_TYPE_EVENT
,
ACTION_TYPE_INSERT
,
ACTION_TYPE_PAGE_CREATE
,
ACTION_TYPE_PAGE_CREATED
,
ACTION_TYPE_PAGE_SCROLL
,
ACTION_TYPE_REMOVE
,
ACTION_TYPE_REMOVE_ATTRIBUTE
,
ACTION_TYPE_REMOVE_EVENT
,
ACTION_TYPE_SET_ATTRIBUTE
,
ACTION_TYPE_SET_TEXT
,
ATTR_CHANGE_PREFIX
,
ATTR_CLASS
,
ATTR_INNER_HTML
,
ATTR_STYLE
,
ATTR_TEXT_CONTENT
,
ATTR_V_OWNER_ID
,
ATTR_V_RENDERJS
,
ATTR_V_SHOW
,
BACKGROUND_COLOR
,
BUILT_IN_TAGS
,
COMPONENT_NAME_PREFIX
,
COMPONENT_PREFIX
,
COMPONENT_SELECTOR_PREFIX
,
DATA_RE
,
EventChannel
,
EventModifierFlags
,
I18N_JSON_DELIMITERS
,
JSON_PROTOCOL
,
LINEFEED
,
NAVBAR_HEIGHT
,
NODE_TYPE_COMMENT
,
NODE_TYPE_ELEMENT
,
NODE_TYPE_PAGE
,
NODE_TYPE_TEXT
,
ON_ADD_TO_FAVORITES
,
ON_APP_ENTER_BACKGROUND
,
ON_APP_ENTER_FOREGROUND
,
ON_BACK_PRESS
,
ON_ERROR
,
ON_HIDE
,
ON_KEYBOARD_HEIGHT_CHANGE
,
ON_LAUNCH
,
ON_LOAD
,
ON_NAVIGATION_BAR_BUTTON_TAP
,
ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED
,
ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED
,
ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED
,
ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED
,
ON_PAGE_NOT_FOUND
,
ON_PAGE_SCROLL
,
ON_PULL_DOWN_REFRESH
,
ON_REACH_BOTTOM
,
ON_REACH_BOTTOM_DISTANCE
,
ON_READY
,
ON_RESIZE
,
ON_SHARE_APP_MESSAGE
,
ON_SHARE_TIMELINE
,
ON_SHOW
,
ON_TAB_ITEM_TAP
,
ON_THEME_CHANGE
,
ON_UNHANDLE_REJECTION
,
ON_UNLOAD
,
ON_WEB_INVOKE_APP_SERVICE
,
ON_WXS_INVOKE_CALL_METHOD
,
PLUS_RE
,
PRIMARY_COLOR
,
RENDERJS_MODULES
,
RESPONSIVE_MIN_WIDTH
,
SCHEME_RE
,
SELECTED_COLOR
,
TABBAR_HEIGHT
,
TAGS
,
UNI_SSR
,
UNI_SSR_DATA
,
UNI_SSR_GLOBAL_DATA
,
UNI_SSR_STORE
,
UNI_SSR_TITLE
,
UniBaseNode
,
UniCommentNode
,
UniElement
,
UniEvent
,
UniInputElement
,
UniLifecycleHooks
,
UniNode
,
UniTextAreaElement
,
UniTextNode
,
WEB_INVOKE_APPSERVICE
,
WXS_MODULES
,
WXS_PROTOCOL
,
addFont
,
cache
,
cacheStringFunction
,
callOptions
,
createRpx2Unit
,
createUniEvent
,
debounce
,
decode
,
decodedQuery
,
default
MiniProgramRpx2Unit
,
default
Rpx2Unit
,
formatAppLog
,
formatDateTime
,
formatLog
,
getCustomDataset
,
getEnvLocale
,
getLen
,
getValueByDataPath
,
initCustomDataset
,
invokeArrayFns
,
isBuiltInComponent
,
isCustomElement
,
isNativeTag
,
isRootHook
,
isServiceCustomElement
,
isServiceNativeTag
,
normalizeDataset
,
normalizeEventType
,
normalizeTarget
,
once
,
parseEventName
,
parseQuery
,
parseUrl
,
passive
,
plusReady
,
removeLeadingSlash
,
resolveOwnerEl
,
resolveOwnerVm
,
sanitise
,
scrollTo
,
stringifyQuery
,
updateElementStyle
};
packages/uni-shared/src/dom/style.ts
浏览文件 @
72ad6aef
...
...
@@ -15,6 +15,12 @@ export const defaultRpx2Unit = {
unitPrecision
:
5
,
}
export
const
defaultMiniProgramRpx2Unit
=
{
unit
:
'
rpx
'
,
unitRatio
:
1
,
unitPrecision
:
1
,
}
export
type
Rpx2UnitOptions
=
typeof
defaultRpx2Unit
export
function
createRpx2Unit
(
...
...
@@ -28,6 +34,9 @@ export function createRpx2Unit(
if
(
!
$1
)
{
return
m
}
if
(
unitRatio
===
1
)
{
return
`
${
$1
}${
unit
}
`
}
const
value
=
toFixed
(
parseFloat
(
$1
)
*
unitRatio
,
unitPrecision
)
return
value
===
0
?
'
0
'
:
`
${
value
}${
unit
}
`
})
...
...
packages/vite-plugin-uni/src/utils/index.ts
浏览文件 @
72ad6aef
export
*
from
'
./ast
'
export
*
from
'
./filter
'
export
*
from
'
./plugin
'
export
*
from
'
./postcss
'
packages/vite-plugin-uni/src/utils/postcss.ts
已删除
100644 → 0
浏览文件 @
0eb7ff2b
import
{
extend
}
from
'
@vue/shared
'
import
{
rule
,
Rule
,
Declaration
,
Plugin
}
from
'
postcss
'
import
selectorParser
from
'
postcss-selector-parser
'
import
{
createRpx2Unit
,
defaultRpx2Unit
,
isBuiltInComponent
,
COMPONENT_SELECTOR_PREFIX
,
}
from
'
@dcloudio/uni-shared
'
interface
UniAppCssProcessorOptions
{
page
?:
string
unit
?:
string
// 目标单位,默认rem
unitRatio
?:
number
// 单位转换比例,默认10/320
unitPrecision
?:
number
// 单位精度,默认5
}
const
defaultUniAppCssProcessorOptions
=
extend
(
{
page
:
'
body
'
,
},
defaultRpx2Unit
)
const
BG_PROPS
=
[
'
background
'
,
'
background-clip
'
,
'
background-color
'
,
'
background-image
'
,
'
background-origin
'
,
'
background-position
'
,
'
background-repeat
'
,
'
background-size
'
,
'
background-attachment
'
,
]
function
transform
(
selector
:
selectorParser
.
Node
,
page
:
string
,
state
:
{
bg
:
boolean
}
)
{
if
(
selector
.
type
!==
'
tag
'
)
{
return
}
const
{
value
}
=
selector
if
(
isBuiltInComponent
(
value
))
{
selector
.
value
=
COMPONENT_SELECTOR_PREFIX
+
value
}
else
if
(
value
===
'
page
'
)
{
if
(
!
page
)
{
return
}
selector
.
value
=
page
if
(
page
!==
'
body
'
)
{
state
.
bg
=
true
}
}
}
function
createBodyBackgroundRule
(
origRule
:
Rule
)
{
const
bgDecls
:
Declaration
[]
=
[]
origRule
.
walkDecls
((
decl
)
=>
{
if
(
BG_PROPS
.
indexOf
(
decl
.
prop
)
!==
-
1
)
{
bgDecls
.
push
(
decl
.
clone
())
}
})
if
(
bgDecls
.
length
)
{
origRule
.
after
(
rule
({
selector
:
'
body
'
}).
append
(
bgDecls
))
}
}
function
walkRules
(
page
:
string
)
{
return
(
rule
:
Rule
)
=>
{
const
state
=
{
bg
:
false
}
rule
.
selector
=
selectorParser
((
selectors
)
=>
selectors
.
walk
((
selector
)
=>
transform
(
selector
,
page
,
state
))
).
processSync
(
rule
.
selector
)
state
.
bg
&&
createBodyBackgroundRule
(
rule
)
}
}
function
walkDecls
(
rpx2unit
:
ReturnType
<
typeof
createRpx2Unit
>
)
{
return
(
decl
:
Declaration
)
=>
{
const
{
value
}
=
decl
if
(
value
.
indexOf
(
'
rpx
'
)
===
-
1
&&
value
.
indexOf
(
'
upx
'
)
===
-
1
)
{
return
}
decl
.
value
=
rpx2unit
(
decl
.
value
)
}
}
export
const
uniapp
=
(
opts
?:
UniAppCssProcessorOptions
)
=>
{
const
{
page
,
unit
,
unitRatio
,
unitPrecision
}
=
extend
(
{},
defaultUniAppCssProcessorOptions
,
opts
||
{}
)
const
rpx2unit
=
createRpx2Unit
(
unit
,
unitRatio
,
unitPrecision
)
return
{
postcssPlugin
:
'
uni-app
'
,
prepare
()
{
return
{
OnceExit
(
root
)
{
root
.
walkDecls
(
walkDecls
(
rpx2unit
))
root
.
walkRules
(
walkRules
(
page
))
},
}
},
}
as
Plugin
}
uniapp
.
postcss
=
true
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录