create-jnrs-template-vue 1.2.2 → 1.2.4

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.
Files changed (37) hide show
  1. package/jnrs-template-vue/.env.development +1 -1
  2. package/jnrs-template-vue/index.html +1 -1
  3. package/jnrs-template-vue/package.json +3 -4
  4. package/jnrs-template-vue/public/system/menu.json +11 -2
  5. package/jnrs-template-vue/src/App.vue +1 -3
  6. package/jnrs-template-vue/src/api/common/index.ts +2 -2
  7. package/jnrs-template-vue/src/api/demos/index.ts +85 -43
  8. package/jnrs-template-vue/src/api/system/index.ts +20 -10
  9. package/jnrs-template-vue/src/api/user/index.ts +2 -2
  10. package/jnrs-template-vue/src/assets/styles/index.scss +0 -24
  11. package/jnrs-template-vue/src/assets/styles/init.scss +24 -0
  12. package/jnrs-template-vue/src/assets/styles/root.scss +4 -0
  13. package/jnrs-template-vue/src/components/common/CardTable.vue +89 -0
  14. package/jnrs-template-vue/src/components/common/DictTag.vue +8 -4
  15. package/jnrs-template-vue/src/components/common/ImageView.vue +16 -7
  16. package/jnrs-template-vue/src/components/common/PdfView.vue +14 -5
  17. package/jnrs-template-vue/src/components/select/SelectManager.vue +2 -2
  18. package/jnrs-template-vue/src/layout/SideMenu.vue +0 -1
  19. package/jnrs-template-vue/src/layout/TopHeader.vue +7 -14
  20. package/jnrs-template-vue/src/locales/index.ts +1 -1
  21. package/jnrs-template-vue/src/types/webSocket.ts +19 -0
  22. package/jnrs-template-vue/src/utils/file.ts +36 -1
  23. package/jnrs-template-vue/src/views/demos/crud/index.vue +57 -32
  24. package/jnrs-template-vue/src/views/demos/simpleTable/index.vue +41 -0
  25. package/jnrs-template-vue/src/views/demos/unitTest/RequestPage.vue +2 -2
  26. package/jnrs-template-vue/src/views/demos/unitTest/index.vue +26 -2
  27. package/jnrs-template-vue/src/views/login/index.vue +18 -15
  28. package/jnrs-template-vue/src/views/system/dict/index.vue +63 -76
  29. package/jnrs-template-vue/src/views/system/menu/index.vue +42 -54
  30. package/jnrs-template-vue/src/views/system/mine/baseInfo.vue +26 -59
  31. package/jnrs-template-vue/src/views/system/role/index.vue +20 -29
  32. package/jnrs-template-vue/src/views/visual/index.vue +130 -15
  33. package/jnrs-template-vue/vite.config.ts +0 -1
  34. package/jnrs-template-vue/viteMockServe/fail.ts +12 -0
  35. package/package.json +1 -1
  36. package/jnrs-template-vue/src/composables/base/useAvatar.ts +0 -36
  37. package/jnrs-template-vue/src/composables/tools/useMouseSelection.ts +0 -150
