@luzhaoqi/test 0.0.53 → 0.0.55

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.
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/npm-test.iml" filepath="$PROJECT_DIR$/.idea/npm-test.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
7
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
+ </content>
9
+ <orderEntry type="inheritedJdk" />
10
+ <orderEntry type="sourceFolder" forTests="false" />
11
+ </component>
12
+ </module>
package/README.md CHANGED
@@ -1,35 +1,74 @@
1
- # vue-project
1
+ # @luzhaoqi/test
2
2
 
3
- This template should help get you started developing with Vue 3 in Vite.
3
+ Vue 数学运算插件,提供加法和减法功能。
4
4
 
5
- ## Recommended IDE Setup
5
+ ## 安装
6
6
 
7
- [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
7
+ ```bash
8
+ npm install @luzhaoqi/test
9
+ ```
10
+
11
+ ## 普通使用
12
+
13
+ ```javascript
14
+ const { add, subtract } = require('@luzhaoqi/test');
15
+
16
+ console.log(add(1, 2, 3)); // 6
17
+ console.log(subtract(5, 3)); // 2
18
+ ```
8
19
 
9
- ## Customize configuration
20
+ ## Vue 插件使用
10
21
 
11
- See [Vite Configuration Reference](https://vitejs.dev/config/).
22
+ ### 全局安装
12
23
 
13
- ## Project Setup
24
+ ```javascript
25
+ import Vue from 'vue';
26
+ import VueMathOps from '@luzhaoqi/test/src/vue-plugin';
14
27
 
15
- ```sh
16
- npm install
28
+ Vue.use(VueMathOps);
17
29
  ```
18
30
 
19
- ### Compile and Hot-Reload for Development
31
+ ### 使用方式
20
32
 
21
- ```sh
22
- npm run dev
33
+ 1. 全局方法:
34
+ ```javascript
35
+ Vue.add(1, 2, 3); // 6
36
+ Vue.subtract(5, 3); // 2
23
37
  ```
24
38
 
25
- ### Compile and Minify for Production
39
+ 2. 实例方法:
40
+ ```javascript
41
+ this.$add(1, 2, 3); // 6
42
+ this.$subtract(5, 3); // 2
43
+ ```
44
+
45
+ 3. 过滤器:
46
+ ```html
47
+ <div>{{ [1, 2, 3] | add }}</div>
48
+ <!-- 渲染为: 6 -->
26
49
 
27
- ```sh
28
- npm run build
50
+ <div>{{ [5, 3] | subtract }}</div>
51
+ <!-- 渲染为: 2 -->
29
52
  ```
30
53
 
31
- ### Lint with [ESLint](https://eslint.org/)
54
+ 4. 指令:
55
+ ```html
56
+ <div v-add="[1, 2, 3]"></div>
57
+ <!-- 渲染为: 6 -->
32
58
 
33
- ```sh
34
- npm run lint
59
+ <div v-subtract="[5, 3]"></div>
60
+ <!-- 渲染为: 2 -->
35
61
  ```
62
+
63
+ ## API 文档
64
+
65
+ ### `add(...numbers)`
66
+ - `...numbers`: 要相加的数字(一个或多个)
67
+ - 返回: 所有数字的和
68
+ - 抛出: 如果任何参数不是数字,则抛出 TypeError
69
+
70
+ ### `subtract(a, b)`
71
+ - `a`: 被减数
72
+ - `b`: 减数
73
+ - 返回: a - b 的结果
74
+ - 抛出: 如果参数不是数字,则抛出 TypeError
package/package.json CHANGED
@@ -1,51 +1,26 @@
1
- {
2
- "name": "@luzhaoqi/test",
3
- "version": "0.0.53",
4
- "private": false,
5
- "main": "dist/z-ui3.mjs",
6
- "files": [
7
- "dist"
8
- ],
9
- "scripts": {
10
- "dev": "vite",
11
- "build": "vite build",
12
- "preview": "vite preview",
13
- "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore",
14
- "format": "prettier --write src/",
15
- "pub": "npm publish --access public",
16
- "lib": "npm run build & npm run pub"
17
- },
18
- "dependencies": {
19
- "@element-plus/icons-vue": "^2.3.1",
20
- "axios": "^1.6.3",
21
- "clipboard": "^2.0.11",
22
- "element-plus": "^2.4.4",
23
- "file-saver": "^2.0.5",
24
- "fuse.js": "6.4.3",
25
- "js-cookie": "^3.0.1",
26
- "jsencrypt": "^3.0.0-rc.1",
27
- "mockjs": "^1.1.0",
28
- "nprogress": "^0.2.0",
29
- "pinia": "^2.1.7",
30
- "pinia-plugin-persist": "^1.0.0",
31
- "screenfull": "5.0.2",
32
- "quill": "1.3.7",
33
- "vue": "^3.3.11",
34
- "vue-meta": "^2.4.0",
35
- "vue-router": "^4.2.5"
36
- },
37
- "devDependencies": {
38
- "@rushstack/eslint-patch": "^1.3.3",
39
- "@vitejs/plugin-vue": "^4.5.2",
40
- "@vitejs/plugin-vue-jsx": "^3.1.0",
41
- "@vue/eslint-config-prettier": "^8.0.0",
42
- "eslint": "^8.49.0",
43
- "eslint-plugin-vue": "^9.17.0",
44
- "prettier": "^3.0.3",
45
- "sass": "1.69.5",
46
- "unplugin-auto-import": "^0.17.3",
47
- "unplugin-vue-components": "^0.26.0",
48
- "vite": "^5.0.10",
49
- "vite-plugin-vue-setup-extend": "^0.4.0"
50
- }
51
- }
1
+ {
2
+ "name": "@luzhaoqi/test",
3
+ "version": "0.0.55",
4
+ "private": false,
5
+ "description": "A simple math library with sum function",
6
+ "main": "src/index.js",
7
+ "module": "src/vue-plugin.js",
8
+ "scripts": {
9
+ "test": "jest",
10
+ "pub": "npm publish --access public"
11
+ },
12
+ "keywords": [
13
+ "math",
14
+ "sum",
15
+ "addition",
16
+ "calculator"
17
+ ],
18
+ "author": "lzq",
19
+ "license": "MIT",
20
+ "peerDependencies": {
21
+ "vue": "^2.6.0 || ^3.0.0"
22
+ },
23
+ "devDependencies": {
24
+ "jest": "^27.0.6"
25
+ }
26
+ }
package/src/index.js ADDED
@@ -0,0 +1,38 @@
1
+ /**
2
+ * 加法函数
3
+ * @param {...number} numbers - 要相加的数字
4
+ * @returns {number} 和
5
+ * @throws {TypeError} 如果参数不是数字
6
+ */
7
+ function add(...numbers) {
8
+ validateNumbers(numbers);
9
+ return numbers.reduce((total, num) => total + num, 0);
10
+ }
11
+
12
+ /**
13
+ * 减法函数
14
+ * @param {number} a - 被减数
15
+ * @param {number} b - 减数
16
+ * @returns {number} 差
17
+ * @throws {TypeError} 如果参数不是数字
18
+ */
19
+ function subtract(a, b) {
20
+ validateNumbers([a, b]);
21
+ return a - b;
22
+ }
23
+
24
+ /**
25
+ * 验证数字
26
+ * @param {Array} numbers - 要验证的数字数组
27
+ * @throws {TypeError} 如果任何参数不是数字
28
+ */
29
+ function validateNumbers(numbers) {
30
+ if (!numbers.every(num => typeof num === 'number' && !isNaN(num))) {
31
+ throw new TypeError('所有参数必须是有效数字');
32
+ }
33
+ }
34
+
35
+ module.exports = {
36
+ add,
37
+ subtract
38
+ };
@@ -0,0 +1,39 @@
1
+ const { add, subtract } = require('./index');
2
+
3
+ const VueMathOpsPlugin = {
4
+ install(Vue, options) {
5
+ // 添加全局方法
6
+ Vue.add = add;
7
+ Vue.subtract = subtract;
8
+
9
+ // 添加实例方法
10
+ Vue.prototype.$add = add;
11
+ Vue.prototype.$subtract = subtract;
12
+
13
+ // 添加全局过滤器
14
+ Vue.filter('add', function(numbers) {
15
+ return add(...numbers);
16
+ });
17
+
18
+ Vue.filter('subtract', function(numbers) {
19
+ return subtract(...numbers);
20
+ });
21
+
22
+ // 添加指令
23
+ Vue.directive('add', {
24
+ bind(el, binding) {
25
+ el.textContent = add(...binding.value);
26
+ }
27
+ });
28
+
29
+ Vue.directive('subtract', {
30
+ bind(el, binding) {
31
+ if (binding.value.length === 2) {
32
+ el.textContent = subtract(...binding.value);
33
+ }
34
+ }
35
+ });
36
+ }
37
+ };
38
+
39
+ module.exports = VueMathOpsPlugin;
@@ -0,0 +1,17 @@
1
+ const { add, subtract } = require('../src/index');
2
+
3
+ test('add function', () => {
4
+ expect(add(1, 2, 3)).toBe(6);
5
+ expect(add(10, -5, 3.5)).toBe(8.5);
6
+ expect(add()).toBe(0);
7
+ });
8
+
9
+ test('subtract function', () => {
10
+ expect(subtract(5, 3)).toBe(2);
11
+ expect(subtract(10, -5)).toBe(15);
12
+ });
13
+
14
+ test('error handling', () => {
15
+ expect(() => add('a', 2)).toThrow(TypeError);
16
+ expect(() => subtract('a', 2)).toThrow(TypeError);
17
+ });
@@ -1,172 +0,0 @@
1
- import { getCurrentInstance as O, computed as S, onMounted as N, ref as d, resolveComponent as a, openBlock as r, createBlock as k, unref as s, withCtx as t, createVNode as o, createElementBlock as C, Fragment as w, renderList as $, withKeys as E, createTextVNode as m } from "vue";
2
- import K from "./dictEdit-RfQqA5M4.mjs";
3
- import { d as L, l as M, a as Q } from "./dict-vkW5oXQf.mjs";
4
- import { u as F } from "./index-Fj2kjzW4.mjs";
5
- import "./main-cLwCUpDd.mjs";
6
- const X = {
7
- __name: "dict",
8
- setup(I) {
9
- const i = O().proxy.$z, x = F(), h = S(() => i.$store.dict.getDictByCode("sys_status"));
10
- N(() => {
11
- i.$store.dict.setDictByCode("sys_status"), z();
12
- });
13
- const T = d({
14
- api: L,
15
- hiddenQuery: {
16
- dictType: x.params.id
17
- },
18
- columns: [
19
- { label: "字典编号", type: "index", width: 90 },
20
- { label: "字典标签", prop: "lable" },
21
- { label: "字典键值", prop: "value" },
22
- { label: "字典排序", prop: "dictSort" },
23
- { label: "状态", prop: "status", slot: !0 },
24
- { label: "备注", prop: "remark" },
25
- { label: "操作", prop: "menu", width: "200", slot: !0 }
26
- ]
27
- }), _ = d([]), z = () => {
28
- M({ pageSize: 9999 }).then((n) => {
29
- _.value = n.records || [];
30
- });
31
- }, f = d(), b = d(), c = () => {
32
- f.value.handleQuery();
33
- }, v = (n, u) => {
34
- n === "add" ? b.value.show(n, f.value.queryParams) : b.value.show(n, u);
35
- }, B = (n) => {
36
- i.$modal.confirm("是否确认删除名称为" + n.lable + "的数据项?", "警告", {
37
- confirmButtonText: "确定",
38
- cancelButtonText: "取消",
39
- type: "warning"
40
- }).then(() => {
41
- Q(n.id).then(() => {
42
- i.$modal.msgSuccess("删除成功"), c();
43
- }).catch((u) => {
44
- console.log(u), i.$modal.msgError("删除失败");
45
- });
46
- });
47
- };
48
- return (n, u) => {
49
- const g = a("el-option"), V = a("el-select"), y = a("el-form-item"), D = a("el-input"), p = a("el-button"), A = a("z-dict-tag"), U = a("z-list");
50
- return r(), k(U, {
51
- ref_key: "list",
52
- ref: f,
53
- tableOption: s(T)
54
- }, {
55
- form: t(({ queryParams: l }) => [
56
- o(y, { label: "字典类型" }, {
57
- default: t(() => [
58
- o(V, {
59
- modelValue: l.dictType,
60
- "onUpdate:modelValue": (e) => l.dictType = e,
61
- clearable: "",
62
- filterable: "",
63
- onChange: c
64
- }, {
65
- default: t(() => [
66
- (r(!0), C(w, null, $(s(_), (e) => (r(), k(g, {
67
- key: e.dictType,
68
- label: e.dictName,
69
- value: e.dictType
70
- }, null, 8, ["label", "value"]))), 128))
71
- ]),
72
- _: 2
73
- }, 1032, ["modelValue", "onUpdate:modelValue"])
74
- ]),
75
- _: 2
76
- }, 1024),
77
- o(y, { label: "字典标签" }, {
78
- default: t(() => [
79
- o(D, {
80
- modelValue: l.lable,
81
- "onUpdate:modelValue": (e) => l.lable = e,
82
- placeholder: "请输入字典标签",
83
- clearable: "",
84
- onKeyup: E(c, ["enter", "native"])
85
- }, null, 8, ["modelValue", "onUpdate:modelValue"])
86
- ]),
87
- _: 2
88
- }, 1024),
89
- o(y, { label: "状态" }, {
90
- default: t(() => [
91
- o(V, {
92
- modelValue: l.status,
93
- "onUpdate:modelValue": (e) => l.status = e,
94
- clearable: ""
95
- }, {
96
- default: t(() => [
97
- (r(!0), C(w, null, $(s(h), (e) => (r(), k(g, {
98
- key: e.value,
99
- label: e.label,
100
- value: e.value
101
- }, null, 8, ["label", "value"]))), 128))
102
- ]),
103
- _: 2
104
- }, 1032, ["modelValue", "onUpdate:modelValue"])
105
- ]),
106
- _: 2
107
- }, 1024)
108
- ]),
109
- leftMenu: t(() => [
110
- o(p, {
111
- onClick: u[0] || (u[0] = (l) => v("add")),
112
- icon: "el-icon-plus",
113
- type: "primary",
114
- plain: ""
115
- }, {
116
- default: t(() => [
117
- m("新增字典")
118
- ]),
119
- _: 1
120
- })
121
- ]),
122
- status: t((l) => [
123
- o(A, {
124
- options: s(h),
125
- value: l.row.status
126
- }, null, 8, ["options", "value"])
127
- ]),
128
- menu: t((l) => [
129
- o(p, {
130
- link: "",
131
- onClick: (e) => v("edit", l.row)
132
- }, {
133
- default: t(() => [
134
- m("编辑")
135
- ]),
136
- _: 2
137
- }, 1032, ["onClick"]),
138
- o(p, {
139
- link: "",
140
- onClick: (e) => v("view", l.row)
141
- }, {
142
- default: t(() => [
143
- m("详情")
144
- ]),
145
- _: 2
146
- }, 1032, ["onClick"]),
147
- o(p, {
148
- link: "",
149
- onClick: (e) => B(l.row)
150
- }, {
151
- default: t(() => [
152
- m("删除")
153
- ]),
154
- _: 2
155
- }, 1032, ["onClick"])
156
- ]),
157
- default: t(() => [
158
- o(K, {
159
- ref_key: "dialog",
160
- ref: b,
161
- typeArr: s(_),
162
- onOk: c
163
- }, null, 8, ["typeArr"])
164
- ]),
165
- _: 1
166
- }, 8, ["tableOption"]);
167
- };
168
- }
169
- };
170
- export {
171
- X as default
172
- };
@@ -1,66 +0,0 @@
1
- import { a as r } from "./main-cLwCUpDd.mjs";
2
- const u = r.config.globalProperties.$z, e = u.$http;
3
- function n(t) {
4
- return e.request({
5
- url: "/ucenter/dict/type/queryPage",
6
- method: "post",
7
- data: t
8
- });
9
- }
10
- function c(t) {
11
- return e.request({
12
- url: "/ucenter/dict/type/save",
13
- method: "post",
14
- data: t
15
- });
16
- }
17
- function d(t) {
18
- return e.request({
19
- url: "/ucenter/dict/type/update",
20
- method: "post",
21
- data: t
22
- });
23
- }
24
- function o(t) {
25
- return e.request({
26
- url: `ucenter/dict/type/del/${t}`,
27
- method: "post"
28
- });
29
- }
30
- function s(t) {
31
- return e.request({
32
- url: "/ucenter/dict/queryPage",
33
- method: "post",
34
- data: t
35
- });
36
- }
37
- function p(t) {
38
- return e.request({
39
- url: "/ucenter/dict/save",
40
- method: "post",
41
- data: t
42
- });
43
- }
44
- function a(t) {
45
- return e.request({
46
- url: "/ucenter/dict/update",
47
- method: "post",
48
- data: t
49
- });
50
- }
51
- function l(t) {
52
- return e.request({
53
- url: `ucenter/dict/del/${t}`,
54
- method: "post"
55
- });
56
- }
57
- export {
58
- l as a,
59
- a as b,
60
- p as c,
61
- s as d,
62
- o as e,
63
- d as f,
64
- c as g,
65
- n as l
66
- };