Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
4188afe2
U
uni-app
项目概览
DCloud
/
uni-app
6 个月 前同步成功
通知
751
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
4188afe2
编写于
3月 29, 2023
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(uts): compiler
上级
4bd02b87
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
91 addition
and
18 deletion
+91
-18
packages/playground/uts/unpackage/dist/dev/.sourcemap/app/uni_modules/test-uniplugin/utssdk/app-ios/index.swift.map
...uni_modules/test-uniplugin/utssdk/app-ios/index.swift.map
+1
-1
packages/playground/uts/unpackage/dist/dev/app-plus/uni_modules/test-component/utssdk/app-ios/index.swift
...lus/uni_modules/test-component/utssdk/app-ios/index.swift
+5
-5
packages/playground/uts/unpackage/dist/dev/app-plus/uni_modules/test-uniplugin/utssdk/app-ios/index.swift
...lus/uni_modules/test-uniplugin/utssdk/app-ios/index.swift
+6
-6
packages/uni-app-plus/dist/uni.runtime.esm.js
packages/uni-app-plus/dist/uni.runtime.esm.js
+4
-0
packages/uni-app-plus/src/service/api/plugin/uts.js
packages/uni-app-plus/src/service/api/plugin/uts.js
+4
-0
packages/uni-app-plus/src/service/api/plugin/uts.ts
packages/uni-app-plus/src/service/api/plugin/uts.ts
+4
-0
packages/uni-cli-shared/__tests__/uniExtApi.spec.ts
packages/uni-cli-shared/__tests__/uniExtApi.spec.ts
+23
-0
packages/uni-cli-shared/src/uni_modules.ts
packages/uni-cli-shared/src/uni_modules.ts
+40
-5
packages/uts-darwin-arm64/uts.darwin-arm64.node
packages/uts-darwin-arm64/uts.darwin-arm64.node
+0
-0
packages/uts-darwin-x64/uts.darwin-x64.node
packages/uts-darwin-x64/uts.darwin-x64.node
+0
-0
packages/uts-linux-x64-gnu/uts.linux-x64-gnu.node
packages/uts-linux-x64-gnu/uts.linux-x64-gnu.node
+0
-0
packages/uts-linux-x64-musl/uts.linux-x64-musl.node
packages/uts-linux-x64-musl/uts.linux-x64-musl.node
+0
-0
packages/uts-win32-ia32-msvc/uts.win32-ia32-msvc.node
packages/uts-win32-ia32-msvc/uts.win32-ia32-msvc.node
+0
-0
packages/uts-win32-x64-msvc/uts.win32-x64-msvc.node
packages/uts-win32-x64-msvc/uts.win32-x64-msvc.node
+0
-0
packages/vite-plugin-uni/src/index.ts
packages/vite-plugin-uni/src/index.ts
+4
-1
未找到文件。
packages/playground/uts/unpackage/dist/dev/.sourcemap/app/uni_modules/test-uniplugin/utssdk/app-ios/index.swift.map
浏览文件 @
4188afe2
{
"version"
:
3
,
"sources"
:
[
"uni_modules/test-uniplugin/utssdk/app-ios/index.uts"
,
"uni_modules/test-uniplugin/utssdk/interface.uts"
],
"sourcesContent"
:
[
"import { UIDevice } from 'UIKit'
\n
import { CLLocationManager, CLAuthorizationStatus } from 'CoreLocation'
\n
import { ShowToast } from '../interface.uts'
\n\n
type GetBatteryInfoOptions = {\n name: string
\n
pwd: number
\n
success?: (res: UTSJSONObject) => void
\n
fail?: (res: UTSJSONObject) => void
\n
complete?: (res: UTSJSONObject) => void
\n
}
\n\n
export default function getBatteryInfo(options: GetBatteryInfoOptions) {\n new UIAlertController(
\n
(title = title),
\n
(message = message),
\n
(preferredStyle = UIAlertController.Style.alert)
\n
)
\n
const res = {\n errMsg: 'getBatteryInfo:ok',
\n
level: UIDevice.current.batteryLevel * 100,
\n
isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging,
\n
}
\n
if (options.success != null) {\n options.success!(res)
\n
}
\n
if (options.complete != null) {\n options.complete!(res)
\n
}
\n
}
\n\n
export function test1(callback: () => void): string {\n console.log({
\"
a
\"
:
\"
b
\"
})
\n
console.log('test1')
\n\n\n\n\n
console.log('def ios')
\n\n\n
console.log('ndef android')
\n\n\n\n\n\n
console.log('def android || def ios')
\n\n\n\n\n
console.log(CLLocationManager, CLAuthorizationStatus)
\n
const a = -3
\n
console.log(~a)
\n
return 'test1'
\n
}
\n\n
class Test1 { }
\n
export class Test {\n constructor() {\n new Test1()
\n
}
\n
test(): string | null {\n if (UTSiOS.macros(
\"
swift(>=1)
\"
)) {\n console.log(
\"
swift(>=1)
\"
)
\n
}
\n
if (UTSiOS.macros(
\"
arch(i386) || arch(arm)
\"
)) {\n console.log(
\"
arch(i386) || arch(arm)
\"
)
\n
}
\n
if (UTSiOS.available(
\"
iOS 14, macOS 11.0, *
\"
)) {\n console.log(
\"
iOS 14, macOS 11.0, *
\"
)
\n
} else if (UTSiOS.available(
\"
iOS 13,*
\"
)) {\n console.log(
\"
iOS 13,*
\"
)
\n
} else if (UTSiOS.unavailable(
\"
tvOS 12
\"
)) {\n console.log(
\"
tvOS 12
\"
)
\n
}
\n
return null
\n
}
\n
}
\n\n
export async function testAsync() {\n uni.showToast()
\n
uni.showToast()
\n
uni.showModel()
\n
return { a: 1 }
\n
}
\n\n
export const showToast1: ShowToast = (msg) => { }
\n
export const showToast2: ShowToast = function (msg) { }
\n
export const showToast3: ShowToast = function showToast(msg) { }
\n
"
,
"export type ShowToast = (msg: string) => void
\n
"
],
"names"
:
[],
"mappings"
:
";;AAAA,aAAgC;AAChC,oBAAuE;;;iBCD3D,eAAa,KAAK,MAAM,KAAK,IAAI;ADIhB;;aAAxB;IACH,WAAA,MAAM,MAAM,EAAA;IACZ,WAAA,KAAK,QAAM,EAAA;IACX,WAAA,aAAW,KA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AQ,GAAG,CAAC;;;;QAEd,OAAO,GAAI;IACb;AACF;AAEO;YAAe,mCAAY;IAC5B;IACA;IACA;IACJ,OAAO;QAAE,CAAA,IAAG,CAAC;MAAE;AACjB;AAEO,WAAM,wBAAwB;GAAC;;AAC/B,WAAM,wBAAwB;CAAU,EAAA,GAAG;;AAC3C,WAAM,wBAAwB;CAAmB,EAAA,GAAG;;AAtF9B;;;IAC3B,WAAA,MAAM,MAAM,EAAA;IACZ,WAAA,KAAK,QAAM,EAAA;IACX,WAAA,SAAQ,aAA8B;IACtC,WAAA,MAAK,aAA8B;IACnC,WAAA,UAAS,aAA8B;AACzC;+BAEuC,EAAA,SAAS,+BAAqB;;;;;SALxD,KAAK;yBAAL;;;SACH,KAAK;sBAAL;;;SACI,KAAK;0BAAL;;;;wBAsBQ,0BAAuB,MAAM;;QAA7B;;;;;;;8BAgCZ,MAAM;;;;;;;;6BC/DS,KAAK,MAAM,KAAK,IAAI;sBAApB;;6BAAA,KAAK,MAAM,KAAK,IAAI;sBAApB;;6BAAA,KAAK,MAAM,KAAK,IAAI;sBAApB;;;;;4CDYc,EAAA,SAAS,+BAAqB;kCAA9B;;qCAmBjB,0BAAuB,MAAM;yBAA7B;;;;;;0CC/BG,KAAK,MAAM,KAAK,IAAI;8BAApB;;0CAAA,KAAK,MAAM,KAAK,IAAI;8BAApB;;0CAAA,KAAK,MAAM,KAAK,IAAI;8BAApB"
}
\ No newline at end of file
{
"version"
:
3
,
"sources"
:
[
"uni_modules/test-uniplugin/utssdk/app-ios/index.uts"
,
"uni_modules/test-uniplugin/utssdk/interface.uts"
],
"sourcesContent"
:
[
"import { UIDevice } from 'UIKit'
\n
import { CLLocationManager, CLAuthorizationStatus } from 'CoreLocation'
\n
import { ShowToast } from '../interface.uts'
\n\n
type GetBatteryInfoOptions = {\n name: string
\n
pwd: number
\n
success?: (res: UTSJSONObject) => void
\n
fail?: (res: UTSJSONObject) => void
\n
complete?: (res: UTSJSONObject) => void
\n
}
\n\n
export default function getBatteryInfo(options: GetBatteryInfoOptions) {\n new UIAlertController(
\n
(title = title),
\n
(message = message),
\n
(preferredStyle = UIAlertController.Style.alert)
\n
)
\n
const res = {\n errMsg: 'getBatteryInfo:ok',
\n
level: UIDevice.current.batteryLevel * 100,
\n
isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging,
\n
}
\n
if (options.success != null) {\n options.success!(res)
\n
}
\n
if (options.complete != null) {\n options.complete!(res)
\n
}
\n
}
\n\n
export function test1(callback: () => void): string {\n console.log({
\"
a
\"
:
\"
b
\"
})
\n
console.log('test1')
\n\n\n\n\n
console.log('def ios')
\n\n\n
console.log('ndef android')
\n\n\n\n\n\n
console.log('def android || def ios')
\n\n\n\n\n
console.log(CLLocationManager, CLAuthorizationStatus)
\n
const a = -3
\n
console.log(~a)
\n
return 'test1'
\n
}
\n\n
class Test1 { }
\n
export class Test {\n constructor() {\n new Test1()
\n
}
\n
test(): string | null {\n if (UTSiOS.macros(
\"
swift(>=1)
\"
)) {\n console.log(
\"
swift(>=1)
\"
)
\n
}
\n
if (UTSiOS.macros(
\"
arch(i386) || arch(arm)
\"
)) {\n console.log(
\"
arch(i386) || arch(arm)
\"
)
\n
}
\n
if (UTSiOS.available(
\"
iOS 14, macOS 11.0, *
\"
)) {\n console.log(
\"
iOS 14, macOS 11.0, *
\"
)
\n
} else if (UTSiOS.available(
\"
iOS 13,*
\"
)) {\n console.log(
\"
iOS 13,*
\"
)
\n
} else if (UTSiOS.unavailable(
\"
tvOS 12
\"
)) {\n console.log(
\"
tvOS 12
\"
)
\n
}
\n
return null
\n
}
\n
}
\n\n
export async function testAsync() {\n uni.showToast()
\n
uni.showToast()
\n
uni.showModel()
\n
return { a: 1 }
\n
}
\n\n
export const showToast1: ShowToast = (msg) => { }
\n
export const showToast2: ShowToast = function (msg) { }
\n
export const showToast3: ShowToast = function showToast(msg) { }
\n
"
,
"export type ShowToast = (msg: string) => void
\n
"
],
"names"
:
[],
"mappings"
:
";;AAAA,aAAgC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AAQ;QACpB;YACE,QAAQ,GAAG,CAAC;cACb;QACD;YACE,QAAQ,GAAG,CAAC;cACb;QACD;YACE,QAAQ,GAAG,CAAC;;YACP;gBACL,QAAQ,GAAG,CAAC;;gBACP;oBACL,QAAQ,GAAG,CAAC;;;;QAEd,OAAO,GAAI;IACb;AACF;AAEO;YAAe,mCAAY;IAC5B;IACA;IACA;IACJ,OAAO;QAAE,CAAA,IAAG,CAAC;MAAE;AACjB;AAEO,WAAM,wBAAwB;GAAC;;AAC/B,WAAM,wBAAwB;CAAU,EAAA,GAAG;;AAC3C,WAAM,wBAAwB;CAAmB,EAAA,GAAG;;AAtF9B;;;IAC3B,WAAA,MAAM,MAAM,EAAA;IACZ,WAAA,KAAK,QAAM,EAAA;IACX,WAAA,SAAQ,aAA8B;IACtC,WAAA,MAAK,aAA8B;IACnC,WAAA,UAAS,aAA8B;AACzC;+BAEuC,EAAA,SAAS,+BAAqB;;;;;SALxD,KAAK;yBAAL;;;SACH,KAAK;sBAAL;;;SACI,KAAK;0BAAL;;;;wBAsBQ,0BAAuB,MAAM;;;IAA7B;;;;;;8BAgCZ,MAAM;;;;;;;;6BC/DS,KAAK,MAAM,KAAK,IAAI;sBAApB;;6BAAA,KAAK,MAAM,KAAK,IAAI;sBAApB;;6BAAA,KAAK,MAAM,KAAK,IAAI;sBAApB;;;;;4CDYc,EAAA,SAAS,+BAAqB;kCAA9B;;qCAmBjB,0BAAuB,MAAM;yBAA7B;;;;;;0CC/BG,KAAK,MAAM,KAAK,IAAI;8BAApB;;0CAAA,KAAK,MAAM,KAAK,IAAI;8BAApB;;0CAAA,KAAK,MAAM,KAAK,IAAI;8BAApB"
}
\ No newline at end of file
packages/playground/uts/unpackage/dist/dev/app-plus/uni_modules/test-component/utssdk/app-ios/index.swift
浏览文件 @
4188afe2
...
...
@@ -88,7 +88,7 @@ public class AnimationViewComponent : UTSComponent<UIView> {
}
public
override
func
__
$$
init
()
{
self
.
__
$$
watch
(
"path"
,
{
(
__newValue
,
__oldValue
)
in
(
__newValue
,
__oldValue
)
->
Void
in
var
newValue
=
UTSiOS
.
convertString
(
__newValue
);
var
oldValue
=
UTSiOS
.
convertString
(
__oldValue
);
self
.
path
=
newValue
;
...
...
@@ -97,7 +97,7 @@ public class AnimationViewComponent : UTSComponent<UIView> {
}
});
self
.
__
$$
watch
(
"loop"
,
{
(
__newValue
,
__oldValue
)
in
(
__newValue
,
__oldValue
)
->
Void
in
var
newValue
=
UTSiOS
.
convertBool
(
__newValue
);
var
oldValue
=
UTSiOS
.
convertBool
(
__oldValue
);
self
.
loop
=
newValue
;
...
...
@@ -106,13 +106,13 @@ public class AnimationViewComponent : UTSComponent<UIView> {
}
});
self
.
__
$$
watch
(
"autoplay"
,
{
(
__newValue
,
__oldValue
)
in
(
__newValue
,
__oldValue
)
->
Void
in
var
newValue
=
UTSiOS
.
convertBool
(
__newValue
);
var
oldValue
=
UTSiOS
.
convertBool
(
__oldValue
);
self
.
autoplay
=
newValue
;
});
self
.
__
$$
watch
(
"action"
,
{
(
__newValue
,
__oldValue
)
in
(
__newValue
,
__oldValue
)
->
Void
in
var
newValue
=
UTSiOS
.
convertString
(
__newValue
);
var
oldValue
=
UTSiOS
.
convertString
(
__oldValue
);
var
action
=
newValue
;
...
...
@@ -131,7 +131,7 @@ public class AnimationViewComponent : UTSComponent<UIView> {
}
});
self
.
__
$$
watch
(
"hidden"
,
{
(
__newValue
,
__oldValue
)
in
(
__newValue
,
__oldValue
)
->
Void
in
var
newValue
=
UTSiOS
.
convertBool
(
__newValue
);
var
oldValue
=
UTSiOS
.
convertBool
(
__oldValue
);
self
.
hidden
=
newValue
;
...
...
packages/playground/uts/unpackage/dist/dev/app-plus/uni_modules/test-uniplugin/utssdk/app-ios/index.swift
浏览文件 @
4188afe2
...
...
@@ -92,13 +92,13 @@ public func testAsync() async -> UTSJSONObject {
]);
}
public
var
showToast1
:
ShowToast
=
{
(
_
msg
)
in
(
_
msg
)
->
Void
in
};
public
var
showToast2
:
ShowToast
=
{
(
_
msg
)
in
(
_
msg
)
->
Void
in
};
public
var
showToast3
:
ShowToast
=
{
(
_
msg
)
in
(
_
msg
)
->
Void
in
};
@objc
(
UTSSDKModulesTestUniPluginGetBatteryInfoOptionsJSONObject
)
@objcMembers
...
...
@@ -129,9 +129,9 @@ public func getBatteryInfoByJs(_ options: GetBatteryInfoOptionsJSONObject) {
}
public
func
test1ByJs
(
_
callback
:
UTSCallback
)
->
String
{
return
test1
({
callback
();
}
);
()
->
Void
in
callback
();
}
);
}
@objc
(
UTSSDKModulesTestUniPluginTestByJs
)
@objcMembers
...
...
packages/uni-app-plus/dist/uni.runtime.esm.js
浏览文件 @
4188afe2
...
...
@@ -17314,6 +17314,10 @@ function resolveSyncResult(res, returnOptions, instanceId, proxy) {
}
if (returnOptions) {
if (returnOptions.type === 'interface' && typeof res.params === 'number') {
// 返回了 0
if (!res.params) {
return null;
}
if (res.params === instanceId && proxy) {
return proxy;
}
...
...
packages/uni-app-plus/src/service/api/plugin/uts.js
浏览文件 @
4188afe2
...
...
@@ -40,6 +40,10 @@ function resolveSyncResult(res, returnOptions, instanceId, proxy) {
}
if
(
returnOptions
)
{
if
(
returnOptions
.
type
===
'
interface
'
&&
typeof
res
.
params
===
'
number
'
)
{
// 返回了 0
if
(
!
res
.
params
)
{
return
null
;
}
if
(
res
.
params
===
instanceId
&&
proxy
)
{
return
proxy
;
}
...
...
packages/uni-app-plus/src/service/api/plugin/uts.ts
浏览文件 @
4188afe2
...
...
@@ -234,6 +234,10 @@ function resolveSyncResult(
}
if
(
returnOptions
)
{
if
(
returnOptions
.
type
===
'
interface
'
&&
typeof
res
.
params
===
'
number
'
)
{
// 返回了 0
if
(
!
res
.
params
)
{
return
null
}
if
(
res
.
params
===
instanceId
&&
proxy
)
{
return
proxy
}
...
...
packages/uni-cli-shared/__tests__/uniExtApi.spec.ts
浏览文件 @
4188afe2
...
...
@@ -72,5 +72,28 @@ describe('uni_modules:uni-ext-api', () => {
).
toEqual
({
'
uni.chooseLocation
'
:
[
'
@/uni_modules/uni-location
'
,
'
chooseLocation
'
],
})
expect
(
parseInjects
(
true
,
'
app
'
,
`@/uni_modules/uni-request`
,
{
uni
:
{
request
:
{
app
:
{
js
:
false
,
},
},
},
})
).
toEqual
({
'
uni.request
'
:
[
'
@/uni_modules/uni-request
'
,
'
request
'
,
{
js
:
false
}],
})
expect
(
parseInjects
(
true
,
'
app
'
,
`@/uni_modules/uni-request`
,
{
uni
:
{
request
:
{
app
:
false
,
},
},
})
).
toEqual
({})
})
})
packages/uni-cli-shared/src/uni_modules.ts
浏览文件 @
4188afe2
...
...
@@ -2,12 +2,24 @@ import path from 'path'
import
fs
from
'
fs-extra
'
import
{
recursive
}
from
'
merge
'
type
Define
=
string
|
string
[]
|
Record
<
string
,
string
>
|
false
type
DefineOptions
=
{
name
?:
string
app
?:
|
boolean
|
{
js
?:
boolean
kotlin
?:
boolean
swift
?:
boolean
}
[
key
:
string
]:
any
}
type
Define
=
string
|
string
[]
|
Record
<
string
,
string
|
DefineOptions
>
|
false
type
Defines
=
{
[
name
:
string
]:
Define
}
interface
Exports
{
export
interface
Exports
{
[
name
:
string
]:
Define
|
Defines
|
false
}
...
...
@@ -50,7 +62,11 @@ export function parseUniExtApis(vite = true) {
type
Inject
=
string
|
string
[]
type
Injects
=
{
[
name
:
string
]:
string
|
string
[]
|
false
[
name
:
string
]:
|
string
|
[
string
,
string
]
|
[
string
,
string
,
DefineOptions
[
'
app
'
]]
|
false
}
/**
* uni:'getBatteryInfo'
...
...
@@ -95,13 +111,17 @@ export function parseInjects(
}
const
injects
:
Injects
=
{}
for
(
const
key
in
rootDefines
)
{
Object
.
assign
(
injects
,
parseInject
(
vite
,
source
,
'
uni
'
,
rootDefines
[
key
]))
Object
.
assign
(
injects
,
parseInject
(
vite
,
platform
,
source
,
'
uni
'
,
rootDefines
[
key
])
)
}
return
injects
}
export
function
parseInject
(
vite
=
true
,
platform
:
UniApp
.
PLATFORM
,
source
:
string
,
globalObject
:
string
,
define
:
Define
...
...
@@ -119,7 +139,22 @@ export function parseInject(
}
else
{
const
keys
=
Object
.
keys
(
define
)
keys
.
forEach
((
d
)
=>
{
injects
[
globalObject
+
'
.
'
+
d
]
=
[
source
,
define
[
d
]]
if
(
typeof
define
[
d
]
===
'
string
'
)
{
injects
[
globalObject
+
'
.
'
+
d
]
=
[
source
,
define
[
d
]
as
string
]
}
else
{
const
defineOptions
=
define
[
d
]
as
DefineOptions
if
(
defineOptions
[
platform
]
!==
false
)
{
if
(
platform
===
'
app
'
)
{
injects
[
globalObject
+
'
.
'
+
d
]
=
[
source
,
defineOptions
.
name
||
d
,
defineOptions
.
app
,
]
}
else
{
injects
[
globalObject
+
'
.
'
+
d
]
=
[
source
,
defineOptions
.
name
||
d
]
}
}
}
})
}
return
injects
...
...
packages/uts-darwin-arm64/uts.darwin-arm64.node
浏览文件 @
4188afe2
无法预览此类型文件
packages/uts-darwin-x64/uts.darwin-x64.node
浏览文件 @
4188afe2
无法预览此类型文件
packages/uts-linux-x64-gnu/uts.linux-x64-gnu.node
浏览文件 @
4188afe2
无法预览此类型文件
packages/uts-linux-x64-musl/uts.linux-x64-musl.node
浏览文件 @
4188afe2
无法预览此类型文件
packages/uts-win32-ia32-msvc/uts.win32-ia32-msvc.node
浏览文件 @
4188afe2
无法预览此类型文件
packages/uts-win32-x64-msvc/uts.win32-x64-msvc.node
浏览文件 @
4188afe2
无法预览此类型文件
packages/vite-plugin-uni/src/index.ts
浏览文件 @
4188afe2
...
...
@@ -10,6 +10,7 @@ import legacyPlugin from '@vitejs/plugin-legacy'
import
{
CopyOptions
,
InjectOptions
,
emptyDir
,
initModuleAlias
,
initPreContext
,
...
...
@@ -94,7 +95,9 @@ export default function uniPlugin(
const
injects
=
parseUniExtApis
()
if
(
Object
.
keys
(
injects
).
length
)
{
plugins
.
push
(
uniViteInjectPlugin
(
'
uni:ext-api-inject
'
,
injects
))
plugins
.
push
(
uniViteInjectPlugin
(
'
uni:ext-api-inject
'
,
injects
as
InjectOptions
)
)
}
// 仅限 h5
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录