diff --git a/.github/ISSUE_TEMPLATE/bug_report_template.yml b/.github/ISSUE_TEMPLATE/bug_report_template.yml
index 1a37f368c3..59aa3154f7 100644
--- a/.github/ISSUE_TEMPLATE/bug_report_template.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report_template.yml
@@ -21,8 +21,8 @@ body:
multiple: true
description: 选择使用的 NutUI NPM 包名
options:
- - "@nutui/nutui"
- - "@nutui/nutui-taro"
+ - '@nutui/nutui'
+ - '@nutui/nutui-taro'
validations:
required: true
@@ -76,7 +76,7 @@ body:
label: 重现步骤
description: |
简洁清晰的重现步骤能够帮助我们更迅速地定位问题所在。
-
+
请使用 Markdown 语法格式化步骤中涉及的列表、代码片段等,否则它将会非常丑陋。
validations:
required: true
diff --git a/.github/ISSUE_TEMPLATE/feature_request_template.yml b/.github/ISSUE_TEMPLATE/feature_request_template.yml
index 45cb2b4d4f..b1b26db03d 100644
--- a/.github/ISSUE_TEMPLATE/feature_request_template.yml
+++ b/.github/ISSUE_TEMPLATE/feature_request_template.yml
@@ -1,7 +1,7 @@
name: 🚀 新功能请求 Feature Request
description: 对组件库或者仓库本身的建议和想法。
-title: "[FR]: "
-labels: ["Feature Request"]
+title: '[FR]: '
+labels: ['Feature Request']
body:
- type: markdown
attributes:
@@ -13,7 +13,7 @@ body:
- 查看组件文档 [@nutui/nutui](https://nutui.jd.com/h5/vue/4x/#/zh-CN/guide/intro) [@nutui/nutui-taro](https://nutui.jd.com/taro/vue/4x/#/zh-CN/guide/intro)
- 在 [Issue](https://github.com/jdf2e/nutui/issues) 列表中查找解决方案
- 查看 [常见问题 QA](https://github.com/jdf2e/nutui/issues/2461)
-
+
- type: dropdown
id: npm
attributes:
@@ -21,8 +21,8 @@ body:
multiple: true
description: 选择使用的 NutUI NPM 包名
options:
- - "@nutui/nutui"
- - "@nutui/nutui-taro"
+ - '@nutui/nutui'
+ - '@nutui/nutui-taro'
validations:
required: true
diff --git a/.github/renovate.json b/.github/renovate.json
index 5137001ae8..f7a2b6d34a 100644
--- a/.github/renovate.json
+++ b/.github/renovate.json
@@ -1,25 +1,14 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
- "extends": [
- "config:base", "schedule:weekly", "group:allNonMajor"
- ],
+ "extends": ["config:base", "schedule:weekly", "group:allNonMajor"],
"rangeStrategy": "bump",
"labels": ["dependencies"],
- "ignorePaths": [
- "src/**",
- "publish/**",
- "packages/nutui-vscode-extension/**"
- ],
+ "ignorePaths": ["src/**", "publish/**", "packages/nutui-vscode-extension/**"],
"packageRules": [
{
"matchPackagePatterns": ["^@tarojs"],
"enabled": false
}
],
- "ignoreDeps": [
- "eslint-config-taro",
- "babel-preset-taro",
- "node",
- "typescript"
- ]
+ "ignoreDeps": ["eslint-config-taro", "babel-preset-taro", "node", "typescript"]
}
diff --git a/.github/workflows/issue-close.yml b/.github/workflows/issue-close.yml
index 9e35112c8b..8cdc948a33 100644
--- a/.github/workflows/issue-close.yml
+++ b/.github/workflows/issue-close.yml
@@ -2,7 +2,7 @@ name: Close Issue
on:
schedule:
- - cron: "0 2 * * 1"
+ - cron: '0 2 * * 1'
workflow_dispatch: # Allow for running this manually.
jobs:
diff --git a/.github/workflows/publish-beta.yml b/.github/workflows/publish-beta.yml
index 239dad01c0..71c1a34e87 100644
--- a/.github/workflows/publish-beta.yml
+++ b/.github/workflows/publish-beta.yml
@@ -21,11 +21,11 @@ jobs:
with:
node-version: '18'
cache: 'pnpm'
- registry-url: "https://registry.npmjs.org"
+ registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: pnpm install
-
+
- name: Build NutUI Vue
run: pnpm build
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 5593938cff..a22da8f339 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -23,11 +23,11 @@ jobs:
with:
node-version: '18'
cache: 'pnpm'
- registry-url: "https://registry.npmjs.org"
+ registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: pnpm install
-
+
- name: Build NutUI Vue
run: pnpm build
diff --git a/.github/workflows/sync-pkg.yml b/.github/workflows/sync-pkg.yml
index d9c63ed344..2233045250 100644
--- a/.github/workflows/sync-pkg.yml
+++ b/.github/workflows/sync-pkg.yml
@@ -28,7 +28,7 @@ jobs:
- name: Build @nutui/nutui
run: pnpm build
-
+
- name: Build @nutui/nutui-taro
run: pnpm build:taro
diff --git a/.prettierrc b/.prettierrc
index 2538d0717e..f6f0690340 100644
--- a/.prettierrc
+++ b/.prettierrc
@@ -1,6 +1,6 @@
{
"singleQuote": true,
- "semi": true,
+ "semi": false,
"bracketSpacing": true,
"tabWidth": 2,
"useTabs": false,
diff --git a/commitlint.config.cjs b/commitlint.config.cjs
index 1020c6833d..3270c10ef8 100644
--- a/commitlint.config.cjs
+++ b/commitlint.config.cjs
@@ -16,4 +16,4 @@ module.exports = {
['upd', 'chore', 'docs', 'feat', 'fix', 'test', 'refactor', 'revert', 'style', 'release', 'perf']
]
}
-};
+}
diff --git a/packages/nutui-auto-import-resolver/README.zh-CN.md b/packages/nutui-auto-import-resolver/README.zh-CN.md
index d5d01a80b0..2c99c9731b 100644
--- a/packages/nutui-auto-import-resolver/README.zh-CN.md
+++ b/packages/nutui-auto-import-resolver/README.zh-CN.md
@@ -32,8 +32,8 @@ bun add @nutui/auto-import-resolver unplugin-vue-components -D
```ts
// vite.config.ts
-import Components from 'unplugin-vue-components/vite';
-import NutUIResolver from '@nutui/auto-import-resolver';
+import Components from 'unplugin-vue-components/vite'
+import NutUIResolver from '@nutui/auto-import-resolver'
export default defineConfig({
plugins: [
@@ -41,15 +41,15 @@ export default defineConfig({
resolvers: [NutUIResolver()]
})
]
-});
+})
```
### Vue CLI
```ts
// vue.config.js
-import Components from 'unplugin-vue-components/webpack';
-const NutUIResolver = require('@nutui/auto-import-resolver');
+import Components from 'unplugin-vue-components/webpack'
+const NutUIResolver = require('@nutui/auto-import-resolver')
module.exports = {
configureWebpack: {
@@ -59,15 +59,15 @@ module.exports = {
})
]
}
-};
+}
```
### Webpack
```ts
// webpack.config.js
-import Components from 'unplugin-vue-components/webpack';
-const NutUIResolver = require('@nutui/auto-import-resolver');
+import Components from 'unplugin-vue-components/webpack'
+const NutUIResolver = require('@nutui/auto-import-resolver')
module.exports = {
plugins: [
@@ -75,7 +75,7 @@ module.exports = {
resolvers: [NutUIResolver()]
})
]
-};
+}
```
## 使用 Sass
@@ -84,8 +84,8 @@ module.exports = {
```ts
// vite.config.ts
-import Components from 'unplugin-vue-components/vite';
-import NutUIResolver from '@nutui/auto-import-resolver';
+import Components from 'unplugin-vue-components/vite'
+import NutUIResolver from '@nutui/auto-import-resolver'
export default defineConfig({
plugins: [
@@ -101,15 +101,15 @@ export default defineConfig({
}
}
}
-});
+})
```
### Vue CLI
```ts
// vue.config.js
-import Components from 'unplugin-vue-components/webpack';
-const NutUIResolver = require('@nutui/auto-import-resolver');
+import Components from 'unplugin-vue-components/webpack'
+const NutUIResolver = require('@nutui/auto-import-resolver')
module.exports = {
configureWebpack: {
@@ -127,15 +127,15 @@ module.exports = {
}
}
}
-};
+}
```
### Webpack
```ts
// webpack.config.js
-import Components from 'unplugin-vue-components/webpack';
-const NutUIResolver = require('@nutui/auto-import-resolver');
+import Components from 'unplugin-vue-components/webpack'
+const NutUIResolver = require('@nutui/auto-import-resolver')
module.exports = {
plugins: [
@@ -161,5 +161,5 @@ module.exports = {
}
]
}
-};
+}
```
diff --git a/packages/nutui-auto-import-resolver/src/index.ts b/packages/nutui-auto-import-resolver/src/index.ts
index 4a8577ab8d..4e9c9a68ea 100644
--- a/packages/nutui-auto-import-resolver/src/index.ts
+++ b/packages/nutui-auto-import-resolver/src/index.ts
@@ -1,4 +1,4 @@
-import type { ComponentResolveResult, ComponentResolver } from 'unplugin-vue-components/types';
+import type { ComponentResolveResult, ComponentResolver } from 'unplugin-vue-components/types'
export interface NutUIResolverOptions {
/**
@@ -6,45 +6,45 @@ export interface NutUIResolverOptions {
*
* @default 'css'
*/
- importStyle?: boolean | 'css' | 'sass';
+ importStyle?: boolean | 'css' | 'sass'
/**
* NutUI or NutUI-Taro
*
* @default false
*/
- taro?: boolean;
+ taro?: boolean
/**
* compatible with unplugin-auto-import
*
* @default false
*/
- autoImport?: boolean;
+ autoImport?: boolean
}
-const nutFunctions = ['showToast', 'showNotify', 'showDialog', 'showImagePreview'];
+const nutFunctions = ['showToast', 'showNotify', 'showDialog', 'showImagePreview']
function getNutResolved(name: string, options: NutUIResolverOptions): ComponentResolveResult {
- const { importStyle = true, taro = false, autoImport = false } = options;
+ const { importStyle = true, taro = false, autoImport = false } = options
- const packageName = taro ? '@nutui/nutui-taro' : '@nutui/nutui';
+ const packageName = taro ? '@nutui/nutui-taro' : '@nutui/nutui'
- if (!importStyle) return { name, from: packageName };
+ if (!importStyle) return { name, from: packageName }
- const componentName = autoImport ? name.slice(4) : name;
+ const componentName = autoImport ? name.slice(4) : name
- let style = `${packageName}/dist/packages/${componentName.toLowerCase()}/style/css`;
+ let style = `${packageName}/dist/packages/${componentName.toLowerCase()}/style/css`
if (importStyle === 'sass') {
- style = `${packageName}/dist/packages/${componentName.toLowerCase()}/style`;
+ style = `${packageName}/dist/packages/${componentName.toLowerCase()}/style`
}
return {
name,
from: packageName,
sideEffects: style
- };
+ }
}
/**
@@ -56,11 +56,11 @@ export default function NutUIResolver(options: NutUIResolverOptions = {}): Compo
return {
type: 'component',
resolve: (name) => {
- const { autoImport = false } = options;
+ const { autoImport = false } = options
- if (autoImport && nutFunctions.includes(name)) return getNutResolved(name, options);
+ if (autoImport && nutFunctions.includes(name)) return getNutResolved(name, options)
- if (name.startsWith('Nut')) return getNutResolved(name.slice(3), options);
+ if (name.startsWith('Nut')) return getNutResolved(name.slice(3), options)
}
- };
+ }
}
diff --git a/packages/nutui-auto-import-resolver/vite.config.ts b/packages/nutui-auto-import-resolver/vite.config.ts
index 9d087141bb..1203b35fbe 100644
--- a/packages/nutui-auto-import-resolver/vite.config.ts
+++ b/packages/nutui-auto-import-resolver/vite.config.ts
@@ -1,4 +1,4 @@
-import { defineConfig } from 'vite';
+import { defineConfig } from 'vite'
export default defineConfig({
build: {
@@ -9,13 +9,13 @@ export default defineConfig({
name: 'name',
fileName: (format) => {
if (format === 'es') {
- return 'index.mjs';
+ return 'index.mjs'
} else {
- return 'index.js';
+ return 'index.js'
}
},
formats: ['es', 'cjs']
},
emptyOutDir: false
}
-});
+})
diff --git a/packages/nutui-eslint-config/index.js b/packages/nutui-eslint-config/index.js
index a7ba58dca8..e9557e1cdb 100644
--- a/packages/nutui-eslint-config/index.js
+++ b/packages/nutui-eslint-config/index.js
@@ -41,4 +41,4 @@ module.exports = {
'vue/multi-word-component-names': 'off',
'vue/no-v-text-v-html-on-component': 'off'
}
-};
+}
diff --git a/packages/nutui-playground/src/App.vue b/packages/nutui-playground/src/App.vue
index 30953abb71..946408b605 100644
--- a/packages/nutui-playground/src/App.vue
+++ b/packages/nutui-playground/src/App.vue
@@ -1,24 +1,24 @@
diff --git a/packages/nutui-playground/src/Header.vue b/packages/nutui-playground/src/Header.vue
index bc992cefdf..1ab7b3c50f 100644
--- a/packages/nutui-playground/src/Header.vue
+++ b/packages/nutui-playground/src/Header.vue
@@ -1,34 +1,34 @@
diff --git a/packages/nutui-playground/src/VersionSelect.vue b/packages/nutui-playground/src/VersionSelect.vue
index ee7dfd25f2..ab2a8ab0ca 100644
--- a/packages/nutui-playground/src/VersionSelect.vue
+++ b/packages/nutui-playground/src/VersionSelect.vue
@@ -1,50 +1,50 @@
diff --git a/packages/nutui-playground/src/download/download.ts b/packages/nutui-playground/src/download/download.ts
index 7f8a92669d..f07a0d59c1 100644
--- a/packages/nutui-playground/src/download/download.ts
+++ b/packages/nutui-playground/src/download/download.ts
@@ -1,33 +1,33 @@
-import { saveAs } from 'file-saver';
+import { saveAs } from 'file-saver'
-import index from './template/index.html?raw';
-import main from './template/main.js?raw';
-import pkg from './template/package.json?raw';
-import config from './template/vite.config.js?raw';
-import readme from './template/README.md?raw';
-import { ReplStore } from '@vue/repl';
+import index from './template/index.html?raw'
+import main from './template/main.js?raw'
+import pkg from './template/package.json?raw'
+import config from './template/vite.config.js?raw'
+import readme from './template/README.md?raw'
+import { ReplStore } from '@vue/repl'
export async function downloadProject(store: ReplStore) {
if (!confirm('Download project files?')) {
- return;
+ return
}
- const { default: JSZip } = await import('jszip');
- const zip = new JSZip();
+ const { default: JSZip } = await import('jszip')
+ const zip = new JSZip()
// basic structure
- zip.file('index.html', index);
- zip.file('package.json', pkg);
- zip.file('vite.config.js', config);
- zip.file('README.md', readme);
+ zip.file('index.html', index)
+ zip.file('package.json', pkg)
+ zip.file('vite.config.js', config)
+ zip.file('README.md', readme)
// project src
- const src = zip.folder('src')!;
- src.file('main.js', main);
+ const src = zip.folder('src')!
+ src.file('main.js', main)
- const files = store.getFiles();
- src.file('App.vue', files['App.vue']);
+ const files = store.getFiles()
+ src.file('App.vue', files['App.vue'])
- const blob = await zip.generateAsync({ type: 'blob' });
- saveAs(blob, 'nutui-project.zip');
+ const blob = await zip.generateAsync({ type: 'blob' })
+ saveAs(blob, 'nutui-project.zip')
}
diff --git a/packages/nutui-playground/src/download/template/main.js b/packages/nutui-playground/src/download/template/main.js
index 8a1ab7f002..b8a4106ccd 100644
--- a/packages/nutui-playground/src/download/template/main.js
+++ b/packages/nutui-playground/src/download/template/main.js
@@ -1,5 +1,5 @@
-import { createApp } from 'vue';
-import App from './App.vue';
-import '@nutui/touch-emulator';
+import { createApp } from 'vue'
+import App from './App.vue'
+import '@nutui/touch-emulator'
-createApp(App).mount('#app');
+createApp(App).mount('#app')
diff --git a/packages/nutui-playground/src/download/template/vite.config.js b/packages/nutui-playground/src/download/template/vite.config.js
index e89f537754..6265a0f792 100644
--- a/packages/nutui-playground/src/download/template/vite.config.js
+++ b/packages/nutui-playground/src/download/template/vite.config.js
@@ -1,8 +1,8 @@
// vite.config.js
-import { defineConfig } from 'vite';
-import vue from '@vitejs/plugin-vue';
-import Components from 'unplugin-vue-components/vite';
-import NutUIResolver from '@nutui/nutui/dist/resolver';
+import { defineConfig } from 'vite'
+import vue from '@vitejs/plugin-vue'
+import Components from 'unplugin-vue-components/vite'
+import NutUIResolver from '@nutui/nutui/dist/resolver'
// https://vitejs.dev/config/
export default defineConfig({
@@ -21,4 +21,4 @@ export default defineConfig({
}
}
}
-});
+})
diff --git a/packages/nutui-playground/src/main.ts b/packages/nutui-playground/src/main.ts
index ada1ad1696..8422420c35 100644
--- a/packages/nutui-playground/src/main.ts
+++ b/packages/nutui-playground/src/main.ts
@@ -1,10 +1,10 @@
-import { createApp } from 'vue';
-import App from './App.vue';
-import './style.css';
+import { createApp } from 'vue'
+import App from './App.vue'
+import './style.css'
// @ts-expect-error Custom window property
window.VUE_DEVTOOLS_CONFIG = {
defaultSelectedAppId: 'repl'
-};
+}
-createApp(App).mount('#app');
+createApp(App).mount('#app')
diff --git a/packages/nutui-playground/src/store.ts b/packages/nutui-playground/src/store.ts
index 5819d85c09..f4bf8bb219 100644
--- a/packages/nutui-playground/src/store.ts
+++ b/packages/nutui-playground/src/store.ts
@@ -1,7 +1,7 @@
-import { StoreOptions, File, ReplStore, compileFile } from '@vue/repl';
-import { ref, computed } from 'vue';
+import { StoreOptions, File, ReplStore, compileFile } from '@vue/repl'
+import { ref, computed } from 'vue'
-const style = ref('https://cdn.jsdelivr.net/npm/@nutui/nutui@latest/dist/style.css');
+const style = ref('https://cdn.jsdelivr.net/npm/@nutui/nutui@latest/dist/style.css')
const appFileCode = `
diff --git a/packages/nutui-taro-demo/src/basic/pages/button/index.config.ts b/packages/nutui-taro-demo/src/basic/pages/button/index.config.ts
index 8c13ec6a43..659e5e8934 100644
--- a/packages/nutui-taro-demo/src/basic/pages/button/index.config.ts
+++ b/packages/nutui-taro-demo/src/basic/pages/button/index.config.ts
@@ -1,3 +1,3 @@
export default {
navigationBarTitleText: 'Button'
-};
+}
diff --git a/packages/nutui-taro-demo/src/basic/pages/button/index.vue b/packages/nutui-taro-demo/src/basic/pages/button/index.vue
index 9983fb3c21..978a053403 100644
--- a/packages/nutui-taro-demo/src/basic/pages/button/index.vue
+++ b/packages/nutui-taro-demo/src/basic/pages/button/index.vue
@@ -30,16 +30,16 @@
diff --git a/packages/nutui-taro-demo/src/exhibition/pages/animate/index.config.ts b/packages/nutui-taro-demo/src/exhibition/pages/animate/index.config.ts
index ff58d94271..c43da808c3 100644
--- a/packages/nutui-taro-demo/src/exhibition/pages/animate/index.config.ts
+++ b/packages/nutui-taro-demo/src/exhibition/pages/animate/index.config.ts
@@ -1 +1 @@
-export default { navigationBarTitleText: 'Animate' };
+export default { navigationBarTitleText: 'Animate' }
diff --git a/packages/nutui-taro-demo/src/exhibition/pages/animate/index.vue b/packages/nutui-taro-demo/src/exhibition/pages/animate/index.vue
index 88676fb697..0306754879 100644
--- a/packages/nutui-taro-demo/src/exhibition/pages/animate/index.vue
+++ b/packages/nutui-taro-demo/src/exhibition/pages/animate/index.vue
@@ -11,10 +11,10 @@
diff --git a/packages/nutui-taro-demo/src/exhibition/pages/list/basic.vue b/packages/nutui-taro-demo/src/exhibition/pages/list/basic.vue
index 75dba97730..1d419adf3d 100644
--- a/packages/nutui-taro-demo/src/exhibition/pages/list/basic.vue
+++ b/packages/nutui-taro-demo/src/exhibition/pages/list/basic.vue
@@ -10,19 +10,19 @@
diff --git a/src/packages/__VUE/avatarcropper/types.ts b/src/packages/__VUE/avatarcropper/types.ts
index 27df244a74..6d63a25c8f 100644
--- a/src/packages/__VUE/avatarcropper/types.ts
+++ b/src/packages/__VUE/avatarcropper/types.ts
@@ -1,4 +1,4 @@
-export type AvatarCropperToolbarPosition = 'top' | 'bottom';
-export type AvatarCropperSizeType = 'original' | 'compressed';
-export type AvatarCropperSourceType = 'album' | 'camera';
-export type AvatarCropperShape = 'square' | 'round';
+export type AvatarCropperToolbarPosition = 'top' | 'bottom'
+export type AvatarCropperSizeType = 'original' | 'compressed'
+export type AvatarCropperSourceType = 'album' | 'camera'
+export type AvatarCropperShape = 'square' | 'round'
diff --git a/src/packages/__VUE/avatargroup/index.taro.vue b/src/packages/__VUE/avatargroup/index.taro.vue
index 2b0ba61d7f..0024cc9699 100644
--- a/src/packages/__VUE/avatargroup/index.taro.vue
+++ b/src/packages/__VUE/avatargroup/index.taro.vue
@@ -15,12 +15,12 @@
diff --git a/src/packages/__VUE/avatargroup/index.vue b/src/packages/__VUE/avatargroup/index.vue
index 2122b6ea71..e8d35234fa 100644
--- a/src/packages/__VUE/avatargroup/index.vue
+++ b/src/packages/__VUE/avatargroup/index.vue
@@ -15,11 +15,11 @@
diff --git a/src/packages/__VUE/backtop/__tests__/backtop.spec.ts b/src/packages/__VUE/backtop/__tests__/backtop.spec.ts
index e61dfbe8fa..83f93211f0 100644
--- a/src/packages/__VUE/backtop/__tests__/backtop.spec.ts
+++ b/src/packages/__VUE/backtop/__tests__/backtop.spec.ts
@@ -1,52 +1,52 @@
-import { mount, config } from '@vue/test-utils';
-import { mockScrollTop } from './../../../utils/unit';
-import { nextTick } from 'vue';
-import { Backtop } from '@nutui/nutui';
-import { Top } from '@nutui/icons-vue';
+import { mount, config } from '@vue/test-utils'
+import { mockScrollTop } from './../../../utils/unit'
+import { nextTick } from 'vue'
+import { Backtop } from '@nutui/nutui'
+import { Top } from '@nutui/icons-vue'
beforeAll(() => {
config.global.components = {
Top
- };
-});
+ }
+})
afterAll(() => {
- config.global.components = {};
-});
+ config.global.components = {}
+})
test('emit click event', () => {
- const wrapper = mount(Backtop);
- wrapper.trigger('click');
- expect(wrapper.emitted('click')!.length).toEqual(1);
-});
+ const wrapper = mount(Backtop)
+ wrapper.trigger('click')
+ expect(wrapper.emitted('click')!.length).toEqual(1)
+})
test('backtop show', () => {
- const wrapper = mount(Backtop);
- const backtop = wrapper.find('.nut-backtop');
- expect(backtop.exists()).toBe(true);
-});
+ const wrapper = mount(Backtop)
+ const backtop = wrapper.find('.nut-backtop')
+ expect(backtop.exists()).toBe(true)
+})
test('backtop style', () => {
const wrapper = mount(Backtop, {
props: {
bottom: 50
}
- });
- const backtop: any = wrapper.find('.nut-backtop');
- expect(backtop.element.style.bottom).toBe('50px');
-});
+ })
+ const backtop: any = wrapper.find('.nut-backtop')
+ expect(backtop.element.style.bottom).toBe('50px')
+})
test('backtop style,backtop show', async () => {
const wrapper = mount(Backtop, {
props: {
right: 40
}
- });
- await mockScrollTop(1000);
- const show: any = wrapper.find('.show');
- expect(show.exists()).toBe(true);
- const backtop: any = wrapper.find('.nut-backtop');
- expect(backtop.element.style.right).toBe('40px');
-});
+ })
+ await mockScrollTop(1000)
+ const show: any = wrapper.find('.show')
+ expect(show.exists()).toBe(true)
+ const backtop: any = wrapper.find('.nut-backtop')
+ expect(backtop.element.style.right).toBe('40px')
+})
test('backtop style', async () => {
const wrapper = mount(Backtop, {
@@ -54,10 +54,10 @@ test('backtop style', async () => {
zIndex: 100,
distance: 0
}
- });
- await nextTick();
- const backtop: any = wrapper.find('.nut-backtop');
- const show: any = wrapper.find('.show');
- expect(backtop.element.style.zIndex).toBe('100');
- expect(show.exists()).toBe(true);
-});
+ })
+ await nextTick()
+ const backtop: any = wrapper.find('.nut-backtop')
+ const show: any = wrapper.find('.show')
+ expect(backtop.element.style.zIndex).toBe('100')
+ expect(show.exists()).toBe(true)
+})
diff --git a/src/packages/__VUE/backtop/backtop.taro.vue b/src/packages/__VUE/backtop/backtop.taro.vue
index e8b172bc17..6a8f4b6665 100644
--- a/src/packages/__VUE/backtop/backtop.taro.vue
+++ b/src/packages/__VUE/backtop/backtop.taro.vue
@@ -18,21 +18,21 @@
diff --git a/src/packages/__VUE/backtop/backtop.vue b/src/packages/__VUE/backtop/backtop.vue
index e50487e5fc..855c56b5e1 100644
--- a/src/packages/__VUE/backtop/backtop.vue
+++ b/src/packages/__VUE/backtop/backtop.vue
@@ -7,23 +7,23 @@
diff --git a/src/packages/__VUE/backtop/demo/basic.vue b/src/packages/__VUE/backtop/demo/basic.vue
index 0f404f5c4a..3a5f4d618c 100644
--- a/src/packages/__VUE/backtop/demo/basic.vue
+++ b/src/packages/__VUE/backtop/demo/basic.vue
@@ -6,8 +6,8 @@
diff --git a/src/packages/__VUE/uploader/doc.en-US.md b/src/packages/__VUE/uploader/doc.en-US.md
index 52930dde72..bd2ef4d317 100644
--- a/src/packages/__VUE/uploader/doc.en-US.md
+++ b/src/packages/__VUE/uploader/doc.en-US.md
@@ -7,11 +7,11 @@ Used to upload local pictures or files to the server.
### Install
```js
-import { createApp } from 'vue';
-import { Uploader } from '@nutui/nutui';
+import { createApp } from 'vue'
+import { Uploader } from '@nutui/nutui'
-const app = createApp();
-app.use(Uploader);
+const app = createApp()
+app.use(Uploader)
```
### Basic Usage
@@ -35,8 +35,8 @@ app.use(Uploader);
```
@@ -76,8 +76,8 @@ const defaultFileList = reactive([
```
@@ -138,14 +138,14 @@ const defaultFileList = reactive([
```
@@ -184,12 +184,12 @@ const onProgress = ({ event, options, percentage }) => {
```
@@ -204,41 +204,41 @@ const onOversize = (files) => {
```
@@ -253,11 +253,11 @@ const beforeUpload = async (file) => {
```
@@ -274,15 +274,15 @@ const formData = {
```
@@ -300,15 +300,15 @@ const beforeXhrUpload = (xhr, options) => {
Clear upload
```
diff --git a/src/packages/__VUE/uploader/doc.md b/src/packages/__VUE/uploader/doc.md
index cee2bb1b9a..40bc5d686d 100644
--- a/src/packages/__VUE/uploader/doc.md
+++ b/src/packages/__VUE/uploader/doc.md
@@ -7,11 +7,11 @@
### 安装
```js
-import { createApp } from 'vue';
-import { Uploader } from '@nutui/nutui';
+import { createApp } from 'vue'
+import { Uploader } from '@nutui/nutui'
-const app = createApp();
-app.use(Uploader);
+const app = createApp()
+app.use(Uploader)
```
### 基础用法
@@ -35,8 +35,8 @@ app.use(Uploader);
```
@@ -76,8 +76,8 @@ const defaultFileList = reactive([
```
@@ -138,14 +138,14 @@ const defaultFileList = reactive([
```
@@ -184,12 +184,12 @@ const onProgress = ({ event, options, percentage }) => {
```
@@ -204,41 +204,41 @@ const onOversize = (files) => {
```
@@ -253,11 +253,11 @@ const beforeUpload = async (file) => {
```
@@ -274,15 +274,15 @@ const formData = {
```
@@ -300,15 +300,15 @@ const beforeXhrUpload = (xhr, options) => {
手动清空上传
```
diff --git a/src/packages/__VUE/uploader/doc.taro.md b/src/packages/__VUE/uploader/doc.taro.md
index 7bd76a5954..c81958f96c 100644
--- a/src/packages/__VUE/uploader/doc.taro.md
+++ b/src/packages/__VUE/uploader/doc.taro.md
@@ -7,11 +7,11 @@
### 安装
```js
-import { createApp } from 'vue';
-import { Uploader } from '@nutui/nutui-taro';
+import { createApp } from 'vue'
+import { Uploader } from '@nutui/nutui-taro'
-const app = createApp();
-app.use(Uploader);
+const app = createApp()
+app.use(Uploader)
```
### 基础用法
@@ -177,12 +177,12 @@ import { ref } from 'vue';
```vue
```
diff --git a/src/packages/__VUE/uploader/index.taro.vue b/src/packages/__VUE/uploader/index.taro.vue
index a716374414..28b21e9a99 100644
--- a/src/packages/__VUE/uploader/index.taro.vue
+++ b/src/packages/__VUE/uploader/index.taro.vue
@@ -71,20 +71,20 @@
diff --git a/src/packages/__VUE/uploader/index.vue b/src/packages/__VUE/uploader/index.vue
index 7ce1f01cbe..8975945145 100644
--- a/src/packages/__VUE/uploader/index.vue
+++ b/src/packages/__VUE/uploader/index.vue
@@ -71,18 +71,18 @@
diff --git a/src/packages/__VUE/uploader/type.ts b/src/packages/__VUE/uploader/type.ts
index 75fcdf9a40..d6dd03c697 100644
--- a/src/packages/__VUE/uploader/type.ts
+++ b/src/packages/__VUE/uploader/type.ts
@@ -1,15 +1,15 @@
-export type SizeType = 'original' | 'compressed';
-export type SourceType = 'album' | 'camera';
-export type MediaType = 'image' | 'video' | 'mix';
-export type FileItemStatus = 'ready' | 'uploading' | 'success' | 'error';
+export type SizeType = 'original' | 'compressed'
+export type SourceType = 'album' | 'camera'
+export type MediaType = 'image' | 'video' | 'mix'
+export type FileItemStatus = 'ready' | 'uploading' | 'success' | 'error'
export class FileItem {
- status: FileItemStatus = 'ready';
- message: string = '';
- uid: string = new Date().getTime().toString();
- name?: string;
- url?: string;
- type?: string;
- path?: string;
- percentage: string | number = 0;
- formData: any = {};
+ status: FileItemStatus = 'ready'
+ message: string = ''
+ uid: string = new Date().getTime().toString()
+ name?: string
+ url?: string
+ type?: string
+ path?: string
+ percentage: string | number = 0
+ formData: any = {}
}
diff --git a/src/packages/__VUE/uploader/uploader.ts b/src/packages/__VUE/uploader/uploader.ts
index eaa27de702..f32c8764b2 100644
--- a/src/packages/__VUE/uploader/uploader.ts
+++ b/src/packages/__VUE/uploader/uploader.ts
@@ -1,76 +1,76 @@
export class UploadOptions {
- url = '';
- name = 'file';
- fileType? = 'image';
- formData?: FormData;
- sourceFile: any;
- method = 'post';
- xhrState = 200;
- timeout = 30 * 1000;
- headers = {};
- withCredentials = false;
- onStart?: Function;
- taroFilePath?: string;
- onProgress?: Function;
- onSuccess?: Function;
- onFailure?: Function;
- beforeXhrUpload?: Function;
+ url = ''
+ name = 'file'
+ fileType? = 'image'
+ formData?: FormData
+ sourceFile: any
+ method = 'post'
+ xhrState = 200
+ timeout = 30 * 1000
+ headers = {}
+ withCredentials = false
+ onStart?: Function
+ taroFilePath?: string
+ onProgress?: Function
+ onSuccess?: Function
+ onFailure?: Function
+ beforeXhrUpload?: Function
}
export class Uploader {
- options: UploadOptions;
+ options: UploadOptions
constructor(options: UploadOptions) {
- this.options = options;
+ this.options = options
}
upload() {
- const options = this.options;
- const xhr = new XMLHttpRequest();
- xhr.timeout = options.timeout;
+ const options = this.options
+ const xhr = new XMLHttpRequest()
+ xhr.timeout = options.timeout
if (xhr.upload) {
xhr.upload.addEventListener(
'progress',
(e: ProgressEvent) => {
- options.onProgress?.(e, options);
+ options.onProgress?.(e, options)
},
false
- );
+ )
xhr.onreadystatechange = () => {
if (xhr.readyState === 4) {
if (xhr.status == options.xhrState) {
- options.onSuccess?.(xhr.responseText, options);
+ options.onSuccess?.(xhr.responseText, options)
} else {
- options.onFailure?.(xhr.responseText, options);
+ options.onFailure?.(xhr.responseText, options)
}
}
- };
- xhr.withCredentials = options.withCredentials;
- xhr.open(options.method, options.url, true);
+ }
+ xhr.withCredentials = options.withCredentials
+ xhr.open(options.method, options.url, true)
// headers
for (const [key, value] of Object.entries(options.headers)) {
- xhr.setRequestHeader(key, value as string);
+ xhr.setRequestHeader(key, value as string)
}
- options.onStart?.(options);
+ options.onStart?.(options)
if (options.beforeXhrUpload) {
- options.beforeXhrUpload(xhr, options);
+ options.beforeXhrUpload(xhr, options)
} else {
- xhr.send(options.formData);
+ xhr.send(options.formData)
}
} else {
- console.warn('浏览器不支持 XMLHttpRequest');
+ console.warn('浏览器不支持 XMLHttpRequest')
}
}
}
export class UploaderTaro extends Uploader {
constructor(options: UploadOptions) {
- super(options);
+ super(options)
}
uploadTaro(uploadFile: Function, env: string) {
- const options = this.options;
+ const options = this.options
if (env === 'WEB') {
- this.upload();
+ this.upload()
} else {
if (options.beforeXhrUpload) {
- options.beforeXhrUpload(uploadFile, options);
+ options.beforeXhrUpload(uploadFile, options)
} else {
const uploadTask = uploadFile({
url: options.url,
@@ -84,19 +84,19 @@ export class UploaderTaro extends Uploader {
name: options.name,
success(response: { errMsg: any; statusCode: number; data: string }) {
if (options.xhrState == response.statusCode) {
- options.onSuccess?.(response, options);
+ options.onSuccess?.(response, options)
} else {
- options.onFailure?.(response, options);
+ options.onFailure?.(response, options)
}
},
fail(e: any) {
- options.onFailure?.(e, options);
+ options.onFailure?.(e, options)
}
- });
- options.onStart?.(options);
+ })
+ options.onStart?.(options)
uploadTask.progress((res: { progress: any; totalBytesSent: any; totalBytesExpectedToSend: any }) => {
- options.onProgress?.(res, options);
- });
+ options.onProgress?.(res, options)
+ })
}
}
}
diff --git a/src/packages/__VUE/video/__tests__/video.spec.ts b/src/packages/__VUE/video/__tests__/video.spec.ts
index 5d2bb0824e..1c05166c59 100644
--- a/src/packages/__VUE/video/__tests__/video.spec.ts
+++ b/src/packages/__VUE/video/__tests__/video.spec.ts
@@ -1,11 +1,11 @@
-import { mount } from '@vue/test-utils';
-import { Video } from '@nutui/nutui';
-import { mockElementMethod } from '@/packages/utils/unit';
+import { mount } from '@vue/test-utils'
+import { Video } from '@nutui/nutui'
+import { mockElementMethod } from '@/packages/utils/unit'
-mockElementMethod(HTMLMediaElement, 'load');
-mockElementMethod(HTMLMediaElement, 'pause');
+mockElementMethod(HTMLMediaElement, 'load')
+mockElementMethod(HTMLMediaElement, 'pause')
-const videoUrl = 'https://storage.jd.com/about/big-final.mp4';
+const videoUrl = 'https://storage.jd.com/about/big-final.mp4'
test('Video: base info', () => {
const wrapper = mount(Video, {
@@ -24,10 +24,10 @@ test('Video: base info', () => {
loop: true
}
}
- });
- expect(wrapper.find('.nut-video source').html()).toContain(videoUrl);
- expect(wrapper.html()).toMatchSnapshot();
-});
+ })
+ expect(wrapper.find('.nut-video source').html()).toContain(videoUrl)
+ expect(wrapper.html()).toMatchSnapshot()
+})
test('Video: ref methods', () => {
const wrapper = mount(Video, {
@@ -38,12 +38,12 @@ test('Video: ref methods', () => {
},
options: {}
}
- });
- const vm: any = wrapper.vm;
- vm.play();
- vm.pause();
- vm.stop();
- vm.muted();
- vm.unmuted();
- expect(wrapper.emitted('pause')).toHaveLength(1);
-});
+ })
+ const vm: any = wrapper.vm
+ vm.play()
+ vm.pause()
+ vm.stop()
+ vm.muted()
+ vm.unmuted()
+ expect(wrapper.emitted('pause')).toHaveLength(1)
+})
diff --git a/src/packages/__VUE/video/demo/autoplay.vue b/src/packages/__VUE/video/demo/autoplay.vue
index 579ebc8f73..3981a9251b 100644
--- a/src/packages/__VUE/video/demo/autoplay.vue
+++ b/src/packages/__VUE/video/demo/autoplay.vue
@@ -5,14 +5,14 @@
diff --git a/src/packages/__VUE/video/demo/background.vue b/src/packages/__VUE/video/demo/background.vue
index 47fe6ccfbf..917ac16803 100644
--- a/src/packages/__VUE/video/demo/background.vue
+++ b/src/packages/__VUE/video/demo/background.vue
@@ -5,11 +5,11 @@
diff --git a/src/packages/__VUE/video/demo/basic.vue b/src/packages/__VUE/video/demo/basic.vue
index e3fb18de70..dd73163110 100644
--- a/src/packages/__VUE/video/demo/basic.vue
+++ b/src/packages/__VUE/video/demo/basic.vue
@@ -5,21 +5,21 @@
diff --git a/src/packages/__VUE/video/demo/index.vue b/src/packages/__VUE/video/demo/index.vue
index a4ff69e7ba..948b104658 100644
--- a/src/packages/__VUE/video/demo/index.vue
+++ b/src/packages/__VUE/video/demo/index.vue
@@ -21,13 +21,13 @@
diff --git a/src/packages/__VUE/video/demo/methods.vue b/src/packages/__VUE/video/demo/methods.vue
index 74a6561e1c..77f3a6f7f6 100644
--- a/src/packages/__VUE/video/demo/methods.vue
+++ b/src/packages/__VUE/video/demo/methods.vue
@@ -12,22 +12,22 @@
diff --git a/src/packages/__VUE/video/demo/playsinline.vue b/src/packages/__VUE/video/demo/playsinline.vue
index 6f0d5a0a80..2bf29d94a8 100644
--- a/src/packages/__VUE/video/demo/playsinline.vue
+++ b/src/packages/__VUE/video/demo/playsinline.vue
@@ -5,13 +5,13 @@
diff --git a/src/packages/__VUE/video/demo/poster.vue b/src/packages/__VUE/video/demo/poster.vue
index 917ce6f0d6..e29c8a1300 100644
--- a/src/packages/__VUE/video/demo/poster.vue
+++ b/src/packages/__VUE/video/demo/poster.vue
@@ -5,14 +5,14 @@
diff --git a/src/packages/__VUE/video/doc.en-US.md b/src/packages/__VUE/video/doc.en-US.md
index e7db59595c..a4dd92092f 100644
--- a/src/packages/__VUE/video/doc.en-US.md
+++ b/src/packages/__VUE/video/doc.en-US.md
@@ -7,11 +7,11 @@ Video player implemented by native video
### Install
```js
-import { createApp } from 'vue';
-import { Video, Button } from '@nutui/nutui';
+import { createApp } from 'vue'
+import { Video, Button } from '@nutui/nutui'
-const app = createApp();
-app.use(Video);
+const app = createApp()
+app.use(Video)
```
### Basic Usage
diff --git a/src/packages/__VUE/video/doc.md b/src/packages/__VUE/video/doc.md
index d824c49ac9..98f758aeca 100644
--- a/src/packages/__VUE/video/doc.md
+++ b/src/packages/__VUE/video/doc.md
@@ -7,11 +7,11 @@
### 安装
```js
-import { createApp } from 'vue';
-import { Video, Button } from '@nutui/nutui';
+import { createApp } from 'vue'
+import { Video, Button } from '@nutui/nutui'
-const app = createApp();
-app.use(Video);
+const app = createApp()
+app.use(Video)
```
### 基础用法
diff --git a/src/packages/__VUE/video/index.vue b/src/packages/__VUE/video/index.vue
index 090c92a6dc..0d18bf5679 100644
--- a/src/packages/__VUE/video/index.vue
+++ b/src/packages/__VUE/video/index.vue
@@ -57,13 +57,13 @@
diff --git a/src/packages/__VUE/watermark/__tests__/watermark.spec.tsx b/src/packages/__VUE/watermark/__tests__/watermark.spec.tsx
index 4f0e8f0d47..7c1a56bdcb 100644
--- a/src/packages/__VUE/watermark/__tests__/watermark.spec.tsx
+++ b/src/packages/__VUE/watermark/__tests__/watermark.spec.tsx
@@ -1,17 +1,17 @@
-import { mount } from '@vue/test-utils';
-import { Watermark, Cell } from '@nutui/nutui';
-import { nextTick } from 'vue';
-import 'vitest-canvas-mock';
+import { mount } from '@vue/test-utils'
+import { Watermark, Cell } from '@nutui/nutui'
+import { nextTick } from 'vue'
+import 'vitest-canvas-mock'
test('render fullPage props ', async () => {
const wrapper = mount(() => {
- return ;
- });
- await nextTick();
+ return
+ })
+ await nextTick()
- expect(wrapper.findAll('.nut-watermark').length).toBe(1);
- expect(wrapper.findAll('.nut-watermark-full-page').length).toBe(1);
-});
+ expect(wrapper.findAll('.nut-watermark').length).toBe(1)
+ expect(wrapper.findAll('.nut-watermark-full-page').length).toBe(1)
+})
test('should render watermark', () => {
const wrapper = mount(() => {
@@ -19,7 +19,7 @@ test('should render watermark', () => {
|
- );
- });
- expect(wrapper.html()).toMatchSnapshot();
-});
+ )
+ })
+ expect(wrapper.html()).toMatchSnapshot()
+})
diff --git a/src/packages/__VUE/watermark/demo/basic.vue b/src/packages/__VUE/watermark/demo/basic.vue
index fa56e2ef60..7832ceeb92 100644
--- a/src/packages/__VUE/watermark/demo/basic.vue
+++ b/src/packages/__VUE/watermark/demo/basic.vue
@@ -14,9 +14,9 @@
>
diff --git a/src/packages/__VUE/watermark/demo/index.vue b/src/packages/__VUE/watermark/demo/index.vue
index 909889cf47..660a82c403 100644
--- a/src/packages/__VUE/watermark/demo/index.vue
+++ b/src/packages/__VUE/watermark/demo/index.vue
@@ -11,10 +11,10 @@
diff --git a/src/packages/__VUE/watermark/demo/part.vue b/src/packages/__VUE/watermark/demo/part.vue
index 610afb2561..73e2e5b7a3 100644
--- a/src/packages/__VUE/watermark/demo/part.vue
+++ b/src/packages/__VUE/watermark/demo/part.vue
@@ -5,6 +5,6 @@
diff --git a/src/packages/__VUE/watermark/doc.en-US.md b/src/packages/__VUE/watermark/doc.en-US.md
index 6f140fc99a..343d292828 100644
--- a/src/packages/__VUE/watermark/doc.en-US.md
+++ b/src/packages/__VUE/watermark/doc.en-US.md
@@ -5,11 +5,11 @@
### Install
```js
-import { createApp } from 'vue';
-import { Watermark } from '@nutui/nutui';
+import { createApp } from 'vue'
+import { Watermark } from '@nutui/nutui'
-const app = createApp();
-app.use(Watermark);
+const app = createApp()
+app.use(Watermark)
```
### Basic Usage
diff --git a/src/packages/__VUE/watermark/doc.md b/src/packages/__VUE/watermark/doc.md
index d47d0f48a2..4f0d56d87e 100644
--- a/src/packages/__VUE/watermark/doc.md
+++ b/src/packages/__VUE/watermark/doc.md
@@ -7,11 +7,11 @@
### 安装
```js
-import { createApp } from 'vue';
-import { Watermark } from '@nutui/nutui';
+import { createApp } from 'vue'
+import { Watermark } from '@nutui/nutui'
-const app = createApp();
-app.use(Watermark);
+const app = createApp()
+app.use(Watermark)
```
### 基础用法
diff --git a/src/packages/__VUE/watermark/doc.taro.md b/src/packages/__VUE/watermark/doc.taro.md
index f5b41790f3..b66091395d 100644
--- a/src/packages/__VUE/watermark/doc.taro.md
+++ b/src/packages/__VUE/watermark/doc.taro.md
@@ -7,11 +7,11 @@
### 安装
```js
-import { createApp } from 'vue';
-import { Watermark } from '@nutui/nutui-taro';
+import { createApp } from 'vue'
+import { Watermark } from '@nutui/nutui-taro'
-const app = createApp();
-app.use(Watermark);
+const app = createApp()
+app.use(Watermark)
```
### 基础用法
diff --git a/src/packages/__VUE/watermark/index.taro.vue b/src/packages/__VUE/watermark/index.taro.vue
index b6af53ef52..fb4d1c1e2b 100644
--- a/src/packages/__VUE/watermark/index.taro.vue
+++ b/src/packages/__VUE/watermark/index.taro.vue
@@ -10,11 +10,11 @@
diff --git a/src/packages/__VUE/watermark/index.vue b/src/packages/__VUE/watermark/index.vue
index 62f012a00e..8e99fc0315 100644
--- a/src/packages/__VUE/watermark/index.vue
+++ b/src/packages/__VUE/watermark/index.vue
@@ -10,9 +10,9 @@
diff --git a/src/packages/locale/index.ts b/src/packages/locale/index.ts
index c3b7af866b..ed625658a8 100644
--- a/src/packages/locale/index.ts
+++ b/src/packages/locale/index.ts
@@ -1,33 +1,33 @@
-import { ref, reactive } from 'vue';
-import ZhCNLang from './lang/zh-CN';
-import EnUSLang from './lang/en-US';
-import { deepMerge } from '../utils/util';
+import { ref, reactive } from 'vue'
+import ZhCNLang from './lang/zh-CN'
+import EnUSLang from './lang/en-US'
+import { deepMerge } from '../utils/util'
// 组件默认语言设置
-export type Lang = Record;
+export type Lang = Record
const langs = reactive({
'zh-CN': new ZhCNLang(),
'en-US': new EnUSLang()
-});
+})
export class Locale {
- static currentLang = ref('zh-CN');
+ static currentLang = ref('zh-CN')
static languages(): Lang {
- return langs[this.currentLang.value];
+ return langs[this.currentLang.value]
}
static use(lang: string, newLanguages?: any) {
if (newLanguages) {
- langs[lang] = new newLanguages();
+ langs[lang] = new newLanguages()
}
- this.currentLang.value = lang;
+ this.currentLang.value = lang
}
static merge(lang: string, newLanguages: any) {
if (newLanguages) {
if (langs[lang]) {
- deepMerge(langs[lang], newLanguages);
+ deepMerge(langs[lang], newLanguages)
} else {
- this.use(lang, newLanguages);
+ this.use(lang, newLanguages)
}
}
}
}
-export default Locale;
+export default Locale
diff --git a/src/packages/locale/lang/baseLang.ts b/src/packages/locale/lang/baseLang.ts
index b55d2bda2a..b433567500 100644
--- a/src/packages/locale/lang/baseLang.ts
+++ b/src/packages/locale/lang/baseLang.ts
@@ -1,102 +1,102 @@
export abstract class BaseLang {
- abstract save: string;
- abstract confirm: string;
- abstract cancel: string;
- abstract done: string;
- abstract noData: string;
- abstract placeholder: string;
- abstract select: string;
+ abstract save: string
+ abstract confirm: string
+ abstract cancel: string
+ abstract done: string
+ abstract noData: string
+ abstract placeholder: string
+ abstract select: string
abstract video: {
- errorTip: string;
- clickRetry: string;
- };
+ errorTip: string
+ clickRetry: string
+ }
abstract fixednav: {
- activeText: string;
- unActiveText: string;
- };
+ activeText: string
+ unActiveText: string
+ }
abstract pagination: {
- prev: string;
- next: string;
- };
+ prev: string
+ next: string
+ }
abstract calendaritem: {
- weekdays: Array;
- end: string;
- start: string;
- title: string;
- monthTitle: Function;
- today: string;
- };
+ weekdays: Array
+ end: string
+ start: string
+ title: string
+ monthTitle: Function
+ today: string
+ }
abstract calendarcard: {
- weekdays: Array;
- end: string;
- start: string;
- title: string;
- monthTitle: Function;
- today: string;
- };
+ weekdays: Array
+ end: string
+ start: string
+ title: string
+ monthTitle: Function
+ today: string
+ }
abstract shortpassword: {
- title: string;
- desc: string;
- tips: string;
- };
+ title: string
+ desc: string
+ tips: string
+ }
abstract uploader: {
- ready: string;
- readyUpload: string;
- waitingUpload: string;
- uploading: string;
- success: string;
- error: string;
- };
+ ready: string
+ readyUpload: string
+ waitingUpload: string
+ uploading: string
+ success: string
+ error: string
+ }
abstract countdown: {
- day: string;
- hour: string;
- minute: string;
- second: string;
- };
+ day: string
+ hour: string
+ minute: string
+ second: string
+ }
abstract address: {
- selectRegion: string;
- deliveryTo: string;
- chooseAnotherAddress: string;
- };
+ selectRegion: string
+ deliveryTo: string
+ chooseAnotherAddress: string
+ }
abstract signature: {
- reSign: string;
- unSupportTpl: string;
- };
+ reSign: string
+ unSupportTpl: string
+ }
abstract ecard: {
- chooseText: string;
- otherValueText: string;
- placeholder: string;
- };
+ chooseText: string
+ otherValueText: string
+ placeholder: string
+ }
abstract timeselect: {
- pickupTime: string;
- };
+ pickupTime: string
+ }
abstract sku: {
- buyNow: string;
- buyNumber: string;
- addToCart: string;
- };
+ buyNow: string
+ buyNumber: string
+ addToCart: string
+ }
abstract skuheader: {
- skuId: string;
- };
+ skuId: string
+ }
abstract addresslist: {
- addAddress: string;
- default: string;
- };
+ addAddress: string
+ default: string
+ }
abstract comment: {
- complaintsText: string;
- additionalReview: Function;
- additionalImages: Function;
- };
+ complaintsText: string
+ additionalReview: Function
+ additionalImages: Function
+ }
abstract infiniteloading: {
- loading: string;
- pullTxt: string;
- loadMoreTxt: string;
- };
+ loading: string
+ pullTxt: string
+ loadMoreTxt: string
+ }
abstract pullrefresh: {
- pulling: string;
- loosing: string;
- loading: string;
- complete: string;
- };
+ pulling: string
+ loosing: string
+ loading: string
+ complete: string
+ }
}
-export default BaseLang;
+export default BaseLang
diff --git a/src/packages/locale/lang/en-US.ts b/src/packages/locale/lang/en-US.ts
index c7af37ed68..60bb806e1c 100644
--- a/src/packages/locale/lang/en-US.ts
+++ b/src/packages/locale/lang/en-US.ts
@@ -1,24 +1,24 @@
-import { BaseLang } from './baseLang';
+import { BaseLang } from './baseLang'
class Lang extends BaseLang {
- save = 'Save';
- confirm = 'Confirm';
- cancel = 'Cancel';
- done = 'Done';
- noData = 'No Data';
- placeholder = 'Placeholder';
- select = 'Select';
+ save = 'Save'
+ confirm = 'Confirm'
+ cancel = 'Cancel'
+ done = 'Done'
+ noData = 'No Data'
+ placeholder = 'Placeholder'
+ select = 'Select'
video = {
errorTip: 'Error Tip',
clickRetry: 'Click Retry'
- };
+ }
fixednav = {
activeText: 'Close Nav',
unActiveText: 'Open Nav'
- };
+ }
pagination = {
prev: 'Previous',
next: 'Next'
- };
+ }
calendaritem = {
weekdays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
end: 'End',
@@ -26,7 +26,7 @@ class Lang extends BaseLang {
title: 'Calendar',
monthTitle: (year: number, month: number) => `${year}/${month}`,
today: 'Today'
- };
+ }
calendarcard = {
weekdays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
end: 'End',
@@ -34,12 +34,12 @@ class Lang extends BaseLang {
title: 'Calendar',
monthTitle: (year: number, month: number) => `${year}/${month}`,
today: 'Today'
- };
+ }
shortpassword = {
title: 'Please input a password',
desc: 'Verify',
tips: 'Forget password'
- };
+ }
uploader = {
ready: 'Ready',
readyUpload: 'Ready to upload',
@@ -47,52 +47,52 @@ class Lang extends BaseLang {
uploading: 'Uploading',
success: 'Upload successful',
error: 'Upload failed'
- };
+ }
countdown = {
day: ' Day ',
hour: ' Hour ',
minute: ' Minute ',
second: ' Second '
- };
+ }
address = {
selectRegion: 'Select Region',
deliveryTo: 'Delivery To',
chooseAnotherAddress: 'Choose Another Address'
- };
+ }
signature = {
reSign: 'Re Sign',
unSupportTpl: `Sorry, the current browser doesn't support canvas, so we can't use this control!`
- };
+ }
ecard = {
chooseText: 'Select',
otherValueText: 'Other Value',
placeholder: 'Placeholder'
- };
+ }
timeselect = {
pickupTime: 'Pickup Time'
- };
+ }
sku = {
buyNow: 'Buy Now',
buyNumber: 'Buy Number',
addToCart: 'Add to Cart'
- };
+ }
skuheader = {
skuId: 'Sku Number'
- };
+ }
addresslist = {
addAddress: 'Add New Address',
default: 'default'
- };
+ }
comment = {
complaintsText: 'I have a complaint',
additionalReview: (day: number) => `Review after ${day} days of purchase`,
additionalImages: (length: number) => `There are ${length} follow-up comments`
- };
+ }
infiniteloading = {
loading: 'Loading...',
pullTxt: 'Loose to refresh',
loadMoreTxt: 'Oops, this is the bottom'
- };
+ }
datepicker = {
year: 'Year',
month: 'Month',
@@ -100,20 +100,20 @@ class Lang extends BaseLang {
hour: 'Hour',
min: 'Minute',
seconds: 'Second'
- };
+ }
audiooperate = {
back: 'Back',
start: 'Start',
pause: 'Pause',
forward: 'Forward',
mute: 'Mute'
- };
+ }
pullrefresh = {
pulling: 'Pull to refresh...',
loosing: 'Loose to refresh...',
loading: 'Loading...',
complete: 'Refresh successfully'
- };
+ }
}
-export default Lang;
+export default Lang
diff --git a/src/packages/locale/lang/id-ID.ts b/src/packages/locale/lang/id-ID.ts
index 6f17a3f671..a4d49e8e79 100644
--- a/src/packages/locale/lang/id-ID.ts
+++ b/src/packages/locale/lang/id-ID.ts
@@ -1,24 +1,24 @@
-import { BaseLang } from './baseLang';
+import { BaseLang } from './baseLang'
class Lang extends BaseLang {
- save = 'Simpan';
- confirm = 'Konfirmasi';
- cancel = 'Batal';
- done = 'Selesai';
- noData = 'Tidak Ada Data';
- placeholder = 'Kolom Input';
- select = 'Pilih';
+ save = 'Simpan'
+ confirm = 'Konfirmasi'
+ cancel = 'Batal'
+ done = 'Selesai'
+ noData = 'Tidak Ada Data'
+ placeholder = 'Kolom Input'
+ select = 'Pilih'
video = {
errorTip: 'Terjadi Kesalahan',
clickRetry: 'Coba Lagi'
- };
+ }
fixednav = {
activeText: 'Tutup Navigasi',
unActiveText: 'Buka Navigasi'
- };
+ }
pagination = {
prev: 'Sebelumnya',
next: 'Selanjutnya'
- };
+ }
calendaritem = {
weekdays: ['Min', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab'],
end: 'Selesai',
@@ -26,7 +26,7 @@ class Lang extends BaseLang {
title: 'Kalender',
monthTitle: (year: number, month: number) => `${year}/${month}`,
today: 'Hari ini'
- };
+ }
calendarcard = {
weekdays: ['Min', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab'],
end: 'Selesai',
@@ -34,12 +34,12 @@ class Lang extends BaseLang {
title: 'Kalender',
monthTitle: (year: number, month: number) => `${year}/${month}`,
today: 'Hari ini'
- };
+ }
shortpassword = {
title: 'SIlakan masukan kata sandi',
desc: 'Anda telah menggunakan aset virtual, mohon lakukan verifikasi.',
tips: 'Lupa Kata Sandi'
- };
+ }
uploader = {
ready: 'File berhasil diunggah',
readyUpload: 'Siap untuk mengunggah',
@@ -47,52 +47,52 @@ class Lang extends BaseLang {
uploading: 'Mengunggah',
success: 'Berhasil Diunggah',
error: 'Gagal Mengunggah'
- };
+ }
countdown = {
day: ' Hari ',
hour: ' Jam ',
minute: ' Menit ',
second: ' Detik '
- };
+ }
address = {
selectRegion: 'Pilih Daerah',
deliveryTo: 'Kirim Ke',
chooseAnotherAddress: 'Pilih alamat lain'
- };
+ }
signature = {
reSign: 'Masuk Kembali',
unSupportTpl: `Maaf, browser Anda saat ini tidak mendukung Canvas, sehingga kita tidak dapat menggunakan kontrol ini!`
- };
+ }
ecard = {
chooseText: 'Pilih',
otherValueText: 'Jumlah Lain',
placeholder: 'Kolom Input'
- };
+ }
timeselect = {
pickupTime: 'Waktu Penjemputan'
- };
+ }
sku = {
buyNow: 'Beli Sekarang',
buyNumber: 'Jumlah Pembelian',
addToCart: 'Tambahkan ke Keranjang'
- };
+ }
skuheader = {
skuId: 'Nomor SKU'
- };
+ }
addresslist = {
addAddress: 'Tambah Alamat Baru',
default: 'Bawaan'
- };
+ }
comment = {
complaintsText: 'Saya memiliki komplain',
additionalReview: (day: number) => `Ulas setelah ${day} hari dari pembelian`,
additionalImages: (length: number) => `Terdapat ${length} komentar lainnya`
- };
+ }
infiniteloading = {
loading: 'Memuat...',
pullTxt: 'Lepaskan untuk memperbarui',
loadMoreTxt: 'Oops, sudah sampai bawah'
- };
+ }
datepicker = {
year: 'Tahun',
month: 'Bulan',
@@ -100,19 +100,19 @@ class Lang extends BaseLang {
hour: 'Jam',
min: 'Menit',
seconds: 'Detik'
- };
+ }
audiooperate = {
back: 'kembali',
start: 'Mulailah',
pause: 'berhenti sebentar',
forward: 'Maju cepat',
mute: 'Bisu'
- };
+ }
pullrefresh = {
pulling: 'Tarik ke bawah untuk menyegarkan',
loosing: 'Lepaskan Refresh',
loading: 'Memuat...',
complete: 'Refresh berhasil'
- };
+ }
}
-export default Lang;
+export default Lang
diff --git a/src/packages/locale/lang/zh-CN.ts b/src/packages/locale/lang/zh-CN.ts
index 2b0a448180..b82fce5bb7 100644
--- a/src/packages/locale/lang/zh-CN.ts
+++ b/src/packages/locale/lang/zh-CN.ts
@@ -1,24 +1,24 @@
-import { BaseLang } from './baseLang';
+import { BaseLang } from './baseLang'
class Lang extends BaseLang {
- save = '保存';
- confirm = '确认';
- cancel = '取消';
- done = '完成';
- noData = '暂无数据';
- placeholder = '请输入';
- select = '请选择';
+ save = '保存'
+ confirm = '确认'
+ cancel = '取消'
+ done = '完成'
+ noData = '暂无数据'
+ placeholder = '请输入'
+ select = '请选择'
video = {
errorTip: '视频加载失败',
clickRetry: '点击重试'
- };
+ }
fixednav = {
activeText: '收起导航',
unActiveText: '快速导航'
- };
+ }
pagination = {
prev: '上一页',
next: '下一页'
- };
+ }
calendaritem = {
weekdays: ['日', '一', '二', '三', '四', '五', '六'],
end: '结束',
@@ -26,7 +26,7 @@ class Lang extends BaseLang {
title: '日期选择',
monthTitle: (year: number, month: number) => `${year}年${month}月`,
today: '今天'
- };
+ }
calendarcard = {
weekdays: ['日', '一', '二', '三', '四', '五', '六'],
end: '结束',
@@ -34,12 +34,12 @@ class Lang extends BaseLang {
title: '日期选择',
monthTitle: (year: number, month: number) => `${year}年${month}月`,
today: '今天'
- };
+ }
shortpassword = {
title: '请输入密码',
desc: '您使用了虚拟资产,请进行验证',
tips: '忘记密码'
- };
+ }
uploader = {
ready: '准备完成',
readyUpload: '准备上传',
@@ -47,52 +47,52 @@ class Lang extends BaseLang {
uploading: '上传中',
success: '上传成功',
error: '上传失败'
- };
+ }
countdown = {
day: '天',
hour: '时',
minute: '分',
second: '秒'
- };
+ }
address = {
selectRegion: '请选择所在地区',
deliveryTo: '配送至',
chooseAnotherAddress: '选择其他地址'
- };
+ }
signature = {
reSign: '重签',
unSupportTpl: '对不起,当前浏览器不支持Canvas,无法使用本控件!'
- };
+ }
ecard = {
chooseText: '请选择电子卡面值',
otherValueText: '其他面值',
placeholder: '请输入1-5000整数'
- };
+ }
timeselect = {
pickupTime: '取件时间'
- };
+ }
sku = {
buyNow: '立即购买',
buyNumber: '购买数量',
addToCart: '加入购物车'
- };
+ }
skuheader = {
skuId: '商品编号'
- };
+ }
addresslist = {
addAddress: '新建地址',
default: '默认'
- };
+ }
comment = {
complaintsText: '我要投诉',
additionalReview: (day: number) => `购买${day}天后追评`,
additionalImages: (length: number) => `${length}张追评图片`
- };
+ }
infiniteloading = {
loading: '加载中...',
pullTxt: '松开刷新',
loadMoreTxt: '哎呀,这里是底部了啦'
- };
+ }
datepicker = {
year: '年',
month: '月',
@@ -100,19 +100,19 @@ class Lang extends BaseLang {
hour: '时',
min: '分',
seconds: '秒'
- };
+ }
audiooperate = {
back: '倒退',
start: '开始',
pause: '暂停',
forward: '快进',
mute: '静音'
- };
+ }
pullrefresh = {
pulling: '下拉刷新',
loosing: '释放刷新',
loading: '加载中...',
complete: '刷新成功'
- };
+ }
}
-export default Lang;
+export default Lang
diff --git a/src/packages/locale/lang/zh-TW.ts b/src/packages/locale/lang/zh-TW.ts
index adac2a2c71..116c1d755b 100644
--- a/src/packages/locale/lang/zh-TW.ts
+++ b/src/packages/locale/lang/zh-TW.ts
@@ -1,24 +1,24 @@
-import { BaseLang } from './baseLang';
+import { BaseLang } from './baseLang'
class Lang extends BaseLang {
- save = '保存';
- confirm = '確認';
- cancel = '取消';
- done = '完成';
- noData = '暫無數據';
- placeholder = '請輸入';
- select = '請選擇';
+ save = '保存'
+ confirm = '確認'
+ cancel = '取消'
+ done = '完成'
+ noData = '暫無數據'
+ placeholder = '請輸入'
+ select = '請選擇'
video = {
errorTip: '視頻加載失敗',
clickRetry: '點擊重試'
- };
+ }
fixednav = {
activeText: '收起導航',
unActiveText: '快速導航'
- };
+ }
pagination = {
prev: '上一頁',
next: '下一頁'
- };
+ }
calendaritem = {
weekdays: ['日', '一', '二', '三', '四', '五', '六'],
end: '結束',
@@ -26,7 +26,7 @@ class Lang extends BaseLang {
title: '行事曆選擇',
monthTitle: (year: number, month: number) => `${year}年${month}月`,
today: '今天'
- };
+ }
calendarcard = {
weekdays: ['日', '一', '二', '三', '四', '五', '六'],
end: '結束',
@@ -34,12 +34,12 @@ class Lang extends BaseLang {
title: '行事曆選擇',
monthTitle: (year: number, month: number) => `${year}年${month}月`,
today: '今天'
- };
+ }
shortpassword = {
title: '請輸入密碼',
desc: '您使用了虛擬資產,請進行驗證',
tips: '忘記密碼'
- };
+ }
uploader = {
ready: '準備完成',
readyUpload: '準備上傳',
@@ -47,52 +47,52 @@ class Lang extends BaseLang {
uploading: '上傳中',
success: '上傳成功',
error: '上傳失敗'
- };
+ }
countdown = {
day: '天',
hour: '時',
minute: '分',
second: '秒'
- };
+ }
address = {
selectRegion: '請選擇所在地區',
deliveryTo: '配送至',
chooseAnotherAddress: '選擇其他地址'
- };
+ }
signature = {
reSign: '重簽',
unSupportTpl: '對不起,當前瀏覽器不支持Canvas,無法使用本控制項!'
- };
+ }
ecard = {
chooseText: '請選擇電子卡面值',
otherValueText: '其他面值',
placeholder: '請輸入1-5000整數'
- };
+ }
timeselect = {
pickupTime: '取件時間'
- };
+ }
sku = {
buyNow: '立即購買',
buyNumber: '購買數量',
addToCart: '加入購物車'
- };
+ }
skuheader = {
skuId: '商品編號'
- };
+ }
addresslist = {
addAddress: '新建地址',
default: '默认'
- };
+ }
comment = {
complaintsText: '我要投訴',
additionalReview: (day: number) => `購買${day}天後追評`,
additionalImages: (length: number) => `${length}張追評圖片`
- };
+ }
infiniteloading = {
loading: '加載中...',
pullTxt: '鬆開刷新',
loadMoreTxt: '哎呀,這裡是底部了啦'
- };
+ }
datepicker = {
year: '年',
month: '月',
@@ -100,19 +100,19 @@ class Lang extends BaseLang {
hour: '時',
min: '分',
seconds: '秒'
- };
+ }
audiooperate = {
back: '倒退',
start: '開始',
pause: '暫停',
forward: '快進',
mute: '靜音'
- };
+ }
pullrefresh = {
pulling: '下拉刷新',
loosing: '釋放刷新',
loading: '加載中...',
complete: '刷新成功'
- };
+ }
}
-export default Lang;
+export default Lang
diff --git a/src/packages/resolver/index.ts b/src/packages/resolver/index.ts
index 4f4b3cfafb..37944f9b69 100644
--- a/src/packages/resolver/index.ts
+++ b/src/packages/resolver/index.ts
@@ -1,4 +1,4 @@
-import type { ComponentResolveResult, ComponentResolver } from 'unplugin-vue-components/types';
+import type { ComponentResolveResult, ComponentResolver } from 'unplugin-vue-components/types'
export interface NutUIResolverOptions {
/**
@@ -6,32 +6,32 @@ export interface NutUIResolverOptions {
*
* @default false
*/
- taro?: boolean;
+ taro?: boolean
/**
* compatible with unplugin-auto-import
*
* @default false
*/
- autoImport?: boolean;
+ autoImport?: boolean
}
-const nutFunctions = ['showToast', 'showNotify', 'showDialog', 'showImagePreview'];
+const nutFunctions = ['showToast', 'showNotify', 'showDialog', 'showImagePreview']
function getNutResolved(name: string, options: NutUIResolverOptions): ComponentResolveResult {
- const { taro = false, autoImport = false } = options;
+ const { taro = false, autoImport = false } = options
- const packageName = taro ? '@nutui/nutui-taro' : '@nutui/nutui';
+ const packageName = taro ? '@nutui/nutui-taro' : '@nutui/nutui'
- const componentName = autoImport ? name.slice(4) : name;
+ const componentName = autoImport ? name.slice(4) : name
- const style = `${packageName}/dist/packages/${componentName.toLowerCase()}/style`;
+ const style = `${packageName}/dist/packages/${componentName.toLowerCase()}/style`
return {
name,
from: packageName,
sideEffects: style
- };
+ }
}
/**
@@ -43,11 +43,11 @@ export default function NutUIResolver(options: NutUIResolverOptions = {}): Compo
return {
type: 'component',
resolve: (name) => {
- const { autoImport = false } = options;
+ const { autoImport = false } = options
- if (autoImport && nutFunctions.includes(name)) return getNutResolved(name, options);
+ if (autoImport && nutFunctions.includes(name)) return getNutResolved(name, options)
- if (name.startsWith('Nut')) return getNutResolved(name.slice(3), options);
+ if (name.startsWith('Nut')) return getNutResolved(name.slice(3), options)
}
- };
+ }
}
diff --git a/src/packages/utils/Interceptor.ts b/src/packages/utils/Interceptor.ts
index 2da22966ad..1239e09bf0 100644
--- a/src/packages/utils/Interceptor.ts
+++ b/src/packages/utils/Interceptor.ts
@@ -1,5 +1,5 @@
-import { isPromise } from './util';
-export type Interceptor = (...args: any[]) => Promise | boolean | undefined | void;
+import { isPromise } from './util'
+export type Interceptor = (...args: any[]) => Promise | boolean | undefined | void
export const funInterceptor = (
interceptor: Interceptor | undefined,
@@ -8,30 +8,30 @@ export const funInterceptor = (
done,
canceled
}: {
- args?: unknown[];
- done: (val?: any) => void;
- canceled?: () => void;
+ args?: unknown[]
+ done: (val?: any) => void
+ canceled?: () => void
}
) => {
if (interceptor) {
- const returnVal = interceptor.apply(null, args);
+ const returnVal = interceptor.apply(null, args)
if (isPromise(returnVal)) {
returnVal
.then((value) => {
if (value) {
- done(value);
+ done(value)
} else if (canceled) {
- canceled();
+ canceled()
}
})
- .catch(() => {});
+ .catch(() => {})
} else if (returnVal) {
- done();
+ done()
} else if (canceled) {
- canceled();
+ canceled()
}
} else {
- done();
+ done()
}
-};
+}
diff --git a/src/packages/utils/canvas.ts b/src/packages/utils/canvas.ts
index fdaf27c918..ff845525dc 100644
--- a/src/packages/utils/canvas.ts
+++ b/src/packages/utils/canvas.ts
@@ -1,35 +1,35 @@
-import Taro from '@tarojs/taro';
-import CanvasContext = Taro.CanvasContext;
+import Taro from '@tarojs/taro'
+import CanvasContext = Taro.CanvasContext
const compareVersion = (v1Old: string, v2Old: string) => {
- let v1 = v1Old.split('.');
- let v2 = v2Old.split('.');
- const len = Math.max(v1.length, v2.length);
+ let v1 = v1Old.split('.')
+ let v2 = v2Old.split('.')
+ const len = Math.max(v1.length, v2.length)
while (v1.length < len) {
- v1.push('0');
+ v1.push('0')
}
while (v2.length < len) {
- v2.push('0');
+ v2.push('0')
}
for (let i = 0; i < len; i++) {
- const num1 = parseInt(v1[i]);
- const num2 = parseInt(v2[i]);
+ const num1 = parseInt(v1[i])
+ const num2 = parseInt(v2[i])
if (num1 > num2) {
- return 1;
+ return 1
} else if (num1 < num2) {
- return -1;
+ return -1
}
}
- return 0;
-};
+ return 0
+}
const isWeapp = () => {
- return process.env.TARO_ENV === 'weapp';
-};
+ return process.env.TARO_ENV === 'weapp'
+}
//////////////////////////////////////////////////////////////////////////////////
//////// 微信小程序自1.9.90起废除若干个CanvasContext的函数,改为属性,以下为兼容代码
@@ -42,9 +42,9 @@ function _easyCanvasContextBase(
targetVersion: string = '1.9.90'
) {
if (isWeapp() && compareVersion(systemInfo.SDKVersion, targetVersion) >= 0) {
- highCallback();
+ highCallback()
} else {
- lowCallback();
+ lowCallback()
}
}
/**
@@ -62,28 +62,28 @@ function easySetStrokeStyle(
_easyCanvasContextBase(
systemInfo,
() => {
- canvasContext.setStrokeStyle(color);
- console.log('???');
+ canvasContext.setStrokeStyle(color)
+ console.log('???')
},
() => {
if (typeof color === 'string') {
- canvasContext.strokeStyle = color;
+ canvasContext.strokeStyle = color
}
- console.log('2333');
+ console.log('2333')
}
- );
+ )
}
function easySetLineWidth(systemInfo: Taro.getSystemInfoSync.Result, canvasContext: CanvasContext, lineWidth: number) {
_easyCanvasContextBase(
systemInfo,
() => {
- canvasContext.setLineWidth(lineWidth);
+ canvasContext.setLineWidth(lineWidth)
},
() => {
- canvasContext.lineWidth = lineWidth;
+ canvasContext.lineWidth = lineWidth
}
- );
+ )
}
function easySetFillStyle(
@@ -94,14 +94,14 @@ function easySetFillStyle(
_easyCanvasContextBase(
systemInfo,
() => {
- canvasContext.setFillStyle(color);
+ canvasContext.setFillStyle(color)
},
() => {
if (typeof color === 'string') {
- canvasContext.fillStyle = color;
+ canvasContext.fillStyle = color
}
}
- );
+ )
}
-export { compareVersion, easySetStrokeStyle, easySetLineWidth, easySetFillStyle };
+export { compareVersion, easySetStrokeStyle, easySetLineWidth, easySetFillStyle }
diff --git a/src/packages/utils/create/component.ts b/src/packages/utils/create/component.ts
index 79de59c0dd..47f1283741 100644
--- a/src/packages/utils/create/component.ts
+++ b/src/packages/utils/create/component.ts
@@ -1,18 +1,18 @@
-import { defineComponent } from 'vue';
-import type { App } from 'vue';
-const camelize = (s: string) => s.replace(/-./g, (x) => x[1].toUpperCase());
+import { defineComponent } from 'vue'
+import type { App } from 'vue'
+const camelize = (s: string) => s.replace(/-./g, (x) => x[1].toUpperCase())
export function createComponent(name: string) {
// TODO: It will be deprecated someday.
- const componentName = 'nut-' + name;
+ const componentName = 'nut-' + name
return {
componentName,
create: function (_component: any) {
- _component.name = 'Nut' + camelize('-' + name);
+ _component.name = 'Nut' + camelize('-' + name)
_component.install = (vue: App) => {
- vue.component(_component.name as string, _component as any);
- };
- return defineComponent(_component);
+ vue.component(_component.name as string, _component as any)
+ }
+ return defineComponent(_component)
} as typeof defineComponent
- };
+ }
}
diff --git a/src/packages/utils/create/index.ts b/src/packages/utils/create/index.ts
index 50ffb2931d..0cecf241bf 100644
--- a/src/packages/utils/create/index.ts
+++ b/src/packages/utils/create/index.ts
@@ -1,5 +1,5 @@
-import { createComponent } from './component';
-import { renderIcon } from './renderIcon';
+import { createComponent } from './component'
+import { renderIcon } from './renderIcon'
-export * from './mountComponent';
-export { createComponent, renderIcon };
+export * from './mountComponent'
+export { createComponent, renderIcon }
diff --git a/src/packages/utils/create/mountComponent.ts b/src/packages/utils/create/mountComponent.ts
index 24c1bb08a0..202f70a4d4 100644
--- a/src/packages/utils/create/mountComponent.ts
+++ b/src/packages/utils/create/mountComponent.ts
@@ -1,45 +1,45 @@
-import { createApp, Component } from 'vue';
-import { isFunction, isString } from '../util';
+import { createApp, Component } from 'vue'
+import { isFunction, isString } from '../util'
export const CreateComponent = (options: any, component: any) => {
- let elWrap: HTMLElement = document.body;
- const teleport = (options.teleport as string) || 'body';
+ let elWrap: HTMLElement = document.body
+ const teleport = (options.teleport as string) || 'body'
if (teleport != 'body') {
if (isString(teleport)) {
- elWrap = document.querySelector(teleport) as HTMLElement;
+ elWrap = document.querySelector(teleport) as HTMLElement
} else {
- elWrap = options.teleport as HTMLElement;
+ elWrap = options.teleport as HTMLElement
}
}
- const root = document.createElement('view');
- const name = component.name ? component.name + '-' : '';
- const id1 = options.id || new Date().getTime();
- root.id = name + id1;
+ const root = document.createElement('view')
+ const name = component.name ? component.name + '-' : ''
+ const id1 = options.id || new Date().getTime()
+ root.id = name + id1
- let Wrapper = {};
+ let Wrapper = {}
if (isFunction(component.wrapper)) {
- Wrapper = component.wrapper(elWrap, root);
+ Wrapper = component.wrapper(elWrap, root)
} else {
- Wrapper = component.wrapper;
+ Wrapper = component.wrapper
}
- const instance: Component = createApp(Wrapper, options);
+ const instance: Component = createApp(Wrapper, options)
- const componens = component.components;
+ const componens = component.components
componens &&
componens.forEach((comp: Component) => {
- instance.use(comp);
- });
+ instance.use(comp)
+ })
- elWrap.appendChild(root);
+ elWrap.appendChild(root)
return {
instance: instance.mount(root),
unmount: () => {
- instance.unmount();
- elWrap.removeChild(root);
+ instance.unmount()
+ elWrap.removeChild(root)
}
- };
-};
+ }
+}
diff --git a/src/packages/utils/create/renderIcon.ts b/src/packages/utils/create/renderIcon.ts
index c779e455cf..bf608add35 100644
--- a/src/packages/utils/create/renderIcon.ts
+++ b/src/packages/utils/create/renderIcon.ts
@@ -1,6 +1,6 @@
-import { h, Component } from 'vue';
+import { h, Component } from 'vue'
export const renderIcon = (icon: Component, props?: any) => {
- if (icon) return h(icon, props);
- return '';
-};
+ if (icon) return h(icon, props)
+ return ''
+}
diff --git a/src/packages/utils/date.ts b/src/packages/utils/date.ts
index ab8c169f87..904ff34185 100644
--- a/src/packages/utils/date.ts
+++ b/src/packages/utils/date.ts
@@ -4,7 +4,7 @@ const Utils = {
* @return {Boolse} true|false
*/
isLeapYear: function (y: number): boolean {
- return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
+ return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0
},
/**
@@ -12,10 +12,10 @@ const Utils = {
* @return {String}
*/
getWhatDay: function (year: number, month: number, day: number): string {
- const date = new Date(year + '/' + month + '/' + day);
- const index = date.getDay();
- const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
- return dayNames[index];
+ const date = new Date(year + '/' + month + '/' + day)
+ const index = date.getDay()
+ const dayNames = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
+ return dayNames[index]
},
/**
@@ -23,12 +23,12 @@ const Utils = {
* @return {Number}
*/
getMonthPreDay: function (year: number, month: number): number {
- const date = new Date(year + '/' + month + '/01');
- let day = date.getDay();
+ const date = new Date(year + '/' + month + '/01')
+ let day = date.getDay()
if (day == 0) {
- day = 7;
+ day = 7
}
- return day;
+ return day
},
/**
@@ -37,11 +37,11 @@ const Utils = {
*/
getMonthDays: function (year: string, month: string): number {
if (/^0/.test(month)) {
- month = month.split('')[1];
+ month = month.split('')[1]
}
return ([0, 31, this.isLeapYear(Number(year)) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] as number[])[
month as any
- ];
+ ]
},
/**
@@ -49,8 +49,8 @@ const Utils = {
* @return {string}
*/
getNumTwoBit: function (n: number): string {
- n = Number(n);
- return (n > 9 ? '' : '0') + n;
+ n = Number(n)
+ return (n > 9 ? '' : '0') + n
},
/**
@@ -58,11 +58,11 @@ const Utils = {
* @return {string}
*/
date2Str: function (date: Date, split?: string): string {
- split = split || '-';
- const y = date.getFullYear();
- const m = this.getNumTwoBit(date.getMonth() + 1);
- const d = this.getNumTwoBit(date.getDate());
- return [y, m, d].join(split);
+ split = split || '-'
+ const y = date.getFullYear()
+ const m = this.getNumTwoBit(date.getMonth() + 1)
+ const d = this.getNumTwoBit(date.getDate())
+ return [y, m, d].join(split)
},
/**
@@ -71,11 +71,11 @@ const Utils = {
* @return {string} '2014-12-31'
*/
getDay: function (i: number): string {
- i = i || 0;
- let date = new Date();
- const diff = i * (1000 * 60 * 60 * 24);
- date = new Date(date.getTime() + diff);
- return this.date2Str(date);
+ i = i || 0
+ let date = new Date()
+ const diff = i * (1000 * 60 * 60 * 24)
+ date = new Date(date.getTime() + diff)
+ return this.date2Str(date)
},
/**
@@ -83,12 +83,12 @@ const Utils = {
* @return {Boolean}
*/
compareDate: function (date1: string, date2: string): boolean {
- const startTime = new Date(date1.replace('-', '/').replace('-', '/'));
- const endTime = new Date(date2.replace('-', '/').replace('-', '/'));
+ const startTime = new Date(date1.replace('-', '/').replace('-', '/'))
+ const endTime = new Date(date2.replace('-', '/').replace('-', '/'))
if (startTime >= endTime) {
- return false;
+ return false
}
- return true;
+ return true
},
/**
@@ -96,65 +96,65 @@ const Utils = {
* @return {Boolean}
*/
isEqual: function (date1: string, date2: string): boolean {
- const startTime = new Date(date1).getTime();
- const endTime = new Date(date2).getTime();
+ const startTime = new Date(date1).getTime()
+ const endTime = new Date(date2).getTime()
if (startTime == endTime) {
- return true;
+ return true
}
- return false;
+ return false
},
getMonthWeek: function (year: string, month: string, date: string, firstDayOfWeek: number = 0): number {
- const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date));
- let w = dateNow.getDay(); //星期数
- let d = dateNow.getDate();
- let remainder = 6 - w;
+ const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date))
+ let w = dateNow.getDay() //星期数
+ let d = dateNow.getDate()
+ let remainder = 6 - w
if (firstDayOfWeek !== 0) {
- w = w == 0 ? 7 : w;
- remainder = 7 - w;
+ w = w == 0 ? 7 : w
+ remainder = 7 - w
}
- return Math.ceil((d + remainder) / 7);
+ return Math.ceil((d + remainder) / 7)
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
getYearWeek: function (year: string, month: string, date: string, firstDayOfWeek: number = 0): number {
- const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date));
- const dateFirst = new Date(Number(year), 0, 1);
- const dataNumber = Math.round((dateNow.valueOf() - dateFirst.valueOf()) / 86400000);
- return Math.ceil((dataNumber + (dateFirst.getDay() + 1 - 1)) / 7);
+ const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date))
+ const dateFirst = new Date(Number(year), 0, 1)
+ const dataNumber = Math.round((dateNow.valueOf() - dateFirst.valueOf()) / 86400000)
+ return Math.ceil((dataNumber + (dateFirst.getDay() + 1 - 1)) / 7)
},
getWeekDate: function (year: string, month: string, date: string, firstDayOfWeek: number = 0): string[] {
- const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date));
- const nowTime = dateNow.getTime();
- let day = dateNow.getDay();
+ const dateNow = new Date(Number(year), parseInt(month) - 1, Number(date))
+ const nowTime = dateNow.getTime()
+ let day = dateNow.getDay()
if (firstDayOfWeek === 0) {
- const oneDayTime = 24 * 60 * 60 * 1000;
+ const oneDayTime = 24 * 60 * 60 * 1000
//显示周日
- const SundayTime = nowTime - day * oneDayTime; //本周的周日
+ const SundayTime = nowTime - day * oneDayTime //本周的周日
//显示周六
- const SaturdayTime = nowTime + (6 - day) * oneDayTime; //本周的周六
+ const SaturdayTime = nowTime + (6 - day) * oneDayTime //本周的周六
- const sunday = this.date2Str(new Date(SundayTime));
- const saturday = this.date2Str(new Date(SaturdayTime));
- return [sunday, saturday];
+ const sunday = this.date2Str(new Date(SundayTime))
+ const saturday = this.date2Str(new Date(SaturdayTime))
+ return [sunday, saturday]
} else {
- day = day == 0 ? 7 : day;
- const oneDayTime = 24 * 60 * 60 * 1000;
+ day = day == 0 ? 7 : day
+ const oneDayTime = 24 * 60 * 60 * 1000
//显示周一
- const MondayTime = nowTime - (day - 1) * oneDayTime; //本周的周一
+ const MondayTime = nowTime - (day - 1) * oneDayTime //本周的周一
//显示周日
- const SundayTime = nowTime + (7 - day) * oneDayTime; //本周的周日
+ const SundayTime = nowTime + (7 - day) * oneDayTime //本周的周日
- const monday = this.date2Str(new Date(MondayTime));
- const sunday = this.date2Str(new Date(SundayTime));
- return [monday, sunday];
+ const monday = this.date2Str(new Date(MondayTime))
+ const sunday = this.date2Str(new Date(SundayTime))
+ return [monday, sunday]
}
},
formatResultDate: function (date: string) {
- let days = [...date.split('-')];
- days[2] = Utils.getNumTwoBit(Number(days[2]));
- days[3] = `${days[0]}-${days[1]}-${days[2]}`;
- days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2]);
- return days;
+ let days = [...date.split('-')]
+ days[2] = Utils.getNumTwoBit(Number(days[2]))
+ days[3] = `${days[0]}-${days[1]}-${days[2]}`
+ days[4] = Utils.getWhatDay(+days[0], +days[1], +days[2])
+ return days
}
-};
+}
-export default Utils;
+export default Utils
diff --git a/src/packages/utils/index.ts b/src/packages/utils/index.ts
index 2cb7b81678..e44ec2c57b 100644
--- a/src/packages/utils/index.ts
+++ b/src/packages/utils/index.ts
@@ -1,3 +1,3 @@
-export * from './useRelation';
-export * from './with-install';
-export * from './util';
+export * from './useRelation'
+export * from './with-install'
+export * from './util'
diff --git a/src/packages/utils/pxCheck.ts b/src/packages/utils/pxCheck.ts
index 5ce85ea6b4..7e61be0223 100644
--- a/src/packages/utils/pxCheck.ts
+++ b/src/packages/utils/pxCheck.ts
@@ -1,5 +1,5 @@
export const pxCheck = (value?: string | number): string | undefined => {
if (value !== undefined) {
- return isNaN(Number(value)) ? String(value) : `${value}px`;
+ return isNaN(Number(value)) ? String(value) : `${value}px`
}
-};
+}
diff --git a/src/packages/utils/raf.ts b/src/packages/utils/raf.ts
index 9b84deac6e..89b35dceaa 100644
--- a/src/packages/utils/raf.ts
+++ b/src/packages/utils/raf.ts
@@ -1,6 +1,6 @@
-const _window = window as any;
+const _window = window as any
-export const inBrowser = typeof window !== 'undefined';
+export const inBrowser = typeof window !== 'undefined'
function requestAniFrame() {
if (typeof _window !== 'undefined') {
@@ -8,22 +8,22 @@ function requestAniFrame() {
_window.requestAnimationFrame ||
_window.webkitRequestAnimationFrame ||
function (callback: Function) {
- _window.setTimeout(callback, 1000 / 60);
+ _window.setTimeout(callback, 1000 / 60)
}
- );
+ )
} else {
return function (callback: Function) {
- setTimeout(callback, 1000 / 60);
- };
+ setTimeout(callback, 1000 / 60)
+ }
}
}
export function cancelRaf(id: number) {
if (inBrowser) {
- cancelAnimationFrame(id);
+ cancelAnimationFrame(id)
} else {
- clearTimeout(id);
+ clearTimeout(id)
}
}
-export default requestAniFrame();
+export default requestAniFrame()
diff --git a/src/packages/utils/throttle.ts b/src/packages/utils/throttle.ts
index ae3c33dcc8..67d63d36c5 100644
--- a/src/packages/utils/throttle.ts
+++ b/src/packages/utils/throttle.ts
@@ -4,13 +4,13 @@
* @param delay
*/
export function debounce(fn: Function, delay: number) {
- let timer: null | number = null;
+ let timer: null | number = null
return function () {
- if (timer) clearTimeout(timer);
+ if (timer) clearTimeout(timer)
- timer = setTimeout(fn, delay);
- };
+ timer = setTimeout(fn, delay)
+ }
}
/**
@@ -19,18 +19,18 @@ export function debounce(fn: Function, delay: number) {
* @param delay
*/
export function throttle(fn: Function, delay: number) {
- let timer: number | null = null;
- let startTime = Date.now();
+ let timer: number | null = null
+ let startTime = Date.now()
return function () {
- let now = Date.now();
- let remaining = delay - (now - startTime);
- if (timer) clearTimeout(timer);
+ let now = Date.now()
+ let remaining = delay - (now - startTime)
+ if (timer) clearTimeout(timer)
if (remaining <= 0) {
- fn.apply(null, arguments);
- startTime = Date.now();
+ fn.apply(null, arguments)
+ startTime = Date.now()
} else {
- timer = setTimeout(fn, remaining);
+ timer = setTimeout(fn, remaining)
}
- };
+ }
}
diff --git a/src/packages/utils/touchEmulator.js b/src/packages/utils/touchEmulator.js
index ef88249999..18eca46495 100644
--- a/src/packages/utils/touchEmulator.js
+++ b/src/packages/utils/touchEmulator.js
@@ -4,12 +4,12 @@
* Source:https://github.com/hammerjs/touchemulator
*/
-(function () {
+;(function () {
if (typeof window === 'undefined') {
- return;
+ return
}
- var eventTarget;
- var supportTouch = 'ontouchstart' in window;
+ var eventTarget
+ var supportTouch = 'ontouchstart' in window
// polyfills
if (!document.createTouch) {
@@ -28,19 +28,19 @@
},
0,
0
- );
- };
+ )
+ }
}
if (!document.createTouchList) {
document.createTouchList = function () {
- var touchList = TouchList();
+ var touchList = TouchList()
for (var i = 0; i < arguments.length; i++) {
- touchList[i] = arguments[i];
+ touchList[i] = arguments[i]
}
- touchList.length = arguments.length;
- return touchList;
- };
+ touchList.length = arguments.length
+ return touchList
+ }
}
/**
@@ -55,18 +55,18 @@
*/
var Touch = function Touch(target, identifier, pos, deltaX, deltaY) {
- deltaX = deltaX || 0;
- deltaY = deltaY || 0;
-
- this.identifier = identifier;
- this.target = target;
- this.clientX = pos.clientX + deltaX;
- this.clientY = pos.clientY + deltaY;
- this.screenX = pos.screenX + deltaX;
- this.screenY = pos.screenY + deltaY;
- this.pageX = pos.pageX + deltaX;
- this.pageY = pos.pageY + deltaY;
- };
+ deltaX = deltaX || 0
+ deltaY = deltaY || 0
+
+ this.identifier = identifier
+ this.target = target
+ this.clientX = pos.clientX + deltaX
+ this.clientY = pos.clientY + deltaY
+ this.screenX = pos.screenX + deltaX
+ this.screenY = pos.screenY + deltaY
+ this.pageX = pos.pageX + deltaX
+ this.pageY = pos.pageY + deltaY
+ }
/**
* create empty touchlist with the methods
@@ -74,18 +74,18 @@
* @returns touchList
*/
function TouchList() {
- var touchList = [];
+ var touchList = []
touchList['item'] = function (index) {
- return this[index] || null;
- };
+ return this[index] || null
+ }
// specified by Mozilla
touchList['identifiedTouch'] = function (id) {
- return this[id + 1] || null;
- };
+ return this[id + 1] || null
+ }
- return touchList;
+ return touchList
}
/**
@@ -94,37 +94,37 @@
* @returns {Function}
*/
- var initiated = false;
+ var initiated = false
function onMouse(touchType) {
return function (ev) {
// prevent mouse events
if (ev.type === 'mousedown') {
- initiated = true;
+ initiated = true
}
if (ev.type === 'mouseup') {
- initiated = false;
+ initiated = false
}
if (ev.type === 'mousemove' && !initiated) {
- return;
+ return
}
// The EventTarget on which the touch point started when it was first placed on the surface,
// even if the touch point has since moved outside the interactive area of that element.
// also, when the target doesnt exist anymore, we update it
if (ev.type === 'mousedown' || !eventTarget || (eventTarget && !eventTarget.dispatchEvent)) {
- eventTarget = ev.target;
+ eventTarget = ev.target
}
- triggerTouch(touchType, ev);
+ triggerTouch(touchType, ev)
// reset
if (ev.type === 'mouseup') {
- eventTarget = null;
+ eventTarget = null
}
- };
+ }
}
/**
@@ -133,19 +133,19 @@
* @param mouseEv
*/
function triggerTouch(eventName, mouseEv) {
- var touchEvent = document.createEvent('Event');
- touchEvent.initEvent(eventName, true, true);
+ var touchEvent = document.createEvent('Event')
+ touchEvent.initEvent(eventName, true, true)
- touchEvent.altKey = mouseEv.altKey;
- touchEvent.ctrlKey = mouseEv.ctrlKey;
- touchEvent.metaKey = mouseEv.metaKey;
- touchEvent.shiftKey = mouseEv.shiftKey;
+ touchEvent.altKey = mouseEv.altKey
+ touchEvent.ctrlKey = mouseEv.ctrlKey
+ touchEvent.metaKey = mouseEv.metaKey
+ touchEvent.shiftKey = mouseEv.shiftKey
- touchEvent.touches = getActiveTouches(mouseEv);
- touchEvent.targetTouches = getActiveTouches(mouseEv);
- touchEvent.changedTouches = createTouchList(mouseEv);
+ touchEvent.touches = getActiveTouches(mouseEv)
+ touchEvent.targetTouches = getActiveTouches(mouseEv)
+ touchEvent.changedTouches = createTouchList(mouseEv)
- eventTarget.dispatchEvent(touchEvent);
+ eventTarget.dispatchEvent(touchEvent)
}
/**
@@ -154,9 +154,9 @@
* @returns {TouchList}
*/
function createTouchList(mouseEv) {
- var touchList = TouchList();
- touchList.push(new Touch(eventTarget, 1, mouseEv, 0, 0));
- return touchList;
+ var touchList = TouchList()
+ touchList.push(new Touch(eventTarget, 1, mouseEv, 0, 0))
+ return touchList
}
/**
@@ -167,24 +167,24 @@
function getActiveTouches(mouseEv) {
// empty list
if (mouseEv.type === 'mouseup') {
- return TouchList();
+ return TouchList()
}
- return createTouchList(mouseEv);
+ return createTouchList(mouseEv)
}
/**
* TouchEmulator initializer
*/
function TouchEmulator() {
- window.addEventListener('mousedown', onMouse('touchstart'), true);
- window.addEventListener('mousemove', onMouse('touchmove'), true);
- window.addEventListener('mouseup', onMouse('touchend'), true);
+ window.addEventListener('mousedown', onMouse('touchstart'), true)
+ window.addEventListener('mousemove', onMouse('touchmove'), true)
+ window.addEventListener('mouseup', onMouse('touchend'), true)
}
// start distance when entering the multitouch mode
- TouchEmulator['multiTouchOffset'] = 75;
+ TouchEmulator['multiTouchOffset'] = 75
if (!supportTouch) {
- new TouchEmulator();
+ new TouchEmulator()
}
-})();
+})()
diff --git a/src/packages/utils/unit.ts b/src/packages/utils/unit.ts
index 57cb3a1f8e..959ba963a5 100644
--- a/src/packages/utils/unit.ts
+++ b/src/packages/utils/unit.ts
@@ -1,6 +1,6 @@
-import { ComponentPublicInstance, nextTick } from 'vue';
-import { VueWrapper, DOMWrapper } from '@vue/test-utils';
-import { Mock, vi } from 'vitest';
+import { ComponentPublicInstance, nextTick } from 'vue'
+import { VueWrapper, DOMWrapper } from '@vue/test-utils'
+import { Mock, vi } from 'vitest'
function getTouch(el: Element | Window, x: number, y: number) {
return {
@@ -14,7 +14,7 @@ function getTouch(el: Element | Window, x: number, y: number) {
radiusY: 2.5,
rotationAngle: 10,
force: 0.5
- };
+ }
}
export function trigger(
@@ -24,15 +24,15 @@ export function trigger(
y = 0,
options: any = {}
) {
- const el = 'element' in wrapper ? wrapper.element : wrapper;
- const touchList = options.touchList || [getTouch(el, x, y)];
+ const el = 'element' in wrapper ? wrapper.element : wrapper
+ const touchList = options.touchList || [getTouch(el, x, y)]
if (options.x || options.y) {
- touchList.push(getTouch(el, options.x, options.y));
+ touchList.push(getTouch(el, options.x, options.y))
}
- const event = document.createEvent('CustomEvent');
- event.initCustomEvent(eventName, true, true, {});
+ const event = document.createEvent('CustomEvent')
+ event.initCustomEvent(eventName, true, true, {})
Object.assign(event, {
clientX: x,
@@ -40,56 +40,56 @@ export function trigger(
touches: touchList,
targetTouches: touchList,
changedTouches: touchList
- });
+ })
- el.dispatchEvent(event);
+ el.dispatchEvent(event)
- return nextTick();
+ return nextTick()
}
export async function mockScrollTop(value: number) {
- Object.defineProperty(window, 'scrollTop', { value, writable: true });
- trigger(window, 'scroll');
- return nextTick();
+ Object.defineProperty(window, 'scrollTop', { value, writable: true })
+ trigger(window, 'scroll')
+ return nextTick()
}
// task sleep
export function sleep(delay = 0): Promise {
return new Promise((resolve) => {
- setTimeout(resolve, delay);
- });
+ setTimeout(resolve, delay)
+ })
}
export function triggerDrag(el: any, relativeX = 0, relativeY = 0): void {
- let x = relativeX;
- let y = relativeY;
- let startX = 0;
- let startY = 0;
+ let x = relativeX
+ let y = relativeY
+ let startX = 0
+ let startY = 0
if (relativeX < 0) {
- startX = Math.abs(relativeX);
- x = 0;
+ startX = Math.abs(relativeX)
+ x = 0
}
if (relativeY < 0) {
- startY = Math.abs(relativeY);
- y = 0;
+ startY = Math.abs(relativeY)
+ y = 0
}
- trigger(el, 'touchstart', startX, startY);
- trigger(el, 'touchmove', x / 4, y / 4);
- trigger(el, 'touchmove', x / 3, y / 3);
- trigger(el, 'touchmove', x / 2, y / 2);
- trigger(el, 'touchmove', x, y);
- trigger(el, 'touchend', x, y);
+ trigger(el, 'touchstart', startX, startY)
+ trigger(el, 'touchmove', x / 4, y / 4)
+ trigger(el, 'touchmove', x / 3, y / 3)
+ trigger(el, 'touchmove', x / 2, y / 2)
+ trigger(el, 'touchmove', x, y)
+ trigger(el, 'touchend', x, y)
}
// mock element method
export function mockElementMethod(element: any, method: string): Mock {
- const fn = vi.fn();
- element.prototype[method] = fn;
- return fn;
+ const fn = vi.fn()
+ element.prototype[method] = fn
+ return fn
}
// mock getBoundingClientRect
export function mockGetBoundingClientRect(rect: any): () => void {
- const spy = vi.spyOn(Element.prototype, 'getBoundingClientRect');
- spy.mockReturnValue(rect);
- return () => spy.mockRestore();
+ const spy = vi.spyOn(Element.prototype, 'getBoundingClientRect')
+ spy.mockReturnValue(rect)
+ return () => spy.mockRestore()
}
diff --git a/src/packages/utils/useExpose/index.ts b/src/packages/utils/useExpose/index.ts
index fa43c9f0ae..ef4c473b68 100644
--- a/src/packages/utils/useExpose/index.ts
+++ b/src/packages/utils/useExpose/index.ts
@@ -1,8 +1,8 @@
-import { getCurrentInstance, ComponentPublicInstance } from 'vue';
+import { getCurrentInstance, ComponentPublicInstance } from 'vue'
export function useExpose(apis: Record) {
- const instance = getCurrentInstance();
+ const instance = getCurrentInstance()
if (instance) {
- Object.assign(instance.proxy as ComponentPublicInstance, apis);
+ Object.assign(instance.proxy as ComponentPublicInstance, apis)
}
}
diff --git a/src/packages/utils/useLocale/index.ts b/src/packages/utils/useLocale/index.ts
index eda3528922..3d7cdaab06 100644
--- a/src/packages/utils/useLocale/index.ts
+++ b/src/packages/utils/useLocale/index.ts
@@ -1,15 +1,15 @@
-import locale from '@/packages/locale';
-import { getPropByPath, isFunction } from '../util';
+import locale from '@/packages/locale'
+import { getPropByPath, isFunction } from '../util'
export const useLocale = (name = '') => {
return (keyPath: T, ...args: unknown[]) => {
- name = name.toLocaleLowerCase();
- const languages = locale.languages();
- let text: string = keyPath;
+ name = name.toLocaleLowerCase()
+ const languages = locale.languages()
+ let text: string = keyPath
if (name && name.startsWith('nut')) {
- text = `${name.slice(3)}.${keyPath}`;
+ text = `${name.slice(3)}.${keyPath}`
}
- const res = getPropByPath(languages, text) || getPropByPath(languages, keyPath);
- return isFunction(res) ? res(...args) : res;
- };
-};
+ const res = getPropByPath(languages, text) || getPropByPath(languages, keyPath)
+ return isFunction(res) ? res(...args) : res
+ }
+}
diff --git a/src/packages/utils/useLockScroll/index.ts b/src/packages/utils/useLockScroll/index.ts
index f3231d3fe0..b47ef1d721 100644
--- a/src/packages/utils/useLockScroll/index.ts
+++ b/src/packages/utils/useLockScroll/index.ts
@@ -1,30 +1,30 @@
-import { body } from '@/packages/utils/util';
-let count = 0;
+import { body } from '@/packages/utils/util'
+let count = 0
-const CLSNAME = 'nut-overflow-hidden';
+const CLSNAME = 'nut-overflow-hidden'
export const useLockScroll = (isLock: () => boolean) => {
const lock = () => {
if (isLock()) {
try {
- !count && body.classList.add(CLSNAME);
- count++;
+ !count && body.classList.add(CLSNAME)
+ count++
} catch (error) {
- console.warn('[NutUI] ', error);
+ console.warn('[NutUI] ', error)
}
}
- };
+ }
const unlock = () => {
if (isLock() && count) {
try {
- count--;
- !count && body.classList.remove(CLSNAME);
+ count--
+ !count && body.classList.remove(CLSNAME)
} catch (error) {
- console.warn('[NutUI] ', error);
+ console.warn('[NutUI] ', error)
}
}
- };
+ }
- return [lock, unlock];
-};
+ return [lock, unlock]
+}
diff --git a/src/packages/utils/useRect/index.ts b/src/packages/utils/useRect/index.ts
index dcee63537a..a0a4aaf1a0 100644
--- a/src/packages/utils/useRect/index.ts
+++ b/src/packages/utils/useRect/index.ts
@@ -8,27 +8,27 @@
bottom 底部与视图窗口左上角的距离 number
*/
-import { Ref, unref } from 'vue';
+import { Ref, unref } from 'vue'
function isWindow(val: unknown): val is Window {
- return typeof window !== 'undefined' && val === window;
+ return typeof window !== 'undefined' && val === window
}
export interface rect {
- top: number;
- left: number;
- right: number;
- bottom: number;
- width: number;
- height: number;
+ top: number
+ left: number
+ right: number
+ bottom: number
+ width: number
+ height: number
}
export const useRect = (elementRef: (Element | Window) | Ref) => {
- const element = unref(elementRef);
+ const element = unref(elementRef)
if (isWindow(element)) {
- const width = element.innerWidth;
- const height = element.innerHeight;
+ const width = element.innerWidth
+ const height = element.innerHeight
return {
top: 0,
@@ -37,11 +37,11 @@ export const useRect = (elementRef: (Element | Window) | Ref {
- const publicChildren = reactive([]);
- const internalChildren = reactive([]);
+ const publicChildren = reactive([])
+ const internalChildren = reactive([])
const linkChildren = (value?: any) => {
const link = (child: any) => {
if (child.proxy) {
- internalChildren.push(child);
- publicChildren.push(child.proxy);
+ internalChildren.push(child)
+ publicChildren.push(child.proxy)
}
- };
+ }
const unlink = (child: any) => {
if (child.proxy) {
- let internalIndex = internalChildren.indexOf(child);
+ let internalIndex = internalChildren.indexOf(child)
if (internalIndex > -1) {
- internalChildren.splice(internalIndex, 1);
+ internalChildren.splice(internalIndex, 1)
}
- let publicIndex = publicChildren.indexOf(child.proxy);
+ let publicIndex = publicChildren.indexOf(child.proxy)
if (internalIndex > -1) {
- publicChildren.splice(publicIndex, 1);
+ publicChildren.splice(publicIndex, 1)
}
}
- };
+ }
provide(key, {
unlink,
@@ -32,11 +32,11 @@ export const useChildren = (key: symbol) => {
children: publicChildren,
internalChildren,
...value
- });
- };
+ })
+ }
return {
children: publicChildren,
linkChildren
- };
-};
+ }
+}
diff --git a/src/packages/utils/useRelation/useInject.ts b/src/packages/utils/useRelation/useInject.ts
index b2245ce2a9..0c34b7ecd8 100644
--- a/src/packages/utils/useRelation/useInject.ts
+++ b/src/packages/utils/useRelation/useInject.ts
@@ -1,32 +1,32 @@
-import { ref, inject, computed, onUnmounted, getCurrentInstance } from 'vue';
-import type { InjectionKey, ComponentInternalInstance } from 'vue';
+import { ref, inject, computed, onUnmounted, getCurrentInstance } from 'vue'
+import type { InjectionKey, ComponentInternalInstance } from 'vue'
type ParentProvide = T & {
- add(child: ComponentInternalInstance): void;
- remove(child: ComponentInternalInstance): void;
- internalChildren: ComponentInternalInstance[];
-};
+ add(child: ComponentInternalInstance): void
+ remove(child: ComponentInternalInstance): void
+ internalChildren: ComponentInternalInstance[]
+}
export function useInject(key: InjectionKey>) {
- const parent = inject(key, null);
+ const parent = inject(key, null)
if (parent) {
- const instance = getCurrentInstance()!;
- const { add, remove, internalChildren } = parent;
+ const instance = getCurrentInstance()!
+ const { add, remove, internalChildren } = parent
- add(instance);
- onUnmounted(() => remove(instance));
+ add(instance)
+ onUnmounted(() => remove(instance))
- const index = computed(() => internalChildren.indexOf(instance));
+ const index = computed(() => internalChildren.indexOf(instance))
return {
parent,
index
- };
+ }
}
return {
parent: null,
index: ref(-1)
- };
+ }
}
diff --git a/src/packages/utils/useRelation/useParent.ts b/src/packages/utils/useRelation/useParent.ts
index eaaf07d9a9..06867dec75 100644
--- a/src/packages/utils/useRelation/useParent.ts
+++ b/src/packages/utils/useRelation/useParent.ts
@@ -1,23 +1,23 @@
-import { getCurrentInstance, computed, inject, onUnmounted } from 'vue';
+import { getCurrentInstance, computed, inject, onUnmounted } from 'vue'
export const useParent = (key: symbol) => {
- const parent = inject(key, null);
+ const parent = inject(key, null)
if (parent) {
- const instance = getCurrentInstance()!;
- const { link, unlink, internalChildren } = parent;
+ const instance = getCurrentInstance()!
+ const { link, unlink, internalChildren } = parent
- link(instance);
+ link(instance)
onUnmounted(() => {
- unlink(instance);
- });
- const index = computed(() => internalChildren.indexOf(instance));
+ unlink(instance)
+ })
+ const index = computed(() => internalChildren.indexOf(instance))
- return { parent, index };
+ return { parent, index }
}
return {
parent,
index: computed(() => -1)
- };
-};
+ }
+}
diff --git a/src/packages/utils/useRelation/useProvide.ts b/src/packages/utils/useRelation/useProvide.ts
index 56536d6123..02326dec8f 100644
--- a/src/packages/utils/useRelation/useProvide.ts
+++ b/src/packages/utils/useRelation/useProvide.ts
@@ -1,36 +1,36 @@
-import { isVNode, provide, markRaw, shallowReactive, getCurrentInstance } from 'vue';
-import type { VNode, InjectionKey, ConcreteComponent, VNodeNormalizedChildren, ComponentInternalInstance } from 'vue';
+import { isVNode, provide, markRaw, shallowReactive, getCurrentInstance } from 'vue'
+import type { VNode, InjectionKey, ConcreteComponent, VNodeNormalizedChildren, ComponentInternalInstance } from 'vue'
export function flattenVNodes(children: VNodeNormalizedChildren, childName?: string) {
- const result: VNode[] = [];
+ const result: VNode[] = []
const traverse = (children: VNodeNormalizedChildren) => {
- if (!Array.isArray(children)) return;
+ if (!Array.isArray(children)) return
children.forEach((child) => {
- if (!isVNode(child)) return;
+ if (!isVNode(child)) return
if (childName) {
if (child.type && (child.type as ConcreteComponent).name === childName) {
- result.push(child);
- return;
+ result.push(child)
+ return
}
} else {
- result.push(child);
+ result.push(child)
}
if (child.component?.subTree) {
- traverse(child.component.subTree.children);
+ traverse(child.component.subTree.children)
}
if (child.children) {
- traverse(child.children);
+ traverse(child.children)
}
- });
- };
+ })
+ }
- traverse(children);
+ traverse(children)
- return result;
+ return result
}
export function sortChildren(
@@ -38,28 +38,28 @@ export function sortChildren(
internalChildren: ComponentInternalInstance[],
childName?: string
) {
- const vnodes = flattenVNodes(parent.subTree.children, childName);
+ const vnodes = flattenVNodes(parent.subTree.children, childName)
internalChildren.sort((a, b) => {
- return vnodes.indexOf(a.vnode) - vnodes.indexOf(b.vnode);
- });
+ return vnodes.indexOf(a.vnode) - vnodes.indexOf(b.vnode)
+ })
}
// 如果指定组件名称,则只查找此组件并且查到后结束。也就是不关心此组件下的内容,在大部分场景下节省查找消耗。
export function useProvide(key: InjectionKey, childName?: string) {
- const internalChildren: ComponentInternalInstance[] = shallowReactive([]);
- const parent = getCurrentInstance()!;
+ const internalChildren: ComponentInternalInstance[] = shallowReactive([])
+ const parent = getCurrentInstance()!
const add = (child: ComponentInternalInstance) => {
- if (!child.proxy) return;
- internalChildren.push(markRaw(child));
- sortChildren(parent, internalChildren, childName);
- };
+ if (!child.proxy) return
+ internalChildren.push(markRaw(child))
+ sortChildren(parent, internalChildren, childName)
+ }
const remove = (child: ComponentInternalInstance) => {
- internalChildren.splice(internalChildren.indexOf(markRaw(child)), 1);
- };
+ internalChildren.splice(internalChildren.indexOf(markRaw(child)), 1)
+ }
- const extend = Object.assign;
+ const extend = Object.assign
return (value?: ProvideValue) => {
provide(
key,
@@ -71,10 +71,10 @@ export function useProvide(key: InjectionKey, childN
},
value
)
- );
+ )
return {
internalChildren
- };
- };
+ }
+ }
}
diff --git a/src/packages/utils/useRelation/useRelation.ts b/src/packages/utils/useRelation/useRelation.ts
index c2a859a972..fa70296908 100644
--- a/src/packages/utils/useRelation/useRelation.ts
+++ b/src/packages/utils/useRelation/useRelation.ts
@@ -1,7 +1,7 @@
-import { getCurrentInstance, ComponentPublicInstance } from 'vue';
+import { getCurrentInstance, ComponentPublicInstance } from 'vue'
export function useExtend(apis: T) {
- const instance = getCurrentInstance();
+ const instance = getCurrentInstance()
if (instance) {
- Object.assign(instance.proxy as ComponentPublicInstance, apis);
+ Object.assign(instance.proxy as ComponentPublicInstance, apis)
}
}
diff --git a/src/packages/utils/useRoute/index.ts b/src/packages/utils/useRoute/index.ts
index ba7f1ac242..faf1ac6d73 100644
--- a/src/packages/utils/useRoute/index.ts
+++ b/src/packages/utils/useRoute/index.ts
@@ -1,6 +1,6 @@
-import { getCurrentInstance } from 'vue';
+import { getCurrentInstance } from 'vue'
export function useRouter() {
- const proxy = getCurrentInstance()!.proxy as any;
- return proxy.$router || null;
+ const proxy = getCurrentInstance()!.proxy as any
+ return proxy.$router || null
}
diff --git a/src/packages/utils/useScrollParent/index.ts b/src/packages/utils/useScrollParent/index.ts
index 1df91f75e0..be33815ff1 100644
--- a/src/packages/utils/useScrollParent/index.ts
+++ b/src/packages/utils/useScrollParent/index.ts
@@ -1,37 +1,37 @@
-import { ref, Ref, onMounted } from 'vue';
+import { ref, Ref, onMounted } from 'vue'
-type ScrollElement = HTMLElement | Window;
+type ScrollElement = HTMLElement | Window
-const overflowScrollReg = /scroll|auto|overlay/i;
-const defaultRoot = window;
+const overflowScrollReg = /scroll|auto|overlay/i
+const defaultRoot = window
function isElement(node: Element) {
- const ELEMENT_NODE_TYPE = 1;
- return node.tagName !== 'HTML' && node.tagName !== 'BODY' && node.nodeType === ELEMENT_NODE_TYPE;
+ const ELEMENT_NODE_TYPE = 1
+ return node.tagName !== 'HTML' && node.tagName !== 'BODY' && node.nodeType === ELEMENT_NODE_TYPE
}
export function getScrollParent(el: Element, root: ScrollElement | undefined = defaultRoot) {
- let node = el;
+ let node = el
while (node && node !== root && isElement(node)) {
- const { overflowY } = window.getComputedStyle(node);
+ const { overflowY } = window.getComputedStyle(node)
if (overflowScrollReg.test(overflowY)) {
- return node;
+ return node
}
- node = node.parentNode as Element;
+ node = node.parentNode as Element
}
- return root;
+ return root
}
export function useScrollParent(el: Ref, root: ScrollElement | undefined = defaultRoot) {
- const scrollParent = ref();
+ const scrollParent = ref()
onMounted(() => {
if (el.value) {
- scrollParent.value = getScrollParent(el.value, root);
+ scrollParent.value = getScrollParent(el.value, root)
}
- });
+ })
- return scrollParent;
+ return scrollParent
}
diff --git a/src/packages/utils/useTaroRect/index.ts b/src/packages/utils/useTaroRect/index.ts
index 0314522963..dfdf6d3f79 100644
--- a/src/packages/utils/useTaroRect/index.ts
+++ b/src/packages/utils/useTaroRect/index.ts
@@ -7,56 +7,56 @@
right 右侧与视图窗口左上角的距离 number
bottom 底部与视图窗口左上角的距离 number
*/
-import Taro from '@tarojs/taro';
-import { Ref, unref } from 'vue';
+import Taro from '@tarojs/taro'
+import { Ref, unref } from 'vue'
function isWindow(val: unknown): val is Window {
- return typeof window !== 'undefined' && val === window;
+ return typeof window !== 'undefined' && val === window
}
export interface rectTaro {
- top: number;
- left: number;
- right: number;
- bottom: number;
- width: number;
- height: number;
+ top: number
+ left: number
+ right: number
+ bottom: number
+ width: number
+ height: number
}
export const useTaroRectById = (id: string) => {
return new Promise((resolve, reject) => {
if (Taro.getEnv() === Taro.ENV_TYPE.WEB) {
- const t = document ? document.querySelector(`#${id}`) : '';
+ const t = document ? document.querySelector(`#${id}`) : ''
if (t) {
- resolve(t?.getBoundingClientRect());
+ resolve(t?.getBoundingClientRect())
}
- reject();
+ reject()
} else {
- const query = Taro.createSelectorQuery();
+ const query = Taro.createSelectorQuery()
query
.select(`#${id}`)
.boundingClientRect()
.exec(function (rect: any) {
if (rect[0]) {
- resolve(rect[0]);
+ resolve(rect[0])
} else {
- reject();
+ reject()
}
- });
+ })
}
- });
-};
+ })
+}
export const useTaroRect = (elementRef: (Element | Window | any) | Ref): any => {
// 小程序下需要 el 具有 id 属性才能查询
- let element = unref(elementRef);
+ let element = unref(elementRef)
return new Promise((resolve, reject) => {
if (Taro.getEnv() === Taro.ENV_TYPE.WEB) {
if (element && element.$el) {
- element = element.$el;
+ element = element.$el
}
if (isWindow(element)) {
- const width = element.innerWidth;
- const height = element.innerHeight;
+ const width = element.innerWidth
+ const height = element.innerHeight
resolve({
top: 0,
left: 0,
@@ -64,29 +64,29 @@ export const useTaroRect = (elementRef: (Element | Window | any) | Ref y && x > MIN_DISTANCE) {
- return 'horizontal';
+ return 'horizontal'
}
if (y > x && y > MIN_DISTANCE) {
- return 'vertical';
+ return 'vertical'
}
- return '';
+ return ''
}
export function useTouch() {
- const startX = ref(0);
- const startY = ref(0);
- const moveX = ref(0);
- const moveY = ref(0);
- const deltaX = ref(0);
- const deltaY = ref(0);
- const offsetX = ref(0);
- const offsetY = ref(0);
- const direction = ref('');
+ const startX = ref(0)
+ const startY = ref(0)
+ const moveX = ref(0)
+ const moveY = ref(0)
+ const deltaX = ref(0)
+ const deltaY = ref(0)
+ const offsetX = ref(0)
+ const offsetY = ref(0)
+ const direction = ref('')
- const isVertical = () => direction.value === 'vertical';
- const isHorizontal = () => direction.value === 'horizontal';
+ const isVertical = () => direction.value === 'vertical'
+ const isHorizontal = () => direction.value === 'horizontal'
const reset = () => {
- deltaX.value = 0;
- deltaY.value = 0;
- offsetX.value = 0;
- offsetY.value = 0;
- direction.value = '';
- };
+ deltaX.value = 0
+ deltaY.value = 0
+ offsetX.value = 0
+ offsetY.value = 0
+ direction.value = ''
+ }
const start = (event: TouchEvent) => {
- reset();
- startX.value = event.touches[0].clientX;
- startY.value = event.touches[0].clientY;
- };
+ reset()
+ startX.value = event.touches[0].clientX
+ startY.value = event.touches[0].clientY
+ }
const move = (event: TouchEvent) => {
- const touch = event.touches[0];
- deltaX.value = touch.clientX - startX.value;
- deltaY.value = touch.clientY - startY.value;
- moveX.value = touch.clientX;
- moveY.value = touch.clientY;
- offsetX.value = Math.abs(deltaX.value);
- offsetY.value = Math.abs(deltaY.value);
+ const touch = event.touches[0]
+ deltaX.value = touch.clientX - startX.value
+ deltaY.value = touch.clientY - startY.value
+ moveX.value = touch.clientX
+ moveY.value = touch.clientY
+ offsetX.value = Math.abs(deltaX.value)
+ offsetY.value = Math.abs(deltaY.value)
if (!direction.value) {
- direction.value = getDirection(offsetX.value, offsetY.value);
+ direction.value = getDirection(offsetX.value, offsetY.value)
}
- };
+ }
return {
move,
@@ -71,5 +71,5 @@ export function useTouch() {
direction,
isVertical,
isHorizontal
- };
+ }
}
diff --git a/src/packages/utils/util.ts b/src/packages/utils/util.ts
index 7f07cdc3f8..ec00d0493d 100644
--- a/src/packages/utils/util.ts
+++ b/src/packages/utils/util.ts
@@ -1,146 +1,146 @@
-export * from './Interceptor';
+export * from './Interceptor'
// 变量类型判断
export const TypeOfFun = (value: any) => {
if (null === value) {
- return 'null';
+ return 'null'
}
- const type = typeof value;
+ const type = typeof value
if ('undefined' === type || 'string' === type) {
- return type;
+ return type
}
- const typeString = toString.call(value);
+ const typeString = toString.call(value)
switch (typeString) {
case '[object Array]':
- return 'array';
+ return 'array'
case '[object Date]':
- return 'date';
+ return 'date'
case '[object Boolean]':
- return 'boolean';
+ return 'boolean'
case '[object Number]':
- return 'number';
+ return 'number'
case '[object Function]':
- return 'function';
+ return 'function'
case '[object RegExp]':
- return 'regexp';
+ return 'regexp'
case '[object Object]':
if (undefined !== value.nodeType) {
if (3 == value.nodeType) {
- return /\S/.test(value.nodeValue) ? 'textnode' : 'whitespace';
+ return /\S/.test(value.nodeValue) ? 'textnode' : 'whitespace'
} else {
- return 'element';
+ return 'element'
}
} else {
- return 'object';
+ return 'object'
}
default:
- return 'unknow';
+ return 'unknow'
}
-};
+}
//
-export const objectToString = Object.prototype.toString;
-export const toTypeString = (value: unknown): string => objectToString.call(value);
+export const objectToString = Object.prototype.toString
+export const toTypeString = (value: unknown): string => objectToString.call(value)
export const toRawType = (value: unknown): string => {
// extract "RawType" from strings like "[object RawType]"
- return toTypeString(value).slice(8, -1);
-};
-export const isArray = Array.isArray;
-export const isMap = (val: unknown): val is Map => toTypeString(val) === '[object Map]';
-export const isSet = (val: unknown): val is Set => toTypeString(val) === '[object Set]';
-
-export const isDate = (val: unknown): val is Date => val instanceof Date;
-export const isFunction = (val: unknown): val is Function => typeof val === 'function';
-export const isString = (val: unknown): val is string => typeof val === 'string';
-export const isSymbol = (val: unknown): val is symbol => typeof val === 'symbol';
-export const isObject = (val: unknown): val is Record => val !== null && typeof val === 'object';
+ return toTypeString(value).slice(8, -1)
+}
+export const isArray = Array.isArray
+export const isMap = (val: unknown): val is Map => toTypeString(val) === '[object Map]'
+export const isSet = (val: unknown): val is Set => toTypeString(val) === '[object Set]'
+
+export const isDate = (val: unknown): val is Date => val instanceof Date
+export const isFunction = (val: unknown): val is Function => typeof val === 'function'
+export const isString = (val: unknown): val is string => typeof val === 'string'
+export const isSymbol = (val: unknown): val is symbol => typeof val === 'symbol'
+export const isObject = (val: unknown): val is Record => val !== null && typeof val === 'object'
export const isPromise = (val: unknown): val is Promise => {
- return isObject(val) && isFunction(val.then) && isFunction(val.catch);
-};
+ return isObject(val) && isFunction(val.then) && isFunction(val.catch)
+}
-export const win = window;
+export const win = window
-export const docu = document;
+export const docu = document
-export const body = docu.body;
+export const body = docu.body
export const getPropByPath = (obj: any, keyPath: string) => {
try {
- return keyPath.split('.').reduce((prev, curr) => prev[curr], obj);
+ return keyPath.split('.').reduce((prev, curr) => prev[curr], obj)
} catch (error) {
- return '';
+ return ''
}
-};
+}
export const floatData = (format: any, dataOp: any, mapOps: any) => {
- let mergeFormat = Object.assign({}, format);
- let mergeMapOps = Object.assign({}, mapOps);
+ let mergeFormat = Object.assign({}, format)
+ let mergeMapOps = Object.assign({}, mapOps)
if (Object.keys(dataOp).length > 0) {
Object.keys(mergeFormat).forEach((keys) => {
if (Object.prototype.hasOwnProperty.call(mergeMapOps, keys)) {
- const tof = TypeOfFun(mergeMapOps[keys]);
+ const tof = TypeOfFun(mergeMapOps[keys])
if (tof == 'function') {
- mergeFormat[keys] = mergeMapOps[keys](dataOp);
+ mergeFormat[keys] = mergeMapOps[keys](dataOp)
}
if (tof == 'string') {
- mergeFormat[keys] = dataOp[mergeMapOps[keys]];
+ mergeFormat[keys] = dataOp[mergeMapOps[keys]]
}
} else {
- if (dataOp[keys]) mergeFormat[keys] = dataOp[keys];
+ if (dataOp[keys]) mergeFormat[keys] = dataOp[keys]
}
- });
- return mergeFormat;
+ })
+ return mergeFormat
}
- return format;
-};
+ return format
+}
export const deepMerge = (target: any, newObj: any) => {
Object.keys(newObj).forEach((key) => {
- let targetValue = target[key];
- let newObjValue = newObj[key];
+ let targetValue = target[key]
+ let newObjValue = newObj[key]
if (isObject(targetValue) && isObject(newObjValue)) {
- deepMerge(targetValue, newObjValue);
+ deepMerge(targetValue, newObjValue)
} else {
- target[key] = newObjValue;
+ target[key] = newObjValue
}
- });
- return target;
-};
+ })
+ return target
+}
export function myFixed(num: any, digit: number = 2) {
if (Object.is(parseFloat(num), NaN)) {
- return console.log(`传入的值:${num}不是一个数字`);
+ return console.log(`传入的值:${num}不是一个数字`)
}
- num = parseFloat(num);
- return (Math.round((num + Number.EPSILON) * Math.pow(10, digit)) / Math.pow(10, digit)).toFixed(digit);
+ num = parseFloat(num)
+ return (Math.round((num + Number.EPSILON) * Math.pow(10, digit)) / Math.pow(10, digit)).toFixed(digit)
}
export function preventDefault(event: Event, isStopPropagation?: boolean) {
if (typeof event.cancelable !== 'boolean' || event.cancelable) {
- event.preventDefault();
+ event.preventDefault()
}
if (isStopPropagation) {
- event.stopPropagation();
+ event.stopPropagation()
}
}
export const padZero = (num: number | string, length = 2): string => {
- num += '';
+ num += ''
while ((num as string).length < length) {
- num = '0' + num;
+ num = '0' + num
}
- return num.toString();
-};
+ return num.toString()
+}
-export const clamp = (num: number, min: number, max: number): number => Math.min(Math.max(num, min), max);
+export const clamp = (num: number, min: number, max: number): number => Math.min(Math.max(num, min), max)
export const getScrollTopRoot = (): number => {
- return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
-};
+ return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0
+}
diff --git a/src/packages/utils/with-install.ts b/src/packages/utils/with-install.ts
index 8b8dac4aa0..a003f0283a 100644
--- a/src/packages/utils/with-install.ts
+++ b/src/packages/utils/with-install.ts
@@ -1,16 +1,16 @@
-import type { App, Component } from 'vue';
+import type { App, Component } from 'vue'
export type WithInstall = T & {
- install(app: App): void;
-};
+ install(app: App): void
+}
export const withInstall = (comp: T) => {
- const _comp = comp as WithInstall;
+ const _comp = comp as WithInstall
_comp.install = (vue: App) => {
if (_comp.name) {
- vue.component(_comp.name, _comp);
+ vue.component(_comp.name, _comp)
}
- };
+ }
- return _comp as WithInstall;
-};
+ return _comp as WithInstall
+}
diff --git a/src/shims-vue.d.ts b/src/shims-vue.d.ts
index 82c10550a6..d8105321fc 100644
--- a/src/shims-vue.d.ts
+++ b/src/shims-vue.d.ts
@@ -1,12 +1,12 @@
///
declare module '*.vue' {
- import { defineComponent } from 'vue';
- const component: ReturnType;
- export default component;
+ import { defineComponent } from 'vue'
+ const component: ReturnType
+ export default component
}
declare module '*.md' {
- import type { ComponentOptions } from 'vue';
- const Component: ComponentOptions;
- export default Component;
+ import type { ComponentOptions } from 'vue'
+ const Component: ComponentOptions
+ export default Component
}
diff --git a/src/sites/assets/util/helper.ts b/src/sites/assets/util/helper.ts
index cac0b50fe6..67c9a601aa 100644
--- a/src/sites/assets/util/helper.ts
+++ b/src/sites/assets/util/helper.ts
@@ -1,56 +1,56 @@
-import config from '../../config/env';
-import { reactive, watch, onMounted, computed, onBeforeUnmount } from 'vue';
-import { nav } from '../../../config.json';
-import { isJDB, isJDT, isJDDKH } from '.';
+import config from '../../config/env'
+import { reactive, watch, onMounted, computed, onBeforeUnmount } from 'vue'
+import { nav } from '../../../config.json'
+import { isJDB, isJDT, isJDDKH } from '.'
type Obj = {
- [k: string]: any;
-};
+ [k: string]: any
+}
type Store = {
- variables: Obj[];
- variablesMap: Obj;
- rawStyles: string;
- [k: string]: any;
-};
+ variables: Obj[]
+ variablesMap: Obj
+ rawStyles: string
+ [k: string]: any
+}
-const components = (nav as any[]).map(({ packages }) => (packages as any[]).map(({ name }) => name)).flat(1);
+const components = (nav as any[]).map(({ packages }) => (packages as any[]).map(({ name }) => name)).flat(1)
const getRawFileText = async function (url: string) {
- const response = await fetch(url);
- const res = await response.text();
- return res;
-};
+ const response = await fetch(url)
+ const res = await response.text()
+ return res
+}
const getInputType = (value: string) => {
if (/^\d+$/.test(value)) {
- return 'number';
+ return 'number'
}
if (/^#[A-Za-z0-9]+$/.test(value)) {
- return 'hex';
+ return 'hex'
}
if (/^(rgb|hsl)a?\((\s*\/?\s*[+-]?\d*(\.\d+)?%?,?\s*){3,5}\)/gim.test(value)) {
- return 'rgb';
+ return 'rgb'
}
- return 'input';
-};
+ return 'input'
+}
const loadScript = async (url: string) =>
new Promise((resolve, reject) => {
- const script = document.createElement('script');
- script.onload = resolve;
- script.onerror = reject;
- script.src = url;
- document.head.appendChild(script);
- });
+ const script = document.createElement('script')
+ script.onload = resolve
+ script.onerror = reject
+ script.src = url
+ document.head.appendChild(script)
+ })
// 提取变量
const extractVariables = (matched: string[], name: string, lowerCaseName: string) =>
matched.reduce((res, str) => {
- const extract = str.replace(/\s+!default/, '').match(/(.*):(?:\s+)?([\s\S]*)(?:\s+)?;/);
+ const extract = str.replace(/\s+!default/, '').match(/(.*):(?:\s+)?([\s\S]*)(?:\s+)?;/)
if (extract) {
- const key = extract[1];
- const value = extract[2];
+ const key = extract[1]
+ const value = extract[2]
res.push({
name, // 组件名
lowerCaseName, // 组件名小写
@@ -60,109 +60,109 @@ const extractVariables = (matched: string[], name: string, lowerCaseName: string
value, // 编辑的值
// 编辑的类型
inputType: getInputType(value)
- });
+ })
}
- return res;
- }, [] as Obj[]);
+ return res
+ }, [] as Obj[])
// 提取样式代码,只保留有使用变量的行
const extractStyle = (style: string) => {
if (!store.variables.length) {
- return '';
+ return ''
}
// comment
style = style
.split('\n')
.filter((str) => !/^(\s+)?\/\//.test(str))
- .join('\n');
+ .join('\n')
// todo: parse mixin
style = style
.split('\n')
.filter((str) => !/^(\s+)?@include/.test(str))
- .join('\n');
+ .join('\n')
style = style.replace(/(?:({|;|\s|\n))[\w-]+:([^;{}]|;base64)+;(?!base64)/g, (matched) => {
- const matchedKey = matched.match(/\$[\w-]+\b/g);
+ const matchedKey = matched.match(/\$[\w-]+\b/g)
if (matchedKey && matchedKey.some((k) => store.variablesMap[k])) {
- return matched;
+ return matched
}
- return '';
- });
+ return ''
+ })
// console.log(style);
- return style;
-};
+ return style
+}
const parseSassVariables = (text: string, components: string[]) => {
const matchedComponentVariables = components
.map((name) => {
- const lowerCaseName = name.toLowerCase();
+ const lowerCaseName = name.toLowerCase()
const reg = new RegExp(
`(? (item && `${item.name}|${item.lowerCaseName}`) || '')
.join('|')})\\b)[\\w-]+:[^:]+;`,
'g'
- );
+ )
- const variables = matchedComponentVariables as Obj[];
+ const variables = matchedComponentVariables as Obj[]
- const matchedBaseVariables = text.match(baseVariablesReg);
+ const matchedBaseVariables = text.match(baseVariablesReg)
// 组件变量以外的都作为基础变量
if (matchedBaseVariables) {
- variables.unshift(...extractVariables(matchedBaseVariables, 'Base', 'base'));
+ variables.unshift(...extractVariables(matchedBaseVariables, 'Base', 'base'))
}
- return variables;
-};
+ return variables
+}
-let cachedStyles = '';
+let cachedStyles = ''
const store: Store = reactive({
init: false,
variables: [],
variablesMap: {},
rawStyles: ''
-});
+})
const getSassVariables = async (sassFileUrl: string) => {
if (sassFileUrl) {
- const customVariablesText = await getRawFileText(sassFileUrl);
- const customVariables = parseSassVariables(customVariablesText, components);
+ const customVariablesText = await getRawFileText(sassFileUrl)
+ const customVariables = parseSassVariables(customVariablesText, components)
const variablesMap = customVariables.reduce((map, item) => {
- map[item.key] = 1;
- return map;
- }, {});
- store.variables = customVariables;
- store.variablesMap = variablesMap;
+ map[item.key] = 1
+ return map
+ }, {})
+ store.variables = customVariables
+ store.variablesMap = variablesMap
}
-};
+}
export const getRawSassStyle = async (): Promise => {
- const style = await getRawFileText(`${config.themeUrl}/styles/sass-styles.scss_source`);
- store.rawStyles = style;
-};
+ const style = await getRawFileText(`${config.themeUrl}/styles/sass-styles.scss_source`)
+ store.rawStyles = style
+}
export const useThemeEditor = function () {
const cssText = computed(() => {
- const variablesText = store.variables.map(({ key, value }) => `${key}:${value}`).join(';');
- cachedStyles = cachedStyles || extractStyle(store.rawStyles);
- return variablesText ? `${variablesText};${cachedStyles}` : '';
- });
+ const variablesText = store.variables.map(({ key, value }) => `${key}:${value}`).join(';')
+ cachedStyles = cachedStyles || extractStyle(store.rawStyles)
+ return variablesText ? `${variablesText};${cachedStyles}` : ''
+ })
onMounted(async () => {
if (!store.init) {
@@ -170,66 +170,66 @@ export const useThemeEditor = function () {
// e.g. https://nutui.jd.com/theme/?theme=xxx.com%2variables.scss#/
// vite issue https://github.com/vitejs/vite/issues/6894
- let customUrl = '';
+ let customUrl = ''
if (isJDT()) {
- customUrl = 'https://storage.360buyimg.com/nutui-static/source/variables-jdt.scss_source';
+ customUrl = 'https://storage.360buyimg.com/nutui-static/source/variables-jdt.scss_source'
} else if (isJDB()) {
- customUrl = 'https://storage.360buyimg.com/nutui-static/source/variables-jdb.scss_source';
+ customUrl = 'https://storage.360buyimg.com/nutui-static/source/variables-jdb.scss_source'
} else if (isJDDKH()) {
- customUrl = 'https://storage.360buyimg.com/nutui-static/source/variables-jddkh.scss_source';
+ customUrl = 'https://storage.360buyimg.com/nutui-static/source/variables-jddkh.scss_source'
}
if (customUrl) {
loadScript('https://storage.360buyimg.com/nutui-static/cdn/sass.sync.min.js').then(() => {
- Promise.all([getSassVariables(customUrl), getRawSassStyle()]);
- });
- store.init = true;
+ Promise.all([getSassVariables(customUrl), getRawSassStyle()])
+ })
+ store.init = true
}
}
- });
+ })
- let timer: any = null;
+ let timer: any = null
onBeforeUnmount(() => {
- clearTimeout(timer);
- });
+ clearTimeout(timer)
+ })
watch(
() => cssText.value,
(css: string) => {
if (!css) {
- return;
+ return
}
- clearTimeout(timer);
+ clearTimeout(timer)
timer = setTimeout(() => {
- const Sass = (window as any).Sass;
- let beginTime = new Date().getTime();
- console.log('sass编译开始', beginTime);
+ const Sass = (window as any).Sass
+ let beginTime = new Date().getTime()
+ console.log('sass编译开始', beginTime)
Sass &&
Sass.compile(css, async (res: Obj) => {
- const iframe = window as any;
+ const iframe = window as any
if (res.text && iframe) {
- console.log('sass编译成功', new Date().getTime() - beginTime);
+ console.log('sass编译成功', new Date().getTime() - beginTime)
try {
if (!iframe.__styleEl) {
- const style = iframe.document.createElement('style');
- style.id = 'theme';
- iframe.__styleEl = style;
+ const style = iframe.document.createElement('style')
+ style.id = 'theme'
+ iframe.__styleEl = style
}
- iframe.__styleEl.innerHTML = res.text;
- iframe.document.head.appendChild(iframe.__styleEl);
- console.info('insert success!');
+ iframe.__styleEl.innerHTML = res.text
+ iframe.document.head.appendChild(iframe.__styleEl)
+ console.info('insert success!')
} catch (error) {
- console.error(error);
+ console.error(error)
}
} else {
- console.log('sass编译失败', new Date().getTime() - beginTime);
- console.error(res);
+ console.log('sass编译失败', new Date().getTime() - beginTime)
+ console.error(res)
}
if (res.status !== 0 && res.message) {
- console.log(res.message);
+ console.log(res.message)
}
- });
- }, 300);
+ })
+ }, 300)
},
{ immediate: true }
- );
-};
+ )
+}
diff --git a/src/sites/assets/util/index.ts b/src/sites/assets/util/index.ts
index 814f1e47e5..0f18d1be01 100644
--- a/src/sites/assets/util/index.ts
+++ b/src/sites/assets/util/index.ts
@@ -1,18 +1,18 @@
-const ua = navigator.userAgent.toLowerCase();
-const isMobile = /ios|iphone|ipod|ipad|android/.test(ua);
+const ua = navigator.userAgent.toLowerCase()
+const isMobile = /ios|iphone|ipod|ipad|android/.test(ua)
const isJDT = () => {
- return window.parent.location.href.includes('jdt');
-};
+ return window.parent.location.href.includes('jdt')
+}
const isJDB = () => {
- return window.parent.location.href.includes('jdb');
-};
+ return window.parent.location.href.includes('jdb')
+}
const isJDDKH = () => {
- return window.parent.location.href.includes('jddkh');
-};
-export { isMobile, isJDT, isJDB, isJDDKH };
+ return window.parent.location.href.includes('jddkh')
+}
+export { isMobile, isJDT, isJDB, isJDDKH }
export const reorder = (packages: Array) => {
return packages.sort(function (x: any, y: any) {
- return x['name'].localeCompare(y['name']);
- });
-};
+ return x['name'].localeCompare(y['name'])
+ })
+}
diff --git a/src/sites/assets/util/ref.ts b/src/sites/assets/util/ref.ts
index b4ab589835..4e0831d9dc 100644
--- a/src/sites/assets/util/ref.ts
+++ b/src/sites/assets/util/ref.ts
@@ -1,25 +1,25 @@
-import { Ref, ref } from 'vue';
+import { Ref, ref } from 'vue'
export class RefData {
- private static instance: RefData;
+ private static instance: RefData
public static getInstance(): RefData {
if (this.instance == null) {
- this.instance = new RefData();
- let localTheme = localStorage.getItem('nutui-theme-color');
+ this.instance = new RefData()
+ let localTheme = localStorage.getItem('nutui-theme-color')
if (localTheme) {
- this.instance.themeColor.value = localTheme;
+ this.instance.themeColor.value = localTheme
}
}
- return this.instance;
+ return this.instance
}
- public currentRoute: Ref = ref('/');
+ public currentRoute: Ref = ref('/')
- private _themeColor: Ref = ref('black');
+ private _themeColor: Ref = ref('black')
public get themeColor(): Ref {
- return this._themeColor;
+ return this._themeColor
}
public set themeColor(v: Ref) {
- this._themeColor = v;
+ this._themeColor = v
}
}
diff --git a/src/sites/assets/util/useTranslate.ts b/src/sites/assets/util/useTranslate.ts
index 0cce5c7247..0c1b5b00b3 100644
--- a/src/sites/assets/util/useTranslate.ts
+++ b/src/sites/assets/util/useTranslate.ts
@@ -1,37 +1,37 @@
-import Locale from '@/packages/locale';
-import { useLocale } from '@/packages/utils/useLocale';
-export const currentLang = Locale.currentLang;
+import Locale from '@/packages/locale'
+import { useLocale } from '@/packages/utils/useLocale'
+export const currentLang = Locale.currentLang
export const useTranslate = <
T1 extends {
- [key: string]: any;
+ [key: string]: any
},
T2 extends T1
>(object: {
- 'zh-CN': T1;
- 'en-US': T2;
+ 'zh-CN': T1
+ 'en-US': T2
}) => {
for (const [key, value] of Object.entries(object)) {
- Locale.merge(key, value);
+ Locale.merge(key, value)
}
- return useLocale, number | symbol>>();
-};
+ return useLocale, number | symbol>>()
+}
export const translateChange = () => {
- let href = '';
- const location = window.parent.location;
- const currentLang = Locale.currentLang;
+ let href = ''
+ const location = window.parent.location
+ const currentLang = Locale.currentLang
if (currentLang.value == 'zh-CN') {
- href = location.href.replace('zh-CN', 'en-US');
- Locale.use('en-US');
+ href = location.href.replace('zh-CN', 'en-US')
+ Locale.use('en-US')
} else {
- href = location.href.replace('en-US', 'zh-CN');
- Locale.use('zh-CN');
+ href = location.href.replace('en-US', 'zh-CN')
+ Locale.use('zh-CN')
}
- location.href = href;
-};
+ location.href = href
+}
export const initSiteLang = () => {
- const lang = location.href.includes('zh-CN') ? 'zh-CN' : 'en-US';
- Locale.use(lang);
-};
+ const lang = location.href.includes('zh-CN') ? 'zh-CN' : 'en-US'
+ Locale.use(lang)
+}
diff --git a/src/sites/config/env.ts b/src/sites/config/env.ts
index 0be1d89d79..131b4c182f 100644
--- a/src/sites/config/env.ts
+++ b/src/sites/config/env.ts
@@ -1,8 +1,8 @@
type EnvConfig = {
- baseUrl: string;
- themeUrl: string;
- isPrd: boolean;
-};
+ baseUrl: string
+ themeUrl: string
+ isPrd: boolean
+}
/**
* 配置编译环境和线上环境之间的切换
@@ -15,23 +15,23 @@ const config: EnvConfig = {
baseUrl: '',
themeUrl: '',
isPrd: true // 是否为线上
-};
+}
switch (import.meta.env.MODE) {
case 'development':
/*
* 开发环境 => npm run dev
*/
- config.isPrd = false;
- config.baseUrl = '/devServer';
- config.themeUrl = '/devTheme';
- break;
+ config.isPrd = false
+ config.baseUrl = '/devServer'
+ config.themeUrl = '/devTheme'
+ break
case 'production':
/*
* 线上环境 => npm run build
*/
- config.isPrd = true;
- config.baseUrl = 'https://nutui.jd.com';
- config.themeUrl = 'https://nutui.jd.com/theme/source';
- break;
+ config.isPrd = true
+ config.baseUrl = 'https://nutui.jd.com'
+ config.themeUrl = 'https://nutui.jd.com/theme/source'
+ break
}
-export default config;
+export default config
diff --git a/src/sites/doc/components/DemoPreview.vue b/src/sites/doc/components/DemoPreview.vue
index a9e4fc77cd..2e6abad508 100644
--- a/src/sites/doc/components/DemoPreview.vue
+++ b/src/sites/doc/components/DemoPreview.vue
@@ -9,7 +9,7 @@ defineProps({
type: String,
default: ''
}
-});
+})