jobsys-newbie 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/_virtual/_plugin-vue_export-helper.mjs +9 -0
- package/dist/es/index.mjs +4 -0
- package/dist/es/src/password/NewbiePassword.vue.mjs +86 -0
- package/dist/es/src/password/NewbiePassword.vue2.mjs +4 -0
- package/dist/es/style.css +1 -0
- package/dist/lib/_virtual/_plugin-vue_export-helper.js +1 -0
- package/dist/lib/index.js +1 -0
- package/dist/lib/src/password/NewbiePassword.vue.js +1 -0
- package/dist/lib/src/password/NewbiePassword.vue2.js +1 -0
- package/index.js +1 -0
- package/package.json +41 -0
- package/src/index.js +1 -0
- package/src/password/NewbiePassword.vue +150 -0
- package/src/password/index.js +3 -0
- package/vite.config.js +65 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { defineComponent as w, ref as d, computed as i, watch as _, openBlock as m, createElementBlock as v, createVNode as V, unref as b, createElementVNode as s, normalizeClass as r, toDisplayString as N, createCommentVNode as y } from "vue";
|
|
2
|
+
import { InputPassword as C } from "ant-design-vue";
|
|
3
|
+
import "./NewbiePassword.vue2.mjs";
|
|
4
|
+
import k from "../../_virtual/_plugin-vue_export-helper.mjs";
|
|
5
|
+
const E = { class: "newbie-password" }, z = {
|
|
6
|
+
key: 0,
|
|
7
|
+
class: "error-message"
|
|
8
|
+
}, L = w({ name: "newbie-password" }), A = /* @__PURE__ */ Object.assign(L, {
|
|
9
|
+
props: {
|
|
10
|
+
/**
|
|
11
|
+
* @model
|
|
12
|
+
*/
|
|
13
|
+
modelValue: { type: String, default: "" },
|
|
14
|
+
/**
|
|
15
|
+
* 最小长度
|
|
16
|
+
*/
|
|
17
|
+
min: { type: Number, default: 8 },
|
|
18
|
+
/**
|
|
19
|
+
* 最大长度
|
|
20
|
+
*/
|
|
21
|
+
max: { type: Number, default: 20 }
|
|
22
|
+
},
|
|
23
|
+
emits: [
|
|
24
|
+
"update:modelValue",
|
|
25
|
+
/**
|
|
26
|
+
* 输入框内容变化时的回调
|
|
27
|
+
* @event change
|
|
28
|
+
* @param {Object} e - 事件对象
|
|
29
|
+
*/
|
|
30
|
+
"change"
|
|
31
|
+
],
|
|
32
|
+
setup(o, { expose: g, emit: c }) {
|
|
33
|
+
const t = o, e = d(""), a = i(() => {
|
|
34
|
+
let n = 0;
|
|
35
|
+
return [
|
|
36
|
+
/\d/,
|
|
37
|
+
// 包含数字
|
|
38
|
+
/[a-z]/,
|
|
39
|
+
// 包含小写字母
|
|
40
|
+
/[A-Z]/,
|
|
41
|
+
// 包含大写字母
|
|
42
|
+
/[^a-zA-Z0-9]/
|
|
43
|
+
// 包含特殊符号
|
|
44
|
+
].forEach((u) => {
|
|
45
|
+
u.test(e.value) && (n += 1);
|
|
46
|
+
}), n;
|
|
47
|
+
}), h = d(["", "bad", "weak", "medium", "strong"]), p = (n) => {
|
|
48
|
+
const { value: l } = n.target;
|
|
49
|
+
c("change", n), c("update:modelValue", l);
|
|
50
|
+
}, f = i(() => e.value.length > 0 && e.value.length < t.min || e.value.length > t.max || a.value < 4), x = i(() => e.value.length > 0 && e.value.length < t.min ? `密码长度不能少于${t.min}个字符` : e.value.length > t.max ? `密码长度不能超过${t.max}个字符` : a.value < 4 ? "密码必须包含数字、小写字母、大写字母和特殊符号" : "");
|
|
51
|
+
return _(
|
|
52
|
+
() => t.modelValue,
|
|
53
|
+
() => {
|
|
54
|
+
e.value = t.modelValue;
|
|
55
|
+
}
|
|
56
|
+
), g({ strength: a }), (n, l) => (m(), v("div", E, [
|
|
57
|
+
V(b(C), {
|
|
58
|
+
value: e.value,
|
|
59
|
+
"onUpdate:value": l[0] || (l[0] = (u) => e.value = u),
|
|
60
|
+
onChange: p,
|
|
61
|
+
minlength: o.min,
|
|
62
|
+
maxlength: o.max
|
|
63
|
+
}, null, 8, ["value", "minlength", "maxlength"]),
|
|
64
|
+
s("div", {
|
|
65
|
+
class: r(["strength-indicator-container", [h.value[a.value]]])
|
|
66
|
+
}, [
|
|
67
|
+
s("div", {
|
|
68
|
+
class: r(["strength-indicator", [a.value >= 1 ? "active" : ""]])
|
|
69
|
+
}, null, 2),
|
|
70
|
+
s("div", {
|
|
71
|
+
class: r(["strength-indicator", [a.value >= 2 ? "active" : ""]])
|
|
72
|
+
}, null, 2),
|
|
73
|
+
s("div", {
|
|
74
|
+
class: r(["strength-indicator", [a.value >= 3 ? "active" : ""]])
|
|
75
|
+
}, null, 2),
|
|
76
|
+
s("div", {
|
|
77
|
+
class: r(["strength-indicator", [a.value >= 4 ? "active" : ""]])
|
|
78
|
+
}, null, 2)
|
|
79
|
+
], 2),
|
|
80
|
+
f.value ? (m(), v("div", z, N(x.value), 1)) : y("", !0)
|
|
81
|
+
]));
|
|
82
|
+
}
|
|
83
|
+
}), Z = /* @__PURE__ */ k(A, [["__scopeId", "data-v-9f72ae98"]]);
|
|
84
|
+
export {
|
|
85
|
+
Z as default
|
|
86
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.strength-indicator-container[data-v-9f72ae98]{display:grid;grid-template-columns:repeat(4,1fr);margin-top:5px}.strength-indicator-container .strength-indicator[data-v-9f72ae98]{height:5px;border:1px solid #e8e8e8}.strength-indicator-container.bad .active[data-v-9f72ae98]{background:#ff0000}.strength-indicator-container.weak .active[data-v-9f72ae98]{background:#ffa500}.strength-indicator-container.medium .active[data-v-9f72ae98]{background:#ffff00}.strength-indicator-container.strong .active[data-v-9f72ae98]{background:#008000}.error-message[data-v-9f72ae98]{color:red;margin-top:5px}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=(e,o)=>{const t=e.__vccOpts||e;for(const[r,s]of o)t[r]=s;return t};exports.default=u;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./src/password/NewbiePassword.vue.js");exports.NewbiePassword=e.default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),g=require("ant-design-vue");require("./NewbiePassword.vue2.js");const h=require("../../_virtual/_plugin-vue_export-helper.js"),p={class:"newbie-password"},f={key:0,class:"error-message"},V=e.defineComponent({name:"newbie-password"}),x=Object.assign(V,{props:{modelValue:{type:String,default:""},min:{type:Number,default:8},max:{type:Number,default:20}},emits:["update:modelValue","change"],setup(s,{expose:i,emit:u}){const a=s,t=e.ref(""),n=e.computed(()=>{let l=0;return[/\d/,/[a-z]/,/[A-Z]/,/[^a-zA-Z0-9]/].forEach(o=>{o.test(t.value)&&(l+=1)}),l}),c=e.ref(["","bad","weak","medium","strong"]),d=l=>{const{value:r}=l.target;u("change",l),u("update:modelValue",r)},m=e.computed(()=>t.value.length>0&&t.value.length<a.min||t.value.length>a.max||n.value<4),v=e.computed(()=>t.value.length>0&&t.value.length<a.min?`密码长度不能少于${a.min}个字符`:t.value.length>a.max?`密码长度不能超过${a.max}个字符`:n.value<4?"密码必须包含数字、小写字母、大写字母和特殊符号":"");return e.watch(()=>a.modelValue,()=>{t.value=a.modelValue}),i({strength:n}),(l,r)=>(e.openBlock(),e.createElementBlock("div",p,[e.createVNode(e.unref(g.InputPassword),{value:t.value,"onUpdate:value":r[0]||(r[0]=o=>t.value=o),onChange:d,minlength:s.min,maxlength:s.max},null,8,["value","minlength","maxlength"]),e.createElementVNode("div",{class:e.normalizeClass(["strength-indicator-container",[c.value[n.value]]])},[e.createElementVNode("div",{class:e.normalizeClass(["strength-indicator",[n.value>=1?"active":""]])},null,2),e.createElementVNode("div",{class:e.normalizeClass(["strength-indicator",[n.value>=2?"active":""]])},null,2),e.createElementVNode("div",{class:e.normalizeClass(["strength-indicator",[n.value>=3?"active":""]])},null,2),e.createElementVNode("div",{class:e.normalizeClass(["strength-indicator",[n.value>=4?"active":""]])},null,2)],2),m.value?(e.openBlock(),e.createElementBlock("div",f,e.toDisplayString(v.value),1)):e.createCommentVNode("",!0)]))}}),_=h.default(x,[["__scopeId","data-v-9f72ae98"]]);exports.default=_;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e="";exports.default=e;
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src";
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jobsys-newbie",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/lib/index.js",
|
|
6
|
+
"module": "dist/es/index.mjs",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "vite",
|
|
9
|
+
"build": "vite build",
|
|
10
|
+
"release": "release-it"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"jobsys",
|
|
14
|
+
"newbie"
|
|
15
|
+
],
|
|
16
|
+
"author": "sinceow@163.com",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@wangeditor/editor": "^5.1.23",
|
|
20
|
+
"@wangeditor/editor-for-vue": "^5.1.12"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@ant-design/icons-vue": "^6.1.0",
|
|
24
|
+
"ant-design-vue": "^4.0.0",
|
|
25
|
+
"lodash-es": "^4.17.21",
|
|
26
|
+
"vue": "^3.3.4"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@vitejs/plugin-vue": "^4.2.3",
|
|
30
|
+
"autoprefixer": "^10.4.14",
|
|
31
|
+
"less": "^4.1.3",
|
|
32
|
+
"postcss": "^8.4.27",
|
|
33
|
+
"unplugin-vue-components": "^0.25.1",
|
|
34
|
+
"unplugin-vue-define-options": "^1.3.12",
|
|
35
|
+
"vite": "^4.4.5"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/jobsys/newbie"
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./password";
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="newbie-password">
|
|
3
|
+
<input-password v-model:value="password" @change="onChange" :minlength="min"
|
|
4
|
+
:maxlength="max"></input-password>
|
|
5
|
+
<div class="strength-indicator-container" :class="[classList[strength]]">
|
|
6
|
+
<div class="strength-indicator" :class="[strength >= 1 ? 'active' : '']"></div>
|
|
7
|
+
<div class="strength-indicator" :class="[strength >= 2 ? 'active' : '']"></div>
|
|
8
|
+
<div class="strength-indicator" :class="[strength >= 3 ? 'active' : '']"></div>
|
|
9
|
+
<div class="strength-indicator" :class="[strength >= 4 ? 'active' : '']"></div>
|
|
10
|
+
</div>
|
|
11
|
+
<div v-if="showError" class="error-message">{{ errorMessage }}</div>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup>
|
|
16
|
+
import {computed, ref, watch} from "vue"
|
|
17
|
+
import {InputPassword} from "ant-design-vue";
|
|
18
|
+
|
|
19
|
+
defineOptions({name: "newbie-password"})
|
|
20
|
+
|
|
21
|
+
const props = defineProps({
|
|
22
|
+
/**
|
|
23
|
+
* @model
|
|
24
|
+
*/
|
|
25
|
+
modelValue: {type: String, default: ""},
|
|
26
|
+
/**
|
|
27
|
+
* 最小长度
|
|
28
|
+
*/
|
|
29
|
+
min: {type: Number, default: 8},
|
|
30
|
+
/**
|
|
31
|
+
* 最大长度
|
|
32
|
+
*/
|
|
33
|
+
max: {type: Number, default: 20},
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const emits = defineEmits([
|
|
37
|
+
"update:modelValue",
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 输入框内容变化时的回调
|
|
41
|
+
* @event change
|
|
42
|
+
* @param {Object} e - 事件对象
|
|
43
|
+
*/
|
|
44
|
+
"change",
|
|
45
|
+
])
|
|
46
|
+
|
|
47
|
+
const password = ref("")
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 密码强度,0 为最弱,4 为最强
|
|
51
|
+
* @type {ComputedRef<number>}
|
|
52
|
+
*/
|
|
53
|
+
const strength = computed(() => {
|
|
54
|
+
let score = 0
|
|
55
|
+
const regexList = [
|
|
56
|
+
/\d/, // 包含数字
|
|
57
|
+
/[a-z]/, // 包含小写字母
|
|
58
|
+
/[A-Z]/, // 包含大写字母
|
|
59
|
+
/[^a-zA-Z0-9]/, // 包含特殊符号
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
regexList.forEach((regex) => {
|
|
63
|
+
if (regex.test(password.value)) {
|
|
64
|
+
score += 1
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
return score
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
const classList = ref(["", "bad", "weak", "medium", "strong"])
|
|
72
|
+
|
|
73
|
+
const onChange = (e) => {
|
|
74
|
+
const {value} = e.target
|
|
75
|
+
emits("change", e)
|
|
76
|
+
emits("update:modelValue", value)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const showError = computed(() => {
|
|
80
|
+
return (password.value.length > 0 && password.value.length < props.min) || password.value.length > props.max || strength.value < 4
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
const errorMessage = computed(() => {
|
|
84
|
+
if (password.value.length > 0 && password.value.length < props.min) {
|
|
85
|
+
return `密码长度不能少于${props.min}个字符`
|
|
86
|
+
}
|
|
87
|
+
if (password.value.length > props.max) {
|
|
88
|
+
return `密码长度不能超过${props.max}个字符`
|
|
89
|
+
}
|
|
90
|
+
if (strength.value < 4) {
|
|
91
|
+
return "密码必须包含数字、小写字母、大写字母和特殊符号"
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return ""
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
watch(
|
|
98
|
+
() => props.modelValue,
|
|
99
|
+
() => {
|
|
100
|
+
password.value = props.modelValue
|
|
101
|
+
},
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 密码强度指示器
|
|
106
|
+
*/
|
|
107
|
+
defineExpose({strength})
|
|
108
|
+
</script>
|
|
109
|
+
|
|
110
|
+
<style scoped lang="less">
|
|
111
|
+
.strength-indicator-container {
|
|
112
|
+
display: grid;
|
|
113
|
+
grid-template-columns: repeat(4, 1fr);
|
|
114
|
+
margin-top: 5px;
|
|
115
|
+
|
|
116
|
+
.strength-indicator {
|
|
117
|
+
height: 5px;
|
|
118
|
+
border: 1px solid #e8e8e8;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
&.bad {
|
|
122
|
+
.active {
|
|
123
|
+
background: #ff0000;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&.weak {
|
|
128
|
+
.active {
|
|
129
|
+
background: #ffa500;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
&.medium {
|
|
134
|
+
.active {
|
|
135
|
+
background: #ffff00;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
&.strong {
|
|
140
|
+
.active {
|
|
141
|
+
background: #008000;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.error-message {
|
|
147
|
+
color: red;
|
|
148
|
+
margin-top: 5px;
|
|
149
|
+
}
|
|
150
|
+
</style>
|
package/vite.config.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {defineConfig} from 'vite'
|
|
2
|
+
import {resolve} from "path";
|
|
3
|
+
import vue from '@vitejs/plugin-vue'
|
|
4
|
+
import Components from "unplugin-vue-components/vite"
|
|
5
|
+
import {AntDesignVueResolver} from "unplugin-vue-components/resolvers";
|
|
6
|
+
import DefineOptions from "unplugin-vue-define-options/vite";
|
|
7
|
+
|
|
8
|
+
// https://vitejs.dev/config/
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
plugins: [
|
|
11
|
+
vue({
|
|
12
|
+
template: {
|
|
13
|
+
transformAssetUrls: {
|
|
14
|
+
base: null,
|
|
15
|
+
includeAbsolute: false,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
}),
|
|
19
|
+
Components({
|
|
20
|
+
resolvers: [AntDesignVueResolver({importStyle: "less"})],
|
|
21
|
+
}),
|
|
22
|
+
DefineOptions()
|
|
23
|
+
],
|
|
24
|
+
resolve: {
|
|
25
|
+
alias: {
|
|
26
|
+
"@": "/src",
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
build: {
|
|
30
|
+
minify: true,
|
|
31
|
+
lib: {
|
|
32
|
+
entry: "./index.js",
|
|
33
|
+
},
|
|
34
|
+
rollupOptions: {
|
|
35
|
+
input: ["index.js"],
|
|
36
|
+
// make sure to externalize deps that shouldn't be bundled
|
|
37
|
+
// into your library
|
|
38
|
+
external: ["vue", "ant-design-vue"],
|
|
39
|
+
output: [
|
|
40
|
+
{
|
|
41
|
+
//打包格式
|
|
42
|
+
format: "es",
|
|
43
|
+
//打包后文件名
|
|
44
|
+
entryFileNames: "[name].mjs",
|
|
45
|
+
//让打包目录和我们目录对应
|
|
46
|
+
preserveModules: true,
|
|
47
|
+
exports: "named",
|
|
48
|
+
//配置打包根目录
|
|
49
|
+
dir: "dist/es",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
//打包格式
|
|
53
|
+
format: "cjs",
|
|
54
|
+
//打包后文件名
|
|
55
|
+
entryFileNames: "[name].js",
|
|
56
|
+
//让打包目录和我们目录对应
|
|
57
|
+
preserveModules: true,
|
|
58
|
+
exports: "named",
|
|
59
|
+
//配置打包根目录
|
|
60
|
+
dir: "dist/lib",
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
})
|