@@ -1,36 +0,0 @@
1
- import { ref, toRefs, watch } from 'vue'
2
- // import { getImgSrc } from '@/utils/common'
3
- // import { useCommonStore } from '@jnrs/vue-core/pinia'
4
- // import imgFailed from '@/assets/img/common/404.png'
5
- import defaultAvatar from '@/assets/images/common/avatar.png'
6
-
7
- export const useAvatar = () => {
8
- // const { userInfo } = toRefs(useCommonStore())
9
- const avatar = ref(defaultAvatar)
10
-
11
- // watch(
12
- // () => userInfo.value.avatar,
13
- // nv => {
14
- // if (nv) {
15
- // getImgSrc(nv).then(res => {
16
- // avatar.value = URL.createObjectURL(res.data)
17
- // })
18
- // }
19
- // }
20
- // )
21
-
22
- // const at = userInfo.value.avatar
23
- // if (at) {
24
- // getImgSrc(at)
25
- // .then(res => {
26
- // avatar.value = URL.createObjectURL(res.data)
27
- // })
28
- // .catch(() => {
29
- // avatar.value = imgFailed
30
- // })
31
- // }
32
-
33
- return {
34
- avatar
35
- }
36
- }
@@ -1,150 +0,0 @@
1
- /**
2
- * @Author : TanRui
3
- * @WeChat : Tan578853789
4
- * @File : useMouseSelection.ts
5
- * @Date : 2025/04/14
6
- * @Desc. : 鼠标框选表格进行多选、回车执行回调
7
- */
8
-
9
- import { onMounted, onUnmounted, onActivated, onDeactivated } from 'vue'
10
-
11
- /**
12
- * @param {*} containerClass 表格或容器类名,默认值 el-table,如果页面存在多个表格,则必须分别传入自定义类名
13
- * @param {*} rowClass 表格或容器类名,默认值 el-table__row
14
- * @param {*} callback 框选后的回调,默认处理的是 input[type='checkbox'] 元素
15
- * @returns handleMouseDown
16
- * @example <el-table @mousedown="handleMouseDown" @selection-change="handleSelectionChange">
17
- */
18
- export function useMouseSelection({
19
- containerClass = 'jn_table',
20
- rowClass = 'el-table__row',
21
- callback = handleSelection
22
- } = {}) {
23
- let isDragging = false
24
- let startPoint = { x: 0, y: 0 }
25
- let endPoint = { x: 0, y: 0 }
26
-
27
- onMounted(() => {
28
- window.addEventListener('mouseup', handleMouseUp)
29
- })
30
-
31
- onUnmounted(() => {
32
- window.removeEventListener('mouseup', handleMouseUp)
33
- })
34
-
35
- onActivated(() => {
36
- window.addEventListener('mouseup', handleMouseUp)
37
- })
38
-
39
- onDeactivated(() => {
40
- window.removeEventListener('mouseup', handleMouseUp)
41
- })
42
-
43
- // 鼠标按下事件
44
- const handleMouseDown = (event: MouseEvent) => {
45
- window.addEventListener('mousemove', handleMouseMove)
46
- isDragging = false
47
- startPoint = { x: event.clientX, y: event.clientY }
48
- endPoint = { ...startPoint }
49
- }
50
-
51
- // 鼠标移动事件
52
- const handleMouseMove = (event: MouseEvent) => {
53
- endPoint = { x: event.clientX, y: event.clientY }
54
- // 判断是否为拖动
55
- if (Math.abs(endPoint.x - startPoint.x) > 5 && Math.abs(endPoint.y - startPoint.y) > 25) {
56
- isDragging = true
57
- }
58
- // 如果没有拖动,则认为是单击
59
- if (isDragging) {
60
- selectRows()
61
- }
62
- setFixedRectBoxStyle()
63
- }
64
-
65
- // 鼠标抬起事件
66
- const handleMouseUp = () => {
67
- window.removeEventListener('mousemove', handleMouseMove)
68
- // 如果没有拖动,则认为是单击
69
- if (isDragging) {
70
- isDragging = false
71
- }
72
- setFixedRectBoxStyle()
73
- }
74
-
75
- // 判断选中的行
76
- const selectRows = () => {
77
- const container = document.querySelector(`.${containerClass}`) as HTMLElement
78
- const rows = container?.querySelectorAll(`.${rowClass}`) as NodeListOf<HTMLElement>
79
- if (!rows) {
80
- return false
81
- }
82
- rows.forEach((row) => {
83
- const rect = row.getBoundingClientRect()
84
- const isIntersecting =
85
- rect.right > Math.min(startPoint.x, endPoint.x) &&
86
- rect.left < Math.max(startPoint.x, endPoint.x) &&
87
- rect.bottom > Math.min(startPoint.y, endPoint.y) &&
88
- rect.top < Math.max(startPoint.y, endPoint.y)
89
- if (isIntersecting && callback) {
90
- callback(row)
91
- }
92
- })
93
- }
94
-
95
- // 设置框选框的位置
96
- const setFixedRectBoxStyle = () => {
97
- const selectionBox = document.querySelector('.useMouseSelection_fixedRectBox') as HTMLElement
98
- if (selectionBox) {
99
- const left = Math.min(startPoint.x, endPoint.x) + 'px'
100
- const top = Math.min(startPoint.y, endPoint.y) + 'px'
101
- const width = Math.abs(endPoint.x - startPoint.x) + 'px'
102
- const height = Math.abs(endPoint.y - startPoint.y) + 'px'
103
- Object.assign(selectionBox.style, {
104
- display: isDragging ? 'block' : 'none',
105
- left: left,
106
- top: top,
107
- width: width,
108
- height: height
109
- })
110
-
111
- const container = document.querySelector(`.${containerClass}`) as HTMLElement
112
- Object.assign(container.style, {
113
- 'user-select': isDragging ? 'none' : 'auto'
114
- })
115
- }
116
- }
117
-
118
- checkAndAddElement()
119
-
120
- return {
121
- handleMouseDown
122
- }
123
- }
124
-
125
- // 回调选中逻辑
126
- const handleSelection = (row: HTMLElement) => {
127
- const checkbox = row.querySelector("input[type='checkbox']") as HTMLInputElement
128
- if (checkbox && !checkbox.checked) {
129
- checkbox.click()
130
- }
131
- }
132
-
133
- // 往页面上添加框选框元素
134
- const checkAndAddElement = () => {
135
- const fixedRectBox = document.querySelector('.useMouseSelection_fixedRectBox')
136
- if (!fixedRectBox) {
137
- const newDiv = document.createElement('div')
138
- newDiv.className = 'useMouseSelection_fixedRectBox'
139
- Object.assign(newDiv.style, {
140
- display: 'none',
141
- position: 'fixed',
142
- 'z-index': 100,
143
- border: '2px dashed #409eff',
144
- 'background-color': 'rgba(64, 158, 255, 0.2)',
145
- 'pointer-events': 'none',
146
- 'will-change': 'transform'
147
- })
148
- document.body.appendChild(newDiv)
149
- }
150
- }