Skip to content

Commit f6ef694

Browse files
author
liyuelong
committed
架构兼容性修改
1 parent 4fe05f4 commit f6ef694

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1783
-1402
lines changed

build.js

+7-46
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,22 @@
11
const path = require('path')
2-
// const fs = require('fs')
32
const { build } = require('vite')
4-
// const Vue = require('@vitejs/plugin-vue')
5-
// const vueJsx = require('@vitejs/plugin-vue-jsx')
6-
// const vitePluginMd2Vue = require('vite-plugin-md2vue')
7-
8-
// console.log('build: ', build)
9-
// console.log('createLogger: ', createLogger)
10-
// console.log('createServer: ', createServer)
11-
// console.log('defineConfig: ', defineConfig)
12-
// console.log('loadConfigFromFile: ', loadConfigFromFile)
13-
// console.log('loadEnv: ', loadEnv)
14-
// console.log('mergeConfig: ', mergeConfig)
15-
// console.log('normalizePath: ', normalizePath)
16-
// console.log('optimizeDeps: ', optimizeDeps)
17-
// console.log('resolveConfig: ', resolveConfig)
18-
// console.log('resolvePackageData: ', resolvePackageData)
19-
// console.log('resolvePackageEntry: ', resolvePackageEntry)
20-
// console.log('send: ', send)
21-
// console.log('sortUserPlugins: ', sortUserPlugins)
22-
23-
// function getEntry(dir) {
24-
// return fs.readdirSync(path.resolve(dir))
25-
// }
26-
27-
// let entry = {
28-
// base: './src/assets/less/variables.less',
29-
// index: './src/index.js'
30-
// };
31-
// getEntry('./packages').forEach(function (name) {
32-
// entry[name] = './packages/' + name + '/index.js'
33-
// })
34-
35-
// console.log(Vue)
36-
// console.log(vueJsx)
37-
// console.log(vitePluginMd2Vue)
3+
const svgLoader = require('vite-svg-loader')
384

