Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
f2138ec8
U
uni-app
项目概览
DCloud
/
uni-app
6 个月 前同步成功
通知
750
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看板
提交
f2138ec8
编写于
10月 31, 2023
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(uts): web平台支持uvue.css
上级
0c040231
变更
17
展开全部
隐藏空白更改
内联
并排
Showing
17 changed file
with
38155 addition
and
47 deletion
+38155
-47
.prettierignore
.prettierignore
+1
-0
packages/global.d.ts
packages/global.d.ts
+1
-0
packages/shims-uni-app.d.ts
packages/shims-uni-app.d.ts
+3
-0
packages/uni-app-uts/src/plugins/pre.ts
packages/uni-app-uts/src/plugins/pre.ts
+1
-1
packages/uni-cli-shared/src/json/pages.ts
packages/uni-cli-shared/src/json/pages.ts
+22
-18
packages/uni-h5-vite/src/plugin/handleHotUpdate/index.ts
packages/uni-h5-vite/src/plugin/handleHotUpdate/index.ts
+5
-1
packages/uni-h5-vite/src/plugins/manifestJson.ts
packages/uni-h5-vite/src/plugins/manifestJson.ts
+10
-7
packages/uni-h5-vite/src/plugins/pagesJson.ts
packages/uni-h5-vite/src/plugins/pagesJson.ts
+12
-5
packages/uni-h5-vite/src/plugins/resolveId.ts
packages/uni-h5-vite/src/plugins/resolveId.ts
+5
-1
packages/uni-h5/dist-x/uni-h5.cjs.js
packages/uni-h5/dist-x/uni-h5.cjs.js
+12438
-0
packages/uni-h5/dist-x/uni-h5.es.js
packages/uni-h5/dist-x/uni-h5.es.js
+25555
-0
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+9
-7
packages/uni-h5/package.json
packages/uni-h5/package.json
+1
-0
packages/uni-h5/src/framework/setup/page.ts
packages/uni-h5/src/framework/setup/page.ts
+12
-6
packages/uni-h5/style/framework/uvue.css
packages/uni-h5/style/framework/uvue.css
+57
-0
packages/uni-h5/vite.config.ts
packages/uni-h5/vite.config.ts
+3
-1
scripts/build.js
scripts/build.js
+20
-0
未找到文件。
.prettierignore
浏览文件 @
f2138ec8
dist
dist-x
packages/uni-app-plus/lib
packages/uni-app-vite/lib
packages/uni-app-vue/lib
...
...
packages/global.d.ts
浏览文件 @
f2138ec8
...
...
@@ -29,6 +29,7 @@ declare var __IMPORT_META_ENV_BASE_URL__:
|
'
__IMPORT_META_ENV_BASE_URL__
'
// Global compile-time constants
declare
var
__X__
:
boolean
declare
var
__DEV__
:
boolean
declare
var
__TEST__
:
boolean
declare
var
__NODE_JS__
:
boolean
...
...
packages/shims-uni-app.d.ts
浏览文件 @
f2138ec8
...
...
@@ -51,6 +51,9 @@ declare namespace UniNamespace {
nvue
?:
{
'
flex-direction
'
:
'
column
'
|
'
row
'
}
uvue
?:
{
'
flex-direction
'
:
'
column
'
|
'
row
'
}
globalStyle
:
PagesJsonPageStyle
&
{
rpxCalcMaxDeviceWidth
?:
number
rpxCalcBaseDeviceWidth
?:
number
...
...
packages/uni-app-uts/src/plugins/pre.ts
浏览文件 @
f2138ec8
...
...
@@ -18,7 +18,7 @@ const debugPreHtml = debug('uni:pre-html')
const
debugPreJsTry
=
debug
(
'
uni:pre-js-try
'
)
const
PRE_HTML_EXTNAME
=
[
'
.vue
'
,
'
.uvue
'
]
const
PRE_JS_EXTNAME
=
[
'
.json
'
,
'
.css
'
,
'
.uts
'
].
concat
(
PRE_HTML_EXTNAME
)
const
PRE_JS_EXTNAME
=
[
'
.json
'
,
'
.css
'
,
'
.uts
'
,
'
.ts
'
].
concat
(
PRE_HTML_EXTNAME
)
export
function
uniPrePlugin
(
options
:
UniPrePluginOptions
=
{}):
Plugin
{
const
filter
=
createFilter
(
options
.
include
,
options
.
exclude
)
...
...
packages/uni-cli-shared/src/json/pages.ts
浏览文件 @
f2138ec8
...
...
@@ -235,26 +235,30 @@ function normalizePageStyle(
pageStyle
:
UniApp
.
PagesJsonPageStyle
|
undefined
,
platform
:
UniApp
.
PLATFORM
)
{
const
hasNVue
=
pagePath
&&
process
.
env
.
UNI_INPUT_DIR
&&
fs
.
existsSync
(
path
.
join
(
process
.
env
.
UNI_INPUT_DIR
,
pagePath
+
'
.nvue
'
))
?
true
:
undefined
let
isNVue
=
false
if
(
hasNVue
)
{
const
hasVue
=
fs
.
existsSync
(
path
.
join
(
process
.
env
.
UNI_INPUT_DIR
,
pagePath
+
'
.vue
'
)
)
if
(
hasVue
)
{
if
(
platform
===
'
app
'
)
{
if
(
process
.
env
.
UNI_NVUE_COMPILER
!==
'
vue
'
)
{
isNVue
=
true
let
isNVue
:
boolean
|
undefined
=
false
if
(
process
.
env
.
UNI_APP_X
===
'
true
'
)
{
isNVue
=
undefined
}
else
{
const
hasNVue
=
pagePath
&&
process
.
env
.
UNI_INPUT_DIR
&&
fs
.
existsSync
(
path
.
join
(
process
.
env
.
UNI_INPUT_DIR
,
pagePath
+
'
.nvue
'
))
?
true
:
undefined
if
(
hasNVue
)
{
const
hasVue
=
fs
.
existsSync
(
path
.
join
(
process
.
env
.
UNI_INPUT_DIR
,
pagePath
+
'
.vue
'
)
)
if
(
hasVue
)
{
if
(
platform
===
'
app
'
)
{
if
(
process
.
env
.
UNI_NVUE_COMPILER
!==
'
vue
'
)
{
isNVue
=
true
}
}
}
else
{
isNVue
=
true
}
}
else
{
isNVue
=
true
}
}
...
...
packages/uni-h5-vite/src/plugin/handleHotUpdate/index.ts
浏览文件 @
f2138ec8
...
...
@@ -34,7 +34,11 @@ export function createHandleHotUpdate(): Plugin['handleHotUpdate'] {
invalidateFiles
=
[
path
.
resolve
(
inputDir
,
PAGES_JSON_JS
),
path
.
resolve
(
inputDir
,
MANIFEST_JSON_JS
),
resolveBuiltIn
(
'
@dcloudio/uni-h5/dist/uni-h5.es.js
'
),
resolveBuiltIn
(
'
@dcloudio/uni-h5/
'
+
(
process
.
env
.
UNI_APP_X
===
'
true
'
?
'
dist-x
'
:
'
dist
'
)
+
'
/uni-h5.es.js
'
),
]
try
{
invalidateFiles
.
push
(
resolveBuiltIn
(
'
vite/dist/client/env.mjs
'
))
...
...
packages/uni-h5-vite/src/plugins/manifestJson.ts
浏览文件 @
f2138ec8
...
...
@@ -94,11 +94,14 @@ export function uniManifestJsonPlugin(): Plugin {
)
const
fallbackLocale
=
(
i18nOptions
&&
i18nOptions
.
locale
)
||
''
const
vueType
=
process
.
env
.
UNI_APP_X
===
'
true
'
?
'
uvue
'
:
'
nvue
'
const
flexDirection
=
(
manifest
[
'
app
'
]
&&
manifest
[
'
app
'
].
nvue
&&
manifest
[
'
app
'
].
nvue
[
'
flex-direction
'
])
||
'
column
'
(
process
.
env
.
UNI_APP_X
===
'
true
'
?
manifest
[
'
uni-app-x
'
]
&&
manifest
[
'
uni-app-x
'
][
'
flex-direction
'
]
:
manifest
[
'
app
'
]
&&
manifest
[
'
app
'
].
nvue
&&
manifest
[
'
app
'
].
nvue
[
'
flex-direction
'
])
||
'
column
'
const
platformConfig
=
manifest
[
...
...
@@ -114,9 +117,9 @@ export function uniManifestJsonPlugin(): Plugin {
export const appVersionCode =
${
JSON
.
stringify
(
manifest
.
versionCode
||
''
)}
export const debug =
${
!!
debug
}
export const
nvue
=
${
JSON
.
stringify
({
'
flex-direction
'
:
flexDirection
,
})}
export const
${
vueType
}
=
${
JSON
.
stringify
({
'
flex-direction
'
:
flexDirection
,
})}
export const networkTimeout =
${
JSON
.
stringify
(
networkTimeout
)}
// h5
export const router =
${
JSON
.
stringify
(
router
)}
...
...
packages/uni-h5-vite/src/plugins/pagesJson.ts
浏览文件 @
f2138ec8
...
...
@@ -49,11 +49,11 @@ function generatePagesJsonCode(
const
uniRoutesCode
=
generateRoutes
(
globalName
,
pagesJson
,
config
)
const
uniConfigCode
=
generateConfig
(
globalName
,
pagesJson
,
config
)
const
cssCode
=
generateCssCode
(
config
)
const
vueType
=
process
.
env
.
UNI_APP_X
===
'
true
'
?
'
uvue
'
:
'
nvue
'
return
`
import { defineAsyncComponent, resolveComponent, createVNode, withCtx, openBlock, createBlock } from 'vue'
import { PageComponent, useI18n, setupWindow, setupPage } from '@dcloudio/uni-h5'
import { appId, appName, appVersion, appVersionCode, debug, networkTimeout, router, async, sdkConfigs, qqMapKey, googleMapKey, aMapKey, bMapKey, aMapSecurityJsCode, aMapServiceHost,
nvue
, locale, fallbackLocale, darkmode, themeConfig } from './
${
MANIFEST_JSON_JS
}
'
import { appId, appName, appVersion, appVersionCode, debug, networkTimeout, router, async, sdkConfigs, qqMapKey, googleMapKey, aMapKey, bMapKey, aMapSecurityJsCode, aMapServiceHost,
${
vueType
}
, locale, fallbackLocale, darkmode, themeConfig } from './
${
MANIFEST_JSON_JS
}
'
const locales = import.meta.globEager('./locale/*.json')
${
importLayoutComponentsCode
}
const extend = Object.assign
...
...
@@ -119,9 +119,15 @@ function generateCssCode(config: ResolvedConfig) {
if
(
define
.
__UNI_FEATURE_TABBAR__
)
{
cssFiles
.
push
(
H5_FRAMEWORK_STYLE_PATH
+
'
tabBar.css
'
)
}
if
(
define
.
__UNI_FEATURE_NVUE__
)
{
cssFiles
.
push
(
H5_FRAMEWORK_STYLE_PATH
+
'
nvue.css
'
)
// x 项目直接集成 uvue.css
if
(
process
.
env
.
UNI_APP_X
===
'
true
'
)
{
cssFiles
.
push
(
H5_FRAMEWORK_STYLE_PATH
+
'
uvue.css
'
)
}
else
{
if
(
define
.
__UNI_FEATURE_NVUE__
)
{
cssFiles
.
push
(
H5_FRAMEWORK_STYLE_PATH
+
'
nvue.css
'
)
}
}
if
(
define
.
__UNI_FEATURE_PULL_DOWN_REFRESH__
)
{
cssFiles
.
push
(
H5_FRAMEWORK_STYLE_PATH
+
'
pageRefresh.css
'
)
}
...
...
@@ -265,6 +271,7 @@ function generateConfig(
delete
pagesJson
.
subPackages
delete
pagesJson
.
subpackages
pagesJson
.
compilerVersion
=
process
.
env
.
UNI_COMPILER_VERSION
const
vueType
=
process
.
env
.
UNI_APP_X
===
'
true
'
?
'
uvue
'
:
'
nvue
'
return
`
${
globalName
}
.__uniConfig=extend(
${
JSON
.
stringify
(
pagesJson
)}
,{
appId,
appName,
...
...
@@ -280,7 +287,7 @@ function generateConfig(
aMapKey,
aMapSecurityJsCode,
aMapServiceHost,
nvue
,
${
vueType
}
,
locale,
fallbackLocale,
locales:Object.keys(locales).reduce((res,name)=>{const locale=name.replace(/\\.\\/locale\\/(uni-app.)?(.*).json/,'$2');extend(res[locale]||(res[locale]={}),locales[name].default);return res},{}),
...
...
packages/uni-h5-vite/src/plugins/resolveId.ts
浏览文件 @
f2138ec8
...
...
@@ -14,7 +14,11 @@ export function uniResolveIdPlugin(): Plugin {
enforce
:
'
pre
'
,
config
()
{
resolveCache
[
ownerModuleName
]
=
resolveBuiltIn
(
path
.
join
(
ownerModuleName
,
'
dist/uni-h5.es.js
'
)
path
.
join
(
ownerModuleName
,
(
process
.
env
.
UNI_APP_X
===
'
true
'
?
'
dist-x
'
:
'
dist
'
)
+
'
/uni-h5.es.js
'
)
)
resolveCache
[
'
@dcloudio/uni-h5-vue
'
]
=
resolveBuiltIn
(
path
.
join
(
...
...
packages/uni-h5/dist-x/uni-h5.cjs.js
0 → 100644
浏览文件 @
f2138ec8
此差异已折叠。
点击以展开。
packages/uni-h5/dist-x/uni-h5.es.js
0 → 100644
浏览文件 @
f2138ec8
此差异已折叠。
点击以展开。
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
f2138ec8
...
...
@@ -15330,13 +15330,15 @@ function pruneRouteCache(key) {
});
}
function updateCurPageAttrs(pageMeta) {
const nvueDirKey = "nvue-dir-" + __uniConfig.nvue["flex-direction"];
if (pageMeta.isNVue) {
document.body.setAttribute("nvue", "");
document.body.setAttribute(nvueDirKey, "");
} else {
document.body.removeAttribute("nvue");
document.body.removeAttribute(nvueDirKey);
{
const nvueDirKey = "nvue-dir-" + __uniConfig.nvue["flex-direction"];
if (pageMeta.isNVue) {
document.body.setAttribute("nvue", "");
document.body.setAttribute(nvueDirKey, "");
} else {
document.body.removeAttribute("nvue");
document.body.removeAttribute(nvueDirKey);
}
}
}
function onPageShow(instance2, pageMeta) {
...
...
packages/uni-h5/package.json
浏览文件 @
f2138ec8
...
...
@@ -6,6 +6,7 @@
"module"
:
"./dist/uni-h5.es.js"
,
"files"
:
[
"dist"
,
"dist-x"
,
"lib"
,
"style"
],
...
...
packages/uni-h5/src/framework/setup/page.ts
浏览文件 @
f2138ec8
...
...
@@ -178,13 +178,19 @@ function pruneRouteCache(key: string) {
}
function
updateCurPageAttrs
(
pageMeta
:
UniApp
.
PageRouteMeta
)
{
const
nvueDirKey
=
'
nvue-dir-
'
+
__uniConfig
.
nvue
!
[
'
flex-direction
'
]
if
(
pageMeta
.
isNVue
)
{
document
.
body
.
setAttribute
(
'
n
vue
'
,
''
)
document
.
body
.
setAttribute
(
n
vueDirKey
,
''
)
if
(
__X__
)
{
const
uvueDirKey
=
'
uvue-dir-
'
+
__uniConfig
.
uvue
!
[
'
flex-direction
'
]
document
.
body
.
setAttribute
(
'
u
vue
'
,
''
)
document
.
body
.
setAttribute
(
u
vueDirKey
,
''
)
}
else
{
document
.
body
.
removeAttribute
(
'
nvue
'
)
document
.
body
.
removeAttribute
(
nvueDirKey
)
const
nvueDirKey
=
'
nvue-dir-
'
+
__uniConfig
.
nvue
!
[
'
flex-direction
'
]
if
(
pageMeta
.
isNVue
)
{
document
.
body
.
setAttribute
(
'
nvue
'
,
''
)
document
.
body
.
setAttribute
(
nvueDirKey
,
''
)
}
else
{
document
.
body
.
removeAttribute
(
'
nvue
'
)
document
.
body
.
removeAttribute
(
nvueDirKey
)
}
}
}
...
...
packages/uni-h5/style/framework/uvue.css
0 → 100644
浏览文件 @
f2138ec8
[
uvue
]
uni-view
,
[
uvue
]
uni-label
,
[
uvue
]
uni-swiper-item
,
[
uvue
]
uni-scroll-view
{
display
:
flex
;
flex-shrink
:
0
;
flex-grow
:
0
;
flex-basis
:
auto
;
align-items
:
stretch
;
align-content
:
flex-start
;
}
[
uvue
]
uni-button
{
margin
:
0
;
}
[
uvue-dir-row
]
uni-view
,
[
uvue-dir-row
]
uni-label
,
[
uvue-dir-row
]
uni-swiper-item
{
flex-direction
:
row
;
}
[
uvue-dir-column
]
uni-view
,
[
uvue-dir-column
]
uni-label
,
[
uvue-dir-column
]
uni-swiper-item
{
flex-direction
:
column
;
}
[
uvue-dir-row-reverse
]
uni-view
,
[
uvue-dir-row-reverse
]
uni-label
,
[
uvue-dir-row-reverse
]
uni-swiper-item
{
flex-direction
:
row-reverse
;
}
[
uvue-dir-column-reverse
]
uni-view
,
[
uvue-dir-column-reverse
]
uni-label
,
[
uvue-dir-column-reverse
]
uni-swiper-item
{
flex-direction
:
column-reverse
;
}
[
uvue
]
uni-view
,
[
uvue
]
uni-image
,
[
uvue
]
uni-input
,
[
uvue
]
uni-scroll-view
,
[
uvue
]
uni-swiper
,
[
uvue
]
uni-swiper-item
,
[
uvue
]
uni-text
,
[
uvue
]
uni-textarea
,
[
uvue
]
uni-video
{
position
:
relative
;
border
:
0px
solid
#000000
;
box-sizing
:
border-box
;
}
[
uvue
]
uni-swiper-item
{
position
:
absolute
;
}
packages/uni-h5/vite.config.ts
浏览文件 @
f2138ec8
...
...
@@ -19,7 +19,7 @@ function resolve(file: string) {
}
const
FORMAT
=
process
.
env
.
FORMAT
as
'
es
'
|
'
cjs
'
const
isX
=
process
.
env
.
UNI_APP_X
===
'
true
'
const
rollupPlugins
=
[
replace
({
values
:
{
...
...
@@ -69,6 +69,7 @@ export default defineConfig({
__PLATFORM__
:
JSON
.
stringify
(
'
h5
'
),
__APP_VIEW__
:
false
,
__NODE_JS__
:
FORMAT
===
'
cjs
'
?
true
:
false
,
__X__
:
isX
,
},
resolve
:
{
alias
:
[
...
...
@@ -120,6 +121,7 @@ export default defineConfig({
assetsDir
:
'
.
'
,
rollupOptions
:
{
output
:
{
dir
:
isX
?
'
dist-x
'
:
'
dist
'
,
freeze
:
false
,
// uni 对象需要可被修改
entryFileNames
:
'
uni-h5.
'
+
FORMAT
+
'
.js
'
,
},
...
...
scripts/build.js
浏览文件 @
f2138ec8
...
...
@@ -146,6 +146,26 @@ async function build(target) {
{
stdio
:
'
inherit
'
,
env
:
Object
.
assign
({
FORMAT
:
'
cjs
'
},
process
.
env
),
cwd
:
pkgDir
,
}
)
// uni-h5(uni-app x)
await
execa
(
'
vite
'
,
[
'
build
'
,
'
--config
'
,
path
.
resolve
(
pkgDir
,
'
vite.config.ts
'
)],
{
stdio
:
'
inherit
'
,
env
:
Object
.
assign
({
FORMAT
:
'
es
'
,
UNI_APP_X
:
'
true
'
},
process
.
env
,
env
),
cwd
:
pkgDir
,
}
)
await
execa
(
'
vite
'
,
[
'
build
'
,
'
--config
'
,
path
.
resolve
(
pkgDir
,
'
vite.config.ts
'
)],
{
stdio
:
'
inherit
'
,
env
:
Object
.
assign
({
FORMAT
:
'
cjs
'
,
UNI_APP_X
:
'
true
'
},
process
.
env
,
env
),
cwd
:
pkgDir
,
}
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录