@zfqh/uview-x 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +83 -149
- package/components/uv-badge/uv-badge.vue +5 -3
- package/components/uv-button/uv-button.vue +2 -2
- package/components/uv-checkbox/uv-checkbox.vue +0 -3
- package/components/uv-checkbox-group/uv-checkbox-group.vue +0 -3
- package/components/uv-dialog/uv-dialog.vue +1 -3
- package/components/uv-form/uv-form.vue +0 -2
- package/components/uv-form-item/uv-form-item.vue +1 -2
- package/components/uv-icon/uv-icon.vue +6 -6
- package/components/uv-input/uv-input.vue +1 -2
- package/components/uv-line-progress/uv-line-progress.vue +0 -2
- package/components/uv-loading-icon/uv-loading-icon.vue +1 -2
- package/components/uv-overlay/uv-overlay.vue +0 -2
- package/components/uv-popup/uv-popup.vue +0 -2
- package/components/uv-safe-bottom/uv-safe-bottom.vue +0 -2
- package/components/uv-status-bar/uv-status-bar.vue +0 -2
- package/components/uv-tabs/uv-tabs.vue +1 -2
- package/hooks/useI18n.ts +1 -1
- package/index.ts +10 -3
- package/locales/{en.ts → en-US.ts} +6 -5
- package/locales/es-ES.ts +79 -0
- package/locales/fr-FR.ts +79 -0
- package/locales/index.ts +166 -169
- package/locales/ru-RU.ts +79 -0
- package/locales/{zh-Hans.ts → zh-CN.ts} +5 -4
- package/locales/zh-TW.ts +79 -0
- package/package.json +2 -3
- package/styles/common.scss +148 -134
- package/styles/index.scss +4 -7
- package/styles/reset.scss +25 -0
- package/styles/theme.scss +40 -44
- package/styles/var.module.scss +1 -1
- package/types/index.d.ts +5 -12
- package/utils/config.ts +18 -13
- package/utils/function.ts +12 -11
- package/utils/index.ts +1 -0
- package/utils/locale.ts +35 -61
- package/utils/scrollbar.ts +181 -0
- package/styles/color.scss +0 -33
- package/styles/components.scss +0 -19
- package/styles/vue.scss +0 -39
- package/theme.scss +0 -2
package/utils/locale.ts
CHANGED
|
@@ -2,10 +2,13 @@ import { ref } from 'vue';
|
|
|
2
2
|
import type { Ref } from 'vue';
|
|
3
3
|
import { createI18n as _createI18n } from 'vue-i18n';
|
|
4
4
|
import type { I18n, I18nOptions } from 'vue-i18n';
|
|
5
|
-
import { getBuiltinMessage,
|
|
5
|
+
import { getBuiltinMessage, mergeDefaultMessages } from '../locales';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* 国际化能力(默认中文 + 可选语言包 + 4 个公共 API)。
|
|
9
|
+
*
|
|
10
|
+
* 默认语言只有简体中文(`zh-CN`),`createI18n` 只注入并深合并内置中文;
|
|
11
|
+
* 英文等其他语言为独立语言包(`locales/en-US.ts`),由使用方显式引入后合并进 `messages`。
|
|
9
12
|
*
|
|
10
13
|
* 公共 API(由 `utils/index.ts` 导出到包入口):
|
|
11
14
|
* `createI18n`、`getLocale`、`getLocaleMessage`、`setLocale`。
|
|
@@ -32,45 +35,17 @@ interface RefLike<T> {
|
|
|
32
35
|
value: T;
|
|
33
36
|
}
|
|
34
37
|
|
|
35
|
-
/**
|
|
36
|
-
* `uni` 全局对象的最小运行时视图(含 i18n 实例挂载点)。
|
|
37
|
-
*
|
|
38
|
-
* 对外 `$i18n` 声明在 `types/index.d.ts`;这里再留一份最小结构,保证其他包深引用
|
|
39
|
-
* `@zfqh/uview-x/utils/locale`(不会加载本包 types 入口)时仍能编译。
|
|
40
|
-
* 纯 Node / 单测环境可能没有 `uni` 全局,所有访问都要容错。
|
|
41
|
-
*/
|
|
42
|
-
interface UniWithI18n {
|
|
43
|
-
$i18n?: I18n;
|
|
44
|
-
getStorageSync?: (key: string) => unknown;
|
|
45
|
-
setStorageSync?: (key: string, value: unknown) => void;
|
|
46
|
-
getLocale?: () => string;
|
|
47
|
-
setLocale?: (locale: string) => void;
|
|
48
|
-
getAppBaseInfo?: () => { appLanguage?: string; language?: string };
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** 读取 uni 全局对象;不存在时返回 undefined */
|
|
52
|
-
function getUni(): UniWithI18n | undefined {
|
|
53
|
-
return typeof uni === 'undefined' ? undefined : (uni as unknown as UniWithI18n);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** 读取挂到 `uni.$i18n` 上的 i18n 实例 */
|
|
57
|
-
function getUniI18n(): I18n | undefined {
|
|
58
|
-
const uniApi = getUni();
|
|
59
|
-
return uniApi ? uniApi.$i18n : undefined;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
38
|
/** 语言持久化 key:App 端切换语言可能触发重启,必须先落盘 */
|
|
63
39
|
const STORAGE_KEY = 'UNI_LOCALE';
|
|
64
40
|
|
|
65
41
|
/** 回退语言(内部使用,不对外导出) */
|
|
66
|
-
const fallbackLocale = 'zh-
|
|
42
|
+
const fallbackLocale = 'zh-CN';
|
|
67
43
|
|
|
68
44
|
/** 读取上次选择的语言;storage 不可用或无有效值时返回空字符串 */
|
|
69
45
|
function readStorageLocale(): string {
|
|
70
|
-
|
|
71
|
-
if (uniApi && typeof uniApi.getStorageSync === 'function') {
|
|
46
|
+
if (typeof uni !== 'undefined' && typeof uni.getStorageSync === 'function') {
|
|
72
47
|
try {
|
|
73
|
-
const stored: unknown =
|
|
48
|
+
const stored: unknown = uni.getStorageSync(STORAGE_KEY);
|
|
74
49
|
if (typeof stored === 'string' && stored) {
|
|
75
50
|
return stored;
|
|
76
51
|
}
|
|
@@ -99,26 +74,19 @@ function readStorageLocale(): string {
|
|
|
99
74
|
*
|
|
100
75
|
* 顺序:
|
|
101
76
|
* 1. 本地存储 `UNI_LOCALE`(用户上次通过 `setLocale` 选择的语言);
|
|
102
|
-
* 2. `uni.
|
|
103
|
-
* 3. `uni.getAppBaseInfo().
|
|
104
|
-
* 4. `uni.getAppBaseInfo().
|
|
105
|
-
* 5. `zh-
|
|
77
|
+
* 2. `uni.getAppBaseInfo().language`;
|
|
78
|
+
* 3. `uni.getAppBaseInfo().osLanguage`;
|
|
79
|
+
* 4. `uni.getAppBaseInfo().hostLanguage`;
|
|
80
|
+
* 5. `zh-CN`。
|
|
106
81
|
*/
|
|
107
82
|
export function getLocale(): string {
|
|
108
83
|
const stored = readStorageLocale();
|
|
109
84
|
if (stored) {
|
|
110
85
|
return stored;
|
|
111
86
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const systemLocale =
|
|
115
|
-
if (systemLocale) {
|
|
116
|
-
return systemLocale;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (uniApi && typeof uniApi.getAppBaseInfo === 'function') {
|
|
120
|
-
const info = uniApi.getAppBaseInfo();
|
|
121
|
-
const systemLocale = info.appLanguage || info.language;
|
|
87
|
+
if (typeof uni !== 'undefined' && typeof uni.getAppBaseInfo === 'function') {
|
|
88
|
+
const info = uni.getAppBaseInfo() as { language?: string; osLanguage?: string; hostLanguage?: string };
|
|
89
|
+
const systemLocale = info.language || info.osLanguage || info.hostLanguage;
|
|
122
90
|
if (systemLocale) {
|
|
123
91
|
return systemLocale;
|
|
124
92
|
}
|
|
@@ -154,7 +122,10 @@ function isI18nGlobalLike(value: unknown): value is I18nGlobalLike {
|
|
|
154
122
|
|
|
155
123
|
/** 当前 `uni.$i18n.global` 的运行时视图;实例不存在时返回 undefined */
|
|
156
124
|
export function getI18nGlobal(): I18nGlobalLike | undefined {
|
|
157
|
-
|
|
125
|
+
if (typeof uni === 'undefined') {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
const global = uni.$i18n?.global;
|
|
158
129
|
return isI18nGlobalLike(global) ? global : undefined;
|
|
159
130
|
}
|
|
160
131
|
|
|
@@ -186,8 +157,9 @@ function getMessage(messages: I18nMessages, locale: string, key: string): string
|
|
|
186
157
|
/**
|
|
187
158
|
* 翻译(App / 小程序 / 无 i18n 实例时的统一实现)。
|
|
188
159
|
*
|
|
189
|
-
* locale 优先级:storage `UNI_LOCALE` → `uni.$i18n.global.locale` → 内部 `localeState` → `zh-
|
|
190
|
-
* 消息优先级:全局语言包(当前语言 →
|
|
160
|
+
* locale 优先级:storage `UNI_LOCALE` → `uni.$i18n.global.locale` → 内部 `localeState` → `zh-CN`;
|
|
161
|
+
* 消息优先级:全局语言包(当前语言 → 中文回退)→ 内置中文默认语言包 → key。
|
|
162
|
+
* 其他语言(如英文)由使用方在 `createI18n` 中显式合并,未合并时回退中文。
|
|
191
163
|
* storage 优先用于 nvue 等页面上下文模块副本不同、实例未共享的场景(setLocale 已先落盘)。
|
|
192
164
|
*/
|
|
193
165
|
export function appTranslate(key: string, values?: Record<string, string | number>): string {
|
|
@@ -206,14 +178,18 @@ export function appTranslate(key: string, values?: Record<string, string | numbe
|
|
|
206
178
|
/**
|
|
207
179
|
* 创建 i18n 实例并挂到 `uni.$i18n`。
|
|
208
180
|
*
|
|
209
|
-
* -
|
|
181
|
+
* - 只注入内置默认中文:`mergeDefaultMessages(opts.messages)` 仅深合并 `zh-CN`,
|
|
182
|
+
* 用户同名 key 优先;其他 locale(如显式引入的 `en-US`)原样透传,不做内置补全;
|
|
183
|
+
* - 未显式传 `fallbackLocale` 时默认 `zh-CN`,未合并的语言回退中文;
|
|
210
184
|
* - App 端不依赖 vue-i18n 注入,直接把 `global.t` 替换为包内 `appTranslate`;
|
|
211
185
|
* - 用 `opts.locale` 初始化内部 `localeState`,无实例时也能保持语言一致。
|
|
212
186
|
*/
|
|
213
187
|
export function createI18n(opts: I18nOptions): I18n {
|
|
214
|
-
const mergedMessages: I18nMessages =
|
|
188
|
+
const mergedMessages: I18nMessages = mergeDefaultMessages(opts.messages as I18nMessages | undefined);
|
|
215
189
|
const mergedOptions: I18nOptions = {
|
|
216
190
|
...opts,
|
|
191
|
+
// 默认回退中文;显式传入的值(含 false)优先
|
|
192
|
+
fallbackLocale: opts.fallbackLocale ?? fallbackLocale,
|
|
217
193
|
// #ifdef WEB || H5
|
|
218
194
|
// vue-i18n 9.1.9 的 globalInjection 默认 false;H5 开启后 app.use(i18n) 会注入
|
|
219
195
|
// `app.config.globalProperties.$i18n`,useI18n 才能检测到实例并走 vue-i18n 分支
|
|
@@ -226,9 +202,8 @@ export function createI18n(opts: I18nOptions): I18n {
|
|
|
226
202
|
// #ifdef APP
|
|
227
203
|
i18n.global.t = appTranslate as unknown as typeof i18n.global.t;
|
|
228
204
|
// #endif
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
uniApi.$i18n = i18n;
|
|
205
|
+
if (typeof uni !== 'undefined') {
|
|
206
|
+
uni.$i18n = i18n;
|
|
232
207
|
}
|
|
233
208
|
if (typeof opts.locale === 'string' && opts.locale) {
|
|
234
209
|
localeState.value = opts.locale;
|
|
@@ -269,17 +244,16 @@ export function setLocale(locale: string): void {
|
|
|
269
244
|
// 实例不可写时忽略,继续持久化
|
|
270
245
|
}
|
|
271
246
|
}
|
|
272
|
-
|
|
273
|
-
if (uniApi && typeof uniApi.setStorageSync === 'function') {
|
|
247
|
+
if (typeof uni !== 'undefined' && typeof uni.setStorageSync === 'function') {
|
|
274
248
|
try {
|
|
275
|
-
|
|
249
|
+
uni.setStorageSync(STORAGE_KEY, locale);
|
|
276
250
|
} catch (e) {
|
|
277
251
|
// storage 不可用时忽略
|
|
278
252
|
}
|
|
279
253
|
}
|
|
280
|
-
if (
|
|
254
|
+
if (typeof uni !== 'undefined' && typeof uni.setLocale === 'function') {
|
|
281
255
|
try {
|
|
282
|
-
|
|
256
|
+
uni.setLocale(locale);
|
|
283
257
|
} catch (e) {
|
|
284
258
|
// App 端 setLocale 可能触发重启 / 平台不支持,忽略
|
|
285
259
|
}
|
|
@@ -288,7 +262,7 @@ export function setLocale(locale: string): void {
|
|
|
288
262
|
|
|
289
263
|
/**
|
|
290
264
|
* 按当前语言取词(公共 API)。
|
|
291
|
-
* 统一走 `appTranslate`(优先读 `uni.$i18n`
|
|
265
|
+
* 统一走 `appTranslate`(优先读 `uni.$i18n` 语言包,其次默认中文语言包),
|
|
292
266
|
* 避免小程序端 vue-i18n runtime-only 构建缺少消息编译器导致翻译空白 / 占位符不插值。
|
|
293
267
|
*/
|
|
294
268
|
export function getLocaleMessage(key: string, values?: Record<string, string | number>): string {
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* H5 全局滚动条样式(仅 H5 运行时注入)。
|
|
3
|
+
*
|
|
4
|
+
* - `false`(默认):隐藏滚动条(保持原 reset 的默认效果);
|
|
5
|
+
* - `true`:使用默认滚动条样式;
|
|
6
|
+
* - 对象:在默认样式基础上覆盖 `::-webkit-scrollbar` 及其 thumb / track。
|
|
7
|
+
*
|
|
8
|
+
* 注入入口见 `index.ts` 的 `install`(H5 条件编译)。
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** 单组滚动条 CSS 样式:camelCase / kebab-case 均可;number 默认按 px 处理(无单位属性除外) */
|
|
12
|
+
export type UviewXScrollbarStyle = Record<string, string | number>;
|
|
13
|
+
|
|
14
|
+
/** 滚动条自定义样式:默认合并 / 扩展 ::-webkit-scrollbar 及其 thumb / track */
|
|
15
|
+
export interface UviewXScrollbarOptions {
|
|
16
|
+
/** ::-webkit-scrollbar-thumb 样式,覆盖默认 thumb 样式 */
|
|
17
|
+
thumb?: UviewXScrollbarStyle;
|
|
18
|
+
/** ::-webkit-scrollbar-track 样式,覆盖默认 track 样式 */
|
|
19
|
+
track?: UviewXScrollbarStyle;
|
|
20
|
+
/** 其余键作为 ::-webkit-scrollbar 样式,覆盖默认宽高 */
|
|
21
|
+
[property: string]: string | number | UviewXScrollbarStyle | undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type UviewXScrollbar = boolean | UviewXScrollbarOptions;
|
|
25
|
+
|
|
26
|
+
/** 注入到 `<style>` 的元素 id;重复设置时替换同一节点 */
|
|
27
|
+
const SCROLLBAR_STYLE_ID = 'uv-scrollbar-style';
|
|
28
|
+
|
|
29
|
+
/** `false`:隐藏滚动条 */
|
|
30
|
+
const HIDDEN_SCROLLBAR_STYLE: UviewXScrollbarStyle = {
|
|
31
|
+
display: 'none',
|
|
32
|
+
width: '0 !important',
|
|
33
|
+
height: '0 !important',
|
|
34
|
+
WebkitAppearance: 'none',
|
|
35
|
+
background: 'transparent',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** `true` / 对象的默认基础样式 */
|
|
39
|
+
const DEFAULT_SCROLLBAR_STYLE: UviewXScrollbarStyle = {
|
|
40
|
+
width: 6,
|
|
41
|
+
height: 6,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const DEFAULT_SCROLLBAR_THUMB_STYLE: UviewXScrollbarStyle = {
|
|
45
|
+
background: '#c0c4cc',
|
|
46
|
+
borderRadius: 3,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const DEFAULT_SCROLLBAR_TRACK_STYLE: UviewXScrollbarStyle = {
|
|
50
|
+
background: 'transparent',
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** 数值不补 px 的 CSS 属性(已转换为 kebab-case) */
|
|
54
|
+
const UNITLESS_PROPERTIES = new Set([
|
|
55
|
+
'opacity',
|
|
56
|
+
'z-index',
|
|
57
|
+
'font-weight',
|
|
58
|
+
'line-height',
|
|
59
|
+
'flex',
|
|
60
|
+
'flex-grow',
|
|
61
|
+
'flex-shrink',
|
|
62
|
+
'order',
|
|
63
|
+
'zoom',
|
|
64
|
+
'animation-iteration-count',
|
|
65
|
+
'column-count',
|
|
66
|
+
'tab-size',
|
|
67
|
+
]);
|
|
68
|
+
|
|
69
|
+
/** camelCase → kebab-case;已是 kebab-case 的属性保持不变 */
|
|
70
|
+
function toKebabCase(property: string): string {
|
|
71
|
+
return property.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function formatStyleValue(property: string, value: string | number): string {
|
|
75
|
+
if (typeof value === 'number' && !UNITLESS_PROPERTIES.has(toKebabCase(property))) {
|
|
76
|
+
return `${value}px`;
|
|
77
|
+
}
|
|
78
|
+
return String(value);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** 把样式对象转换为 CSS 声明串 */
|
|
82
|
+
function styleToDeclarations(style: UviewXScrollbarStyle): string {
|
|
83
|
+
const declarations: string[] = [];
|
|
84
|
+
for (const property of Object.keys(style)) {
|
|
85
|
+
const value = style[property];
|
|
86
|
+
if (typeof value !== 'string' && typeof value !== 'number') {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
declarations.push(`${toKebabCase(property)}: ${formatStyleValue(property, value)};`);
|
|
90
|
+
}
|
|
91
|
+
return declarations.join(' ');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function toRule(selector: string, style: UviewXScrollbarStyle): string {
|
|
95
|
+
const declarations = styleToDeclarations(style);
|
|
96
|
+
return declarations ? `${selector} { ${declarations} }` : '';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function isScrollbarStyle(value: unknown): value is UviewXScrollbarStyle {
|
|
100
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function mergeScrollbarStyle(base: UviewXScrollbarStyle, override?: UviewXScrollbarStyle): UviewXScrollbarStyle {
|
|
104
|
+
return override ? { ...base, ...override } : { ...base };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* 生成滚动条 CSS。
|
|
109
|
+
*
|
|
110
|
+
* - `false` / `undefined`:隐藏滚动条;
|
|
111
|
+
* - `true`:默认滚动条样式;
|
|
112
|
+
* - 对象:默认样式 + 用户覆盖;空对象等价 `true`。
|
|
113
|
+
*/
|
|
114
|
+
export function buildScrollbarCss(scrollbar: UviewXScrollbar): string {
|
|
115
|
+
if (!scrollbar) {
|
|
116
|
+
return toRule('::-webkit-scrollbar', HIDDEN_SCROLLBAR_STYLE);
|
|
117
|
+
}
|
|
118
|
+
if (scrollbar === true) {
|
|
119
|
+
return [
|
|
120
|
+
toRule('::-webkit-scrollbar', DEFAULT_SCROLLBAR_STYLE),
|
|
121
|
+
toRule('::-webkit-scrollbar-thumb', DEFAULT_SCROLLBAR_THUMB_STYLE),
|
|
122
|
+
toRule('::-webkit-scrollbar-track', DEFAULT_SCROLLBAR_TRACK_STYLE),
|
|
123
|
+
]
|
|
124
|
+
.filter(Boolean)
|
|
125
|
+
.join('\n');
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 自定义样式:`thumb` / `track` 之外的键作为基础样式
|
|
129
|
+
const baseOverride: UviewXScrollbarStyle = {};
|
|
130
|
+
let thumbOverride: UviewXScrollbarStyle | undefined;
|
|
131
|
+
let trackOverride: UviewXScrollbarStyle | undefined;
|
|
132
|
+
for (const property of Object.keys(scrollbar)) {
|
|
133
|
+
const value = scrollbar[property];
|
|
134
|
+
if (property === 'thumb' || property === 'track') {
|
|
135
|
+
if (isScrollbarStyle(value)) {
|
|
136
|
+
if (property === 'thumb') {
|
|
137
|
+
thumbOverride = value;
|
|
138
|
+
} else {
|
|
139
|
+
trackOverride = value;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
145
|
+
baseOverride[property] = value;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return [
|
|
150
|
+
toRule('::-webkit-scrollbar', mergeScrollbarStyle(DEFAULT_SCROLLBAR_STYLE, baseOverride)),
|
|
151
|
+
toRule('::-webkit-scrollbar-thumb', mergeScrollbarStyle(DEFAULT_SCROLLBAR_THUMB_STYLE, thumbOverride)),
|
|
152
|
+
toRule('::-webkit-scrollbar-track', mergeScrollbarStyle(DEFAULT_SCROLLBAR_TRACK_STYLE, trackOverride)),
|
|
153
|
+
]
|
|
154
|
+
.filter(Boolean)
|
|
155
|
+
.join('\n');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* 应用 H5 滚动条样式:替换 `#uv-scrollbar-style` 节点;其它平台不会注入任何代码。
|
|
160
|
+
*
|
|
161
|
+
* `document` 不存在(SSR / Node 单测)时静默返回。
|
|
162
|
+
*/
|
|
163
|
+
export function applyScrollbar(scrollbar: UviewXScrollbar): void {
|
|
164
|
+
// #ifdef WEB || H5
|
|
165
|
+
if (typeof document === 'undefined' || !document.head) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const existing = document.getElementById(SCROLLBAR_STYLE_ID);
|
|
169
|
+
if (existing && existing.parentNode) {
|
|
170
|
+
existing.parentNode.removeChild(existing);
|
|
171
|
+
}
|
|
172
|
+
const css = buildScrollbarCss(scrollbar);
|
|
173
|
+
if (!css) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const styleElement = document.createElement('style');
|
|
177
|
+
styleElement.id = SCROLLBAR_STYLE_ID;
|
|
178
|
+
styleElement.textContent = css;
|
|
179
|
+
document.head.appendChild(styleElement);
|
|
180
|
+
// #endif
|
|
181
|
+
}
|
package/styles/color.scss
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
$uv-main-color: #333333 !default;
|
|
2
|
-
$uv-content-color: #7a7a7a !default;
|
|
3
|
-
$uv-tips-color: #9a9a9a !default;
|
|
4
|
-
$uv-light-color: #c0c4cc !default;
|
|
5
|
-
$uv-border-color: #eeeeee !default;
|
|
6
|
-
$uv-bg-color: #f5f5f5 !default;
|
|
7
|
-
$uv-bg-light-color: #fffbf4 !default;
|
|
8
|
-
$uv-disabled-color: #c8c9cc !default;
|
|
9
|
-
|
|
10
|
-
$uv-primary: #00b4c3 !default;
|
|
11
|
-
$uv-primary-dark: #157572 !default;
|
|
12
|
-
$uv-primary-disabled: #b4e3d9 !default;
|
|
13
|
-
$uv-primary-light: #dff3f9 !default;
|
|
14
|
-
|
|
15
|
-
$uv-warning: #ff9a05 !default;
|
|
16
|
-
$uv-warning-dark: #ed6c04 !default;
|
|
17
|
-
$uv-warning-disabled: #f9d39b !default;
|
|
18
|
-
$uv-warning-light: #fdf6ec !default;
|
|
19
|
-
|
|
20
|
-
$uv-success: #5ac725 !default;
|
|
21
|
-
$uv-success-dark: #53c21d !default;
|
|
22
|
-
$uv-success-disabled: #a9e08f !default;
|
|
23
|
-
$uv-success-light: #f5fff0 !default;
|
|
24
|
-
|
|
25
|
-
$uv-error: #ff4d4f !default;
|
|
26
|
-
$uv-error-dark: #e45656 !default;
|
|
27
|
-
$uv-error-disabled: #f7b2b2 !default;
|
|
28
|
-
$uv-error-light: #fef0f0 !default;
|
|
29
|
-
|
|
30
|
-
$uv-info: #909399 !default;
|
|
31
|
-
$uv-info-dark: #767a82 !default;
|
|
32
|
-
$uv-info-disabled: #c4c6c9 !default;
|
|
33
|
-
$uv-info-light: #f4f4f5 !default;
|
package/styles/components.scss
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// uview-x 组件样式基础 mixin。
|
|
2
|
-
//
|
|
3
|
-
// 注意:这里只允许输出“编译期可消解”的 SCSS 或扁平 class 规则。
|
|
4
|
-
// uni-app x App 蒸汽模式不支持元素选择器、后代选择器、伪类/伪元素,
|
|
5
|
-
// 因此原 uv-ui 中的 view/scroll-view 全局重置必须放在 index.scss 的
|
|
6
|
-
// WEB / MP 条件块中,不能出现在每个组件的 style 里。
|
|
7
|
-
@mixin flex($direction: row) {
|
|
8
|
-
/* #ifndef APP-NVUE */
|
|
9
|
-
display: flex;
|
|
10
|
-
/* #endif */
|
|
11
|
-
flex-direction: $direction;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// 细边框(用于需要显式声明边框的场景,调用方自行控制 class)
|
|
15
|
-
@mixin border-1px($color: #dadbde) {
|
|
16
|
-
border-width: 0.5px;
|
|
17
|
-
border-color: $color;
|
|
18
|
-
border-style: solid;
|
|
19
|
-
}
|
package/styles/vue.scss
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// 全局辅助样式(x-safe)。
|
|
2
|
-
//
|
|
3
|
-
// App 蒸汽模式不支持元素选择器、伪元素、后代选择器;
|
|
4
|
-
// Web/小程序不需要这些限制,相关规则保留在条件编译块中。
|
|
5
|
-
|
|
6
|
-
// 四个方向的安全区
|
|
7
|
-
@each $d in top, right, bottom, left {
|
|
8
|
-
.uv-safe-area-inset-#{$d} {
|
|
9
|
-
padding-#{$d}: 0;
|
|
10
|
-
/* #ifdef APP */
|
|
11
|
-
padding-#{$d}: var(--uni-safe-area-inset-#{$d}, 0px);
|
|
12
|
-
/* #endif */
|
|
13
|
-
/* #ifdef WEB || H5 || MP */
|
|
14
|
-
padding-#{$d}: constant(safe-area-inset-#{$d});
|
|
15
|
-
padding-#{$d}: env(safe-area-inset-#{$d});
|
|
16
|
-
/* #endif */
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/* #ifdef WEB || H5 */
|
|
21
|
-
// 提升 H5 端 uni.toast() 的层级,避免被弹层遮盖
|
|
22
|
-
uni-toast {
|
|
23
|
-
z-index: 10090;
|
|
24
|
-
}
|
|
25
|
-
uni-toast .uni-toast {
|
|
26
|
-
z-index: 10090;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// 隐藏 scroll-view 滚动条
|
|
30
|
-
::-webkit-scrollbar {
|
|
31
|
-
display: none;
|
|
32
|
-
width: 0 !important;
|
|
33
|
-
height: 0 !important;
|
|
34
|
-
-webkit-appearance: none;
|
|
35
|
-
background: transparent;
|
|
36
|
-
}
|
|
37
|
-
/* #endif */
|
|
38
|
-
|
|
39
|
-
|
package/theme.scss
DELETED