395
build({
40-
// root: path.resolve(__dirname, './'),
41-
// plugins: [
42-
// Vue.default(),
43-
// vueJsx.default(),
44-
// vitePluginMd2Vue.default()
45-
// ],
6+
plugins: [
7+
svgLoader()
8+
],
469
build: {
4710
lib: {
4811
entry: path.resolve(__dirname, 'src/index.js'),
49-
name: 'PlMobile'
12+
name: 'PlMobile',
13+
formats: ['es', 'umd'],
14+
fileName: 'index'
5015
},
5116
outDir: 'lib',
5217
rollupOptions: {
53-
// 确保外部化处理那些你不想打包进库的依赖
5418
external: ['vue'],
55-
// input: entry,
5619
output: {
57-
// entryFileNames: '[name].js',
58-
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
5920
globals: {
6021
vue: 'Vue'
6122
}

docs/fetch.md

+20-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
## fetch 接口请求
22

33
### 基础用法
4+
```
5+
import { fetch } from 'pl-mobile2'
6+
app.use(fetch)
7+
```
48

59
#### 1、定义默认配置
610
```
@@ -57,7 +61,7 @@ Vue.prototype.$fetch.my_api.getLogo({
5761
method: 'post',
5862
headers: {
5963
'Cookie': 'my-cookie'
60-
}
64+
}
6165
}).then(data => {
6266
console.log(data) // Blob data
6367
})
@@ -100,15 +104,15 @@ Vue.prototype.$fetchMiddleware(function (res, options) {
100104
this.src = URL.createObjectURL(data)
101105
}
102106
})
103-
}
107+
}
104108
}
105109
}
106110
</script>
107111
```
108112

109113

110114
### Methods
111-
| 方法名 | 说明 | 参数 | 参数描述 |返回值 |
115+
| 方法名 | 说明 | 参数 | 参数描述 |返回值 |
112116
| ---- | ---- | ---- | ---- | ---- |
113117
| $fetch | 接口api对象,根据 $fetchDefine 定义 API 路径和名称 | \<data>[, options] | data:请求的数据 | fetchHandler |
114118
| $fetchConfig | 设置默认请求配置 | \<options> |||
@@ -119,22 +123,22 @@ Vue.prototype.$fetchMiddleware(function (res, options) {
119123
### options
120124
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
121125
|---------- |-------- |---------- |------------- |-------- |
122-
| url | 请求URL地址 | String |||
123-
| baseUrl | 请求URL域名 | String |||
124-
| method | 请求使用的方法,如 GET、POST | String || POST |
125-
| data | 请求的数据 | Object | Object / Blob / BufferSource / FormData / URLSearchParams / USVString ||
126-
| headers | 请求的头信息 | Object |||
127-
| type | 请求的数据类型 | String | json / blob / arrayBuffer / formData / text | json |
128-
| mode | 请求的模式 | String | cors / no-cors / same-origin ||
129-
| credentials| 请求的 credentials 。为了在当前域名内自动发送 cookie , 必须提供这个选项 | String | omit / same-origin / include ||
130-
| cache | 请求的 cache 模式 | String | default / no-store / reload / no-cache / force-cache / only-if-cached | no-cache |
131-
| signal | AbortSignal 接口表示一个信号对象( signal object ),它允许您通过 AbortController 对象与DOM请求(如Fetch)进行通信并在需要时将其中止。 | AbortController |||
132-
| redirect | 根据请求地址转成get请求,直接重定向URL | Boolean || false |
133-
| onDownload | onDownload 回调方法 | Function |||
126+
| url | 请求URL地址 | String |||
127+
| baseUrl | 请求URL域名 | String |||
128+
| method | 请求使用的方法,如 GET、POST | String || POST |
129+
| data | 请求的数据 | Object | Object / Blob / BufferSource / FormData / URLSearchParams / USVString ||
130+
| headers | 请求的头信息 | Object |||
131+
| type | 请求的数据类型 | String | json / blob / arrayBuffer / formData / text | json |
132+
| mode | 请求的模式 | String | cors / no-cors / same-origin ||
133+
| credentials| 请求的 credentials 。为了在当前域名内自动发送 cookie , 必须提供这个选项 | String | omit / same-origin / include ||
134+
| cache | 请求的 cache 模式 | String | default / no-store / reload / no-cache / force-cache / only-if-cached | no-cache |
135+
| signal | AbortSignal 接口表示一个信号对象( signal object ),它允许您通过 AbortController 对象与DOM请求(如Fetch)进行通信并在需要时将其中止。 | AbortController |||
136+
| redirect | 根据请求地址转成get请求,直接重定向URL | Boolean || false |
137+
| onDownload | onDownload 回调方法 | Function |||
134138

135139

136140
### fetchHandler
137-
| 方法 | 说明 | 参数 | 返回值 |
141+
| 方法 | 说明 | 参数 | 返回值 |
138142
|----- |------ |-------- |------ |
139143
| url | url拼接 | \<string>[, string]... | fetchHandler |
140144
| headers | 自定义请求头,会跟默认头信息合并 | \<object> | fetchHandler |

docs/icon.md

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
<template>
88
<pl-icon name="icon-icon_rukou"/>
99
</template>
10+
<script>
11+
import { icon } from 'pl-mobile2'
12+
export default {
13+
components: {
14+
'pl-icon': icon
15+
}
16+
}
17+
</script>
1018
```
1119

1220
### Attributes

examples/components/checkbox.vue

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@
2121

2222
<h3>前置图标</h3>
2323
<pl-checkbox v-model="value" :options="data" :rules="rules" label="请选择:">
24-
<pl-icon name="icon-dingwei" fill="#999" slot="prepend"></pl-icon>
24+
<template v-slot:prepend>
25+
<pl-icon name="icon-dingwei" fill="#999"></pl-icon>
26+
</template>
2527
</pl-checkbox>
2628
<pl-checkbox v-model="value" :options="data" :rules="rules" label="请选择:" wrap ref="box2" required>
27-
<pl-icon name="icon-dingwei" fill="#999" slot="prepend"></pl-icon>
29+
<template v-slot:prepend>
30+
<pl-icon name="icon-dingwei" fill="#999"></pl-icon>
31+
</template>
2832
</pl-checkbox>
2933

3034
<h3>竖排样式</h3>

examples/components/datetime.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="content">
33
<h3>基础用法</h3>
4-
<pl-datetime placeholder="请选择日期" v-model="date" type="date"></pl-datetime>
4+
<pl-datetime placeholder="请选择日期" v-model="date" type="date" clearable></pl-datetime>
55

66
<h3>时间选择</h3>
77
<pl-datetime label="请选择时间:" v-model="time" type="time" @change="onChange" valueFormat="H:I" clearable></pl-datetime>

examples/components/input.vue

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="content">
33
<h3>基础用法</h3>
4-
<pl-input placeholder="姓名、手机、电话" type="text" v-model="value" size="normal" />
4+
<pl-input placeholder="姓名、手机、电话" type="text" v-model="value" size="normal" clearable />
55

66
<h3>尺寸大小</h3>
77
<pl-input label="请输入:" placeholder="姓名、手机、电话" type="text" v-model="value" size="small" />
@@ -25,12 +25,20 @@
2525

2626
<h3>图标填充</h3>
2727
<pl-input label="请输入:" placeholder="姓名、手机、电话" type="text" v-model="value" :rules="rules" ref="input6" required clearable>
28-
<pl-icon name="icon-dingwei" fill="#999" slot="prepend"></pl-icon>
29-
<pl-icon name="icon-people_fill" fill="#999" slot="append"></pl-icon>
28+
<template v-slot:prepend>
29+
<pl-icon name="icon-dingwei" fill="#999"></pl-icon>
30+
</template>
31+
<template v-slot:append>
32+
<pl-icon name="icon-people_fill" fill="#999"></pl-icon>
33+
</template>
3034
</pl-input>
3135
<pl-input label="请输入:" placeholder="姓名、手机、电话" type="textarea" rows="5" v-model="value" :rules="rules" ref="input7" required wrap clearable>
32-
<pl-icon name="icon-dingwei" fill="#999" slot="prepend"></pl-icon>
33-
<pl-icon name="icon-people_fill" fill="#999" slot="append"></pl-icon>
36+
<template v-slot:prepend>
37+
<pl-icon name="icon-dingwei" fill="#999"></pl-icon>
38+
</template>
39+
<template v-slot:append>
40+
<pl-icon name="icon-people_fill" fill="#999"></pl-icon>
41+
</template>
3442
</pl-input>
3543

3644
<pl-cell :span="[1]">

examples/components/message.vue

+46-40
Original file line numberDiff line numberDiff line change
@@ -8,75 +8,81 @@
88
</div>
99
</template>
1010
<script>
11+
import { getCurrentInstance } from 'vue'
1112
import swipe from './swipe.vue'
1213
1314
export default {
14-
methods: {
15-
alert() {
16-
this.$alert({
15+
setup() {
16+
const app = getCurrentInstance()
17+
const { $alert, $confirm, $toast } = app.appContext.config.globalProperties
18+
19+
function alert() {
20+
$alert({
1721
title: '提示',
1822
message: '这个一个弹窗!',
1923
buttonText: '确定',
2024
action: () => {
2125
// 确定
22-
console.log('确定')
26+
$toast('确定')
2327
}
2428
})
25-
},
26-
confirm() {
27-
this.$confirm({
29+
}
30+
function confirm() {
31+
$confirm({
2832
title: '提示',
2933
message: '这个一个确认弹窗!',
3034
submitText: '确定',
3135
cancelText: '取消',
3236
submit: () => {
3337
// 确定
34-
console.log('确定')
38+
$toast('确定')
3539
},
3640
cancel: () => {
3741
// 取消
38-
console.log('取消')
39-
}
40-
})
41-
},
42-
dialog1() {
43-
this.$alert({
44-
component: swipe,
45-
componentProps: {
46-
isMsg: true
47-
},
48-
submitText: '确定',
49-
cancelText: '取消',
50-
action: () => {
51-
// 确定
52-
console.log('确定')
42+
$toast('取消')
5343
}
5444
})
55-
},
56-
dialog2() {
57-
this.$confirm({
58-
// title: '提示',
45+
}
46+
async function dialog1() {
47+
await $alert({
5948
component: swipe,
6049
componentProps: {
6150
isMsg: true
6251
},
63-
// message: '这个一个确认弹窗!',
6452
submitText: '确定',
65-
cancelText: '取消',
66-
submit: () => {
67-
// 确定
68-
console.log('确定')
69-
},
70-
cancel: () => {
71-
// 取消
72-
console.log('取消')
73-
}
53+
cancelText: '取消'
7454
})
75-
},
76-
toast() {
77-
this.$toast('消息提醒', 3000) // 提示信息, 持续时间(可选,默认3000毫秒)
55+
$toast('确定')
56+
}
57+
async function dialog2() {
58+
try {
59+
await $confirm({
60+
// title: '提示',
61+
component: swipe,
62+
componentProps: {
63+
isMsg: true
64+
},
65+
// message: '这个一个确认弹窗!',
66+
submitText: '确定',
67+
cancelText: '取消'
68+
})
69+
$toast('确定')
70+
} catch (e) {
71+
$toast('取消')
72+
}
73+
}
74+
async function toast() {
75+
await $toast('消息提醒1', 3000) // 提示信息, 持续时间(可选,默认3000毫秒)
76+
await $toast('消息提醒2', 3000) // 提示信息, 持续时间(可选,默认3000毫秒)
7877
}
7978
79+
return {
80+
alert,
81+
confirm,
82+
dialog1,
83+
dialog2,
84+
toast
85+
}
8086
}
8187
}
8288
</script>

examples/components/radio.vue

+6-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@
2727

2828
<h3>前置图标</h3>
2929
<pl-radio v-model="value" :options="data" label="请选择:" :rules="rules" ref="radio2" wrap required>
30-
<pl-icon name="icon-dingwei" fill="#999" slot="prepend"></pl-icon>
30+
<template v-slot:prepend>
31+
<pl-icon name="icon-dingwei" fill="#999"></pl-icon>
32+
</template>
3133
</pl-radio>
3234
<pl-radio v-model="value" :options="data" label="请选择:" :rules="rules" ref="radio3" required>
33-
<pl-icon name="icon-dingwei" fill="#999" slot="prepend"></pl-icon>
35+
<template v-slot:prepend>
36+
<pl-icon name="icon-dingwei" fill="#999"></pl-icon>
37+
</template>
3438
</pl-radio>
3539

3640
<h3>自定义子节点</h3>

examples/components/range.vue

+9-5
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,21 @@
2121

2222
<h3>图标填充</h3>
2323
<pl-range v-model="value" :min="0" :max="100" :step="1" label="请选择:" @change="onChange" :rules="rules" ref="range3" required>
24-
<pl-icon name="icon-dingwei" fill="#999" slot="prepend"></pl-icon>
25-
<span slot="append">{{value}}%</span>
24+
<template v-slot:prepend>
25+
<pl-icon name="icon-dingwei" fill="#999"></pl-icon>
26+
</template>
27+
<template v-slot:append>{{value}}%</template>
2628
</pl-range>
2729
<pl-range v-model="value" :min="0" :max="100" :step="1" label="请选择:" @change="onChange" :rules="rules" ref="range4" required wrap>
28-
<pl-icon name="icon-dingwei" fill="#999" slot="prepend"></pl-icon>
29-
<span slot="append">{{value}}%</span>
30+
<template v-slot:prepend>
31+
<pl-icon name="icon-dingwei" fill="#999"></pl-icon>
32+
</template>
33+
<template v-slot:append>{{value}}%</template>
3034
</pl-range>
3135

3236
<h3>自定义滑块</h3>
3337
<pl-range v-model="value" :min="0" :max="100" :step="1" label="请选择:" @change="onChange" :rules="rules" ref="range5" required>
34-
<span slot="thumb" class="thumb">{{value}}%</span>
38+
<template v-slot:thumb><span class="thumb">{{value}}%</span></template>
3539
</pl-range>
3640

3741
<pl-cell :span="[1]">

examples/components/select.vue

+6-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@
2727

2828
<h3>前后图标</h3>
2929
<pl-select label="请选择:" placeholder="请选择" v-model="value1" :options="data" @change="change" :rules="rules1" ref="select3" clearable required>
30-
<pl-icon name="icon-dingwei" fill="#999" slot="prepend"></pl-icon>
31-
<pl-icon name="icon-people_fill" fill="#999" slot="append"></pl-icon>
30+
<template v-slot:prepend>
31+
<pl-icon name="icon-dingwei" fill="#999"></pl-icon>
32+
</template>
33+
<template v-slot:append>
34+
<pl-icon name="icon-people_fill" fill="#999"></pl-icon>
35+
</template>
3236
</pl-select>
3337

3438
<br /><br /><br />

lib/favicon.ico

4.19 KB
Binary file not shown.

lib/index.es.js

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/index.umd.js

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/style.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)