create-jnrs-vue 1.2.21 → 1.2.23

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 (52) hide show
  1. package/README.md +1 -1
  2. package/jnrs-vue/.env.development +1 -1
  3. package/jnrs-vue/README.md +1 -1
  4. package/{bin → jnrs-vue/bin}/upgrade.mjs +2 -2
  5. package/jnrs-vue/package.json +6 -3
  6. package/jnrs-vue/src/api/common/index.ts +2 -2
  7. package/jnrs-vue/src/api/demos/index.ts +73 -32
  8. package/jnrs-vue/src/api/request.ts +10 -11
  9. package/jnrs-vue/src/api/system/index.ts +27 -26
  10. package/jnrs-vue/src/components/common/CardTable.vue +3 -3
  11. package/jnrs-vue/src/components/common/DictTag.vue +1 -1
  12. package/jnrs-vue/src/components/common/ImageView.vue +4 -4
  13. package/jnrs-vue/src/components/common/PdfView.vue +4 -4
  14. package/jnrs-vue/src/components/select/SelectManager.vue +2 -2
  15. package/jnrs-vue/src/composables/useCrud.ts +29 -10
  16. package/jnrs-vue/src/layout/RouterTabs.vue +6 -6
  17. package/jnrs-vue/src/layout/SideMenuItem.vue +2 -2
  18. package/jnrs-vue/src/layout/TopHeader.vue +2 -1
  19. package/jnrs-vue/src/layout/index.vue +2 -1
  20. package/jnrs-vue/src/locales/en.ts +1 -1
  21. package/jnrs-vue/src/main.ts +2 -7
  22. package/jnrs-vue/src/router/index.ts +5 -4
  23. package/jnrs-vue/src/stores/index.ts +8 -0
  24. package/jnrs-vue/src/stores/system/auth.ts +67 -0
  25. package/jnrs-vue/src/types/index.ts +2 -81
  26. package/jnrs-vue/src/types/system.d.ts +115 -0
  27. package/jnrs-vue/src/types/system.js +1 -0
  28. package/jnrs-vue/src/types/system.ts +124 -0
  29. package/jnrs-vue/src/types/webSocket.ts +4 -4
  30. package/jnrs-vue/src/utils/dict.ts +59 -0
  31. package/jnrs-vue/src/utils/file.ts +1 -1
  32. package/jnrs-vue/src/utils/index.ts +4 -0
  33. package/jnrs-vue/src/utils/packages.ts +6 -65
  34. package/jnrs-vue/src/utils/permissions.ts +1 -1
  35. package/jnrs-vue/src/views/demos/crud/index.vue +29 -17
  36. package/jnrs-vue/src/views/demos/simpleTable/index.vue +2 -2
  37. package/jnrs-vue/src/views/demos/unitTest/RequestPage.vue +30 -7
  38. package/jnrs-vue/src/views/demos/unitTest/index.vue +2 -2
  39. package/jnrs-vue/src/views/home/index.vue +1 -1
  40. package/jnrs-vue/src/views/login/index.vue +2 -2
  41. package/jnrs-vue/src/views/system/dict/index.vue +4 -4
  42. package/jnrs-vue/src/views/system/mine/baseInfo.vue +2 -2
  43. package/jnrs-vue/src/views/system/mine/securitySettings.vue +1 -1
  44. package/jnrs-vue/src/views/visual/index.vue +3 -4
  45. package/jnrs-vue/vite.config.ts +2 -2
  46. package/jnrs-vue/viteMockServe/fail.ts +3 -3
  47. package/jnrs-vue/viteMockServe/file.ts +1 -1
  48. package/jnrs-vue/viteMockServe/index.ts +7 -16
  49. package/jnrs-vue/viteMockServe/json/loginRes_user.json +21 -1
  50. package/jnrs-vue/viteMockServe/success.ts +5 -5
  51. package/package.json +2 -3
  52. package/jnrs-vue/src/api/user/index.ts +0 -12
@@ -7,86 +7,27 @@
7
7
  */
8
8
 
9
9
  import { ElMessage, ElLoading } from 'element-plus'
10
- import {
11
- getDictList as _getDictList,
12
- getDictLabel as _getDictLabel,
13
- getDictValue as _getDictValue,
14
- getDictColor as _getDictColor,
15
- downloadByBlob as _downloadByBlob
16
- } from '@jnrs/shared'
17
- import { useAuthStore } from '@jnrs/vue-core/pinia'
18
- import { objectToFormData as _objectToFormData } from '@jnrs/shared'
10
+ import { objectToFormData as _objectToFormData, downloadByBlob as _downloadByBlob } from '@jnrs/shared'
19
11
  import { FileApi } from '@/api/common'
20
12
 
21
- /**
22
- * 根据字典名称获取字典数据
23
- * @param name 字典名称
24
- * @returns 某字典名称所对应的字典列表数据
25
- */
26
- export const getDictList = (name: string) => {
27
- const { dict } = useAuthStore()
28
- if (dict) {
29
- return _getDictList(name, dict)
30
- }
31
- }
32
-
33
- /**
34
- * 根据字典名称和字典值获取字典标签
35
- * @param name 字典名称
36
- * @param value 字典值
37
- * @returns 某字典名称所对应的字典标签
38
- */
39
- export const getDictLabel = (name: string, value: string | number) => {
40
- const { dict } = useAuthStore()
41
- if (dict) {
42
- return _getDictLabel(name, value, dict)
43
- }
44
- }
45
-
46
- /**
47
- * 根据字典名称和字典标签获取字典值
48
- * @param name 字典名称
49
- * @param label 字典标签
50
- * @returns 某字典名称所对应的字典值
51
- */
52
- export const getDictValue = (name: string, label: string) => {
53
- const { dict } = useAuthStore()
54
- if (dict) {
55
- return _getDictValue(name, label, dict)
56
- }
57
- }
58
-
59
- /**
60
- * 根据字典名称和字典值获取字典颜色
61
- * @param name 字典名称
62
- * @param value 字典值
63
- * @returns 某字典名称所对应的字典颜色
64
- */
65
- export const getDictColor = (name: string, value: string | number) => {
66
- const { dict } = useAuthStore()
67
- if (dict) {
68
- return _getDictColor(name, value, dict)
69
- }
70
- }
71
-
72
13
  /**
73
14
  * 将对象转为 FormData
74
15
  * @param obj 对象
75
16
  * @returns FormData
76
17
  */
77
- export const objectToFormData = (obj: Record<string, unknown>) => {
18
+ export const objectToFormData = (obj: object): FormData => {
78
19
  // 根据后端返回结果处理的映射关系
79
20
  const mapConfig = {
80
21
  // 图片
81
- newImageFiles: { finallyKey: 'orginImageNames', valueKey: 'uniqueFileName' },
22
+ newImageFiles: { finallyKey: 'originImageNames', valueKey: 'uniqueFileName' },
82
23
  // 通用附件
83
- newAttachmentFile: { finallyKey: 'orginAttachmentName', valueKey: 'uniqueFileName' },
24
+ newAttachmentFile: { finallyKey: 'originAttachmentName', valueKey: 'uniqueFileName' },
84
25
  // 程序文件
85
- newProgramFile: { finallyKey: 'orginProgramName', valueKey: 'uniqueFileName' },
26
+ newProgramFile: { finallyKey: 'originProgramName', valueKey: 'uniqueFileName' },
86
27
  // 数据库
87
28
  databaseFile: { finallyKey: 'databaseFile', valueKey: 'uniqueFileName' }
88
29
  }
89
- return _objectToFormData(obj, mapConfig)
30
+ return _objectToFormData(obj as Record<string, unknown>, mapConfig)
90
31
  }
91
32
 
92
33
  /**
@@ -1,5 +1,5 @@
1
1
  import { hasPermissionWithSuffix } from '@jnrs/shared'
2
- import { useAuthStore } from '@jnrs/vue-core/pinia'
2
+ import { useAuthStore } from '@/stores'
3
3
 
4
4
  // 菜单查看权限
5
5
  export function hasMenuViewPermission(requiredPerms: string[] | undefined) {
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import type { FormInstance, FormRules } from 'element-plus'
3
- import type { Attachment, Pagination } from '@/types'
4
- import type { ProjectItem, AddProjectItem } from '@/api/demos/index'
3
+ import type { IAttachment, IPagination } from '@/types'
4
+ import type { Project, EditProject } from '@/api/demos/index'
5
5
  import { ref, onActivated, nextTick } from 'vue'
6
6
  import { ElMessage, ElMessageBox } from 'element-plus'
7
7
  import { Plus } from '@element-plus/icons-vue'
@@ -9,31 +9,38 @@ import { useRoute } from '@jnrs/vue-core/router'
9
9
  import { objectMatchAssign, dateFormatsToObject } from '@jnrs/shared'
10
10
  import { debounce } from '@jnrs/shared/lodash'
11
11
  import { isNumberGtZero } from '@jnrs/shared/validator'
12
- import { getDictList, downloadFile } from '@/utils/packages'
12
+ import { getDictList, downloadFile, extractFieldId } from '@/utils'
13
13
  import { useI18n } from '@/locales'
14
- import { ListApi, EditApi, DelApi, ImportTemplateApi, ImportDataApi, ExportApi } from '@/api/demos/index'
14
+ import {
15
+ ProjectListApi,
16
+ EditProjectApi,
17
+ DeleteProjectApi,
18
+ DownloadTemplateApi,
19
+ ImportDataApi,
20
+ ExportApi
21
+ } from '@/api/demos/index'
15
22
  import { JnDialog, JnDatetime, JnPagination, JnFileUpload, JnTable, JnImportAndExport } from '@jnrs/vue-core/components'
16
23
  import ImageView from '@/components/common/ImageView.vue'
17
24
  import PdfView from '@/components/common/PdfView.vue'
18
25
  import DictTag from '@/components/common/DictTag.vue'
19
26
  import SelectManager from '@/components/select/SelectManager.vue'
20
27
 
21
- interface ProcessedProjectItem extends ProjectItem {
22
- newImageFiles?: Attachment[]
23
- newAttachmentFile?: Attachment[]
28
+ interface ProcessedProjectItem extends Project {
29
+ newImageFiles?: IAttachment[]
30
+ newAttachmentFile?: IAttachment[]
24
31
  }
25
32
 
26
33
  const { t: $t } = useI18n()
27
34
  const loading = ref(false)
28
35
  const tableData = ref<ProcessedProjectItem[]>([])
29
36
  const total = ref(0)
30
- const pagination = ref<Pagination>({ pageNo: 1, pageSize: 20 })
37
+ const pagination = ref<IPagination>({ pageNo: 1, pageSize: 20 })
31
38
  const route = useRoute()
32
39
 
33
40
  // 编辑
34
41
  const editDialogRef = ref()
35
42
  const ruleFormRef = ref<FormInstance>()
36
- const ruleForm = ref<AddProjectItem>({
43
+ const ruleForm = ref<EditProject>({
37
44
  id: '',
38
45
  name: '',
39
46
  projectType: undefined,
@@ -67,14 +74,14 @@ const queryForm = ref({
67
74
  plannedStartDate: ''
68
75
  })
69
76
 
70
- const handleSelectionChange = (row: ProjectItem[]) => {
77
+ const handleSelectionChange = (row: Project[]) => {
71
78
  console.log(row)
72
79
  }
73
80
 
74
81
  const getTable = debounce(async () => {
75
82
  loading.value = true
76
83
  try {
77
- const res = await ListApi({
84
+ const res = await ProjectListApi({
78
85
  ...pagination.value,
79
86
  ...queryForm.value
80
87
  })
@@ -92,7 +99,7 @@ const getTable = debounce(async () => {
92
99
  }, 300)
93
100
 
94
101
  // 新增和修改
95
- const handleEdit = (row?: ProjectItem) => {
102
+ const handleEdit = (row?: Project) => {
96
103
  editDialogRef.value.open()
97
104
  nextTick(() => {
98
105
  ruleFormRef.value?.resetFields()
@@ -108,7 +115,7 @@ const handleEdit = (row?: ProjectItem) => {
108
115
  })
109
116
  }
110
117
 
111
- const handleDelete = (row: ProjectItem) => {
118
+ const handleDelete = (row: Project) => {
112
119
  ElMessageBox.confirm('<p style="color: #f30">请注意,您尚未保存的数据将会丢失。</p>', '确定要删除吗?', {
113
120
  dangerouslyUseHTMLString: true,
114
121
  confirmButtonType: 'danger',
@@ -118,9 +125,9 @@ const handleDelete = (row: ProjectItem) => {
118
125
  .then(async () => {
119
126
  loading.value = true
120
127
  try {
121
- await DelApi(row.id)
128
+ await DeleteProjectApi(row.id)
122
129
  ElMessage({
123
- message: '',
130
+ message: '删除成功',
124
131
  grouping: true,
125
132
  showClose: true,
126
133
  type: 'success'
@@ -142,7 +149,11 @@ const submitForm = () => {
142
149
  if (valid) {
143
150
  loading.value = true
144
151
  try {
145
- await EditApi(ruleForm.value)
152
+ await EditProjectApi({
153
+ ...ruleForm.value,
154
+ // 将 managerId 的值从 Record<string, unknown> 转换为 number
155
+ managerId: extractFieldId(ruleForm.value.managerId, 'managerId') as number
156
+ })
146
157
  ElMessage({
147
158
  message: '数据已保存',
148
159
  grouping: true,
@@ -195,6 +206,7 @@ onActivated(() => {
195
206
  v-model="ruleForm.managerId"
196
207
  :formRef="ruleFormRef"
197
208
  validateFieldName="managerId"
209
+ :limit="1"
198
210
  :simpleValue="false"
199
211
  ></SelectManager>
200
212
  </el-form-item>
@@ -254,7 +266,7 @@ onActivated(() => {
254
266
  <span>项目管理</span>
255
267
  <div style="display: flex; justify-content: space-between; align-items: center">
256
268
  <JnImportAndExport
257
- :importTemplateApi="ImportTemplateApi"
269
+ :importTemplateApi="DownloadTemplateApi"
258
270
  importBtnName="导入项目"
259
271
  :importApi="ImportDataApi"
260
272
  exportBtnName="导出项目"
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { ListApi } from '@/api/demos/index'
2
+ import { ProjectListApi } from '@/api/demos/index'
3
3
  import { JnDatetime } from '@jnrs/vue-core/components'
4
4
  import CardTable from '@/components/common/CardTable.vue'
5
5
  import ImageView from '@/components/common/ImageView.vue'
@@ -8,7 +8,7 @@ import DictTag from '@/components/common/DictTag.vue'
8
8
  </script>
9
9
 
10
10
  <template>
11
- <CardTable :getTableDataApi="ListApi">
11
+ <CardTable :getTableDataApi="ProjectListApi">
12
12
  <template #header>项目列表</template>
13
13
  <template #table>
14
14
  <el-table-column prop="name" label="项目名称" min-width="200" sortable show-overflow-tooltip />
@@ -1,11 +1,10 @@
1
1
  <script setup lang="ts">
2
2
  import { ref } from 'vue'
3
3
  import { ElMessage } from 'element-plus'
4
- import { objectToFormData } from '@/utils/packages'
5
- import { LoginApi, UserInfoApi } from '@/api/system'
6
- import { NotFoundApi, NoAuthApi, DetailsApi } from '@/api/demos'
4
+ import { objectToFormData, downloadFile } from '@/utils'
5
+ import { LoginApi } from '@/api/system'
6
+ import { DataApiTest, FullDataApiTest, NotFoundApi, NoAuthApi, DetailsApi } from '@/api/demos'
7
7
  import { getFileUrl } from '@/utils/file'
8
- import { downloadFile } from '@/utils/packages'
9
8
 
10
9
  import ImageView from '@/components/common/ImageView.vue'
11
10
 
@@ -16,10 +15,33 @@ const loginParams = ref({
16
15
  password: '123456'
17
16
  })
18
17
 
19
- const handleInfoApi = async () => {
18
+ const handleDataApi = async () => {
20
19
  try {
21
- const res = await UserInfoApi()
20
+ const res = await DataApiTest('123')
22
21
  console.log(res)
22
+ console.log(res.name)
23
+ ElMessage({
24
+ message: '获取数据成功',
25
+ grouping: true,
26
+ showClose: true,
27
+ type: 'success'
28
+ })
29
+ } catch (error) {
30
+ console.log(error)
31
+ }
32
+ }
33
+
34
+ const handleFullDataApi = async () => {
35
+ try {
36
+ const res = await FullDataApiTest('123')
37
+ console.log(res)
38
+ console.log(res.data?.name)
39
+ ElMessage({
40
+ message: res.msg,
41
+ grouping: true,
42
+ showClose: true,
43
+ type: 'success'
44
+ })
23
45
  } catch (error) {
24
46
  console.log(error)
25
47
  }
@@ -93,7 +115,8 @@ const handleFileView = async () => {
93
115
  <template>
94
116
  <p>网络请求测试</p>
95
117
  <el-button-group>
96
- <el-button type="success" size="small" @click="handleInfoApi">获取用户数据</el-button>
118
+ <el-button type="success" size="small" @click="handleDataApi">获取data数据</el-button>
119
+ <el-button type="success" size="small" @click="handleFullDataApi">获取全量数据</el-button>
97
120
  <el-button type="primary" size="small" @click="handleNotFoundApi">接口返回404</el-button>
98
121
  <el-button type="primary" size="small" @click="handleNoAuth()">接口返回暂无权限</el-button>
99
122
  <el-button type="primary" size="small" @click="handleNoAuth(false)">接口返回暂无权限(不显示 Message)</el-button>
@@ -2,14 +2,14 @@
2
2
  import RequestPage from './RequestPage.vue'
3
3
  import { ref, onMounted } from 'vue'
4
4
  import { handleRouter } from '@jnrs/vue-core/router'
5
- import type { MenuItem } from '@jnrs/vue-core'
5
+ import type { IMenuItem } from '@jnrs/vue-core'
6
6
  import { hasPermission } from '@/utils/permissions'
7
7
  import { MenuApi } from '@/api/system'
8
8
  import { formatDateTime, formatWeekday } from '@jnrs/shared'
9
9
  import { isFloatGtZero } from '@jnrs/shared/validator'
10
10
  import { testI18n } from '@jnrs/shared/request'
11
11
 
12
- const routeOptions = ref<MenuItem[]>([])
12
+ const routeOptions = ref<IMenuItem[]>([])
13
13
  const currentRoute = ref('')
14
14
  const datePicker = ref(new Date())
15
15
  const datetime = ref(formatDateTime() + ' ' + formatWeekday())
@@ -1,8 +1,8 @@
1
1
  <script setup lang="ts">
2
2
  import { ref, computed, onActivated, onDeactivated } from 'vue'
3
3
  import { formatDateTime, formatWeekday, formatGreeting } from '@jnrs/shared'
4
- import { useAuthStore } from '@jnrs/vue-core/pinia'
5
4
  import { handleRouter } from '@jnrs/vue-core/router'
5
+ import { useAuthStore } from '@/stores'
6
6
  import ImageView from '@/components/common/ImageView.vue'
7
7
 
8
8
  const { userInfo } = useAuthStore()
@@ -2,7 +2,7 @@
2
2
  import type { FormInstance, FormRules } from 'element-plus'
3
3
  import { ref } from 'vue'
4
4
  import { RoleApi, LoginApi } from '@/api/system'
5
- import { useAuthStore } from '@jnrs/vue-core/pinia'
5
+ import { useAuthStore } from '@/stores'
6
6
  import { handleRouter, useRoute } from '@jnrs/vue-core/router'
7
7
  import { isWeakPwd } from '@jnrs/shared/validator'
8
8
  import { formatDateTime, formatWeekday } from '@jnrs/shared'
@@ -111,7 +111,7 @@ const submitForm = async () => {
111
111
  <el-input
112
112
  v-model="ruleForm.account"
113
113
  :placeholder="$t('login.formAccount')"
114
- prefix-icon="User"
114
+ prefix-icon="IUser"
115
115
  clearable
116
116
  />
117
117
  </el-form-item>
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import type { DictItem } from '@jnrs/shared'
2
+ import type { IDictItem } from '@/types'
3
3
  import { ElMessage } from 'element-plus'
4
4
  import { ref, onActivated } from 'vue'
5
5
  import { DictApi, DictDetailApi, DictChangeApi } from '@/api/system'
@@ -8,7 +8,7 @@ import { JnTable } from '@jnrs/vue-core/components'
8
8
 
9
9
  const PERMISSION_EDIT = ['dict:edit']
10
10
  const loading = ref(false)
11
- const tableData = ref<DictItem[]>()
11
+ const tableData = ref<IDictItem[]>()
12
12
  const predefineColors = ref([
13
13
  '#000000',
14
14
  '#999999',
@@ -36,7 +36,7 @@ const getList = () => {
36
36
  })
37
37
  }
38
38
 
39
- const handleExpandChange = (row: DictItem) => {
39
+ const handleExpandChange = (row: IDictItem) => {
40
40
  loading.value = true
41
41
  DictDetailApi(String(row.id))
42
42
  .then((res) => {
@@ -48,7 +48,7 @@ const handleExpandChange = (row: DictItem) => {
48
48
  }
49
49
 
50
50
  // 保存键值对
51
- const editKeyValue = (row: DictItem) => {
51
+ const editKeyValue = (row: IDictItem) => {
52
52
  if (!row.label) {
53
53
  ElMessage({
54
54
  type: 'warning',
@@ -1,8 +1,8 @@
1
1
  <script setup lang="ts">
2
2
  import type { FormInstance } from 'element-plus'
3
3
  import { ref, onMounted } from 'vue'
4
- import { useAuthStore } from '@jnrs/vue-core/pinia'
5
- import { getDictList } from '@/utils/packages'
4
+ import { useAuthStore } from '@/stores'
5
+ import { getDictList } from '@/utils'
6
6
  import { JnFileUpload } from '@jnrs/vue-core/components'
7
7
  import { AvatarChangeApi } from '@/api/system'
8
8
  import { objectMatchAssign } from '@jnrs/shared'
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import { reactive, ref } from 'vue'
3
3
  import { PasswordChangeApi } from '@/api/system'
4
- import { useAuthStore } from '@jnrs/vue-core/pinia'
4
+ import { useAuthStore } from '@/stores'
5
5
  import { handleRouter } from '@jnrs/vue-core/router'
6
6
  import { isWeakPwd } from '@jnrs/shared/validator'
7
7
  import type { FormInstance, FormItemRule } from 'element-plus'
@@ -1,6 +1,5 @@
1
1
  <script setup lang="ts">
2
- import type { MsgIdMessage, TypeDataMessage } from '@/types/webSocket'
3
- import { isMsgIdMessage, isTypeDataMessage } from '@/types/webSocket'
2
+ import { type IMsgIdMessage, type ITypeDataMessage, isMsgIdMessage, isTypeDataMessage } from '@/types'
4
3
  import { storeToRefs } from 'pinia'
5
4
  import { useWebSocket } from '@jnrs/vue-core/composables'
6
5
  import { useRouter } from '@jnrs/vue-core/router'
@@ -16,12 +15,12 @@ const { isLoading, wsStateInfo } = useWebSocket({
16
15
  connectionTimeoutDuration: 3_000, // 修改仅为测试
17
16
  onMessage: (rawMessage: unknown) => {
18
17
  if (isMsgIdMessage(rawMessage)) {
19
- const msg = rawMessage as MsgIdMessage
18
+ const msg = rawMessage as IMsgIdMessage
20
19
  if (msg.msgId && msg.d && typeof msg.d === 'object') {
21
20
  // console.log('接收 msgId 数据:', msg)
22
21
  }
23
22
  } else if (isTypeDataMessage(rawMessage)) {
24
- const msg = rawMessage as TypeDataMessage
23
+ const msg = rawMessage as ITypeDataMessage
25
24
  if (msg.type && msg.data && typeof msg.data === 'object') {
26
25
  // console.log('接收 type 数据:', msg)
27
26
  }
@@ -10,7 +10,7 @@ import vueDevTools from 'vite-plugin-vue-devtools'
10
10
 
11
11
  const path = (url: string) => fileURLToPath(new URL(url, import.meta.url))
12
12
  const config = loadEnv('development', './')
13
- const isMock = config.VITE_USE_MOCK === 'true'
13
+ const useMockServe = config.VITE_USE_MOCK === 'true'
14
14
 
15
15
  export default defineConfig({
16
16
  plugins: [
@@ -32,9 +32,9 @@ export default defineConfig({
32
32
  deleteOriginFile: false
33
33
  }),
34
34
  viteMockServe({
35
+ enable: useMockServe, // 是否开启 mock 服务器
35
36
  mockPath: 'viteMockServe', // mock 文件目录
36
37
  watchFiles: true, // mock 文件热更新
37
- enable: isMock, // 是否开启
38
38
  logger: false // 是否在终端显示请求日志
39
39
  })
40
40
  ],
@@ -8,7 +8,7 @@ const res_fail = {
8
8
  export default [
9
9
  // 404
10
10
  {
11
- url: '/mock/notFound',
11
+ url: '/api/mock/notFound',
12
12
  method: 'get',
13
13
  rawResponse: async (req: IncomingMessage, res: ServerResponse) => {
14
14
  res.statusCode = 404
@@ -18,7 +18,7 @@ export default [
18
18
  },
19
19
  // 权限不足
20
20
  {
21
- url: '/mock/auth/no',
21
+ url: '/api/mock/auth/no',
22
22
  method: 'post',
23
23
  response: () => {
24
24
  return {
@@ -29,7 +29,7 @@ export default [
29
29
  },
30
30
  // 操作失败
31
31
  {
32
- url: '/mock/auth/fail',
32
+ url: '/api/mock/auth/fail',
33
33
  method: 'post',
34
34
  response: () => {
35
35
  return res_fail
@@ -18,7 +18,7 @@ const MIME_TYPES: Record<string, string> = {
18
18
 
19
19
  export default [
20
20
  {
21
- url: /\/mock\/api\/files\/[\w.-]+/,
21
+ url: /\/api\/mock\/files\/[\w.-]+/,
22
22
  method: 'get',
23
23
  rawResponse: async (req: IncomingMessage, res: ServerResponse) => {
24
24
  if (!req.url) {
@@ -1,7 +1,6 @@
1
1
  import successMock from './success'
2
2
  import failMock from './fail'
3
3
  import fileMock from './file'
4
- import menuRes from '../public/system/menu.json'
5
4
  import loginRes_admin from './json/loginRes_admin.json'
6
5
  import loginRes_user from './json/loginRes_user.json'
7
6
  import dictRes from './json/dictRes.json'
@@ -14,17 +13,9 @@ export default [
14
13
  ...successMock,
15
14
  ...failMock,
16
15
  ...fileMock,
17
- // 获取菜单
18
- {
19
- url: '/mock/menu',
20
- method: 'get',
21
- response: () => {
22
- return menuRes
23
- }
24
- },
25
16
  // 登录
26
17
  {
27
- url: '/mock/api/auth/login',
18
+ url: '/api/mock/auth/login',
28
19
  method: 'post',
29
20
  response: ({ body }) => {
30
21
  if (body.account === 'admin') {
@@ -35,7 +26,7 @@ export default [
35
26
  },
36
27
  // 获取个人信息
37
28
  {
38
- url: '/mock/api/auth/user-info',
29
+ url: '/api/mock/auth/user-info',
39
30
  method: 'get',
40
31
  response: ({ headers }) => {
41
32
  if (headers.authorization.includes('admin')) {
@@ -46,7 +37,7 @@ export default [
46
37
  },
47
38
  // 获取字典
48
39
  {
49
- url: '/mock/api/dict-manager',
40
+ url: '/api/mock/dict-manager',
50
41
  method: 'get',
51
42
  response: () => {
52
43
  return dictRes
@@ -54,7 +45,7 @@ export default [
54
45
  },
55
46
  // 获取单个字典
56
47
  {
57
- url: /\/mock\/api\/dict-manager\/detail\/\d+/,
48
+ url: /\/api\/mock\/dict-manager\/detail\/\d+/,
58
49
  method: 'get',
59
50
  response: () => {
60
51
  return dictItemRes
@@ -62,7 +53,7 @@ export default [
62
53
  },
63
54
  // 获取角色
64
55
  {
65
- url: '/mock/api/role-manager',
56
+ url: '/api/mock/role-manager',
66
57
  method: 'get',
67
58
  response: () => {
68
59
  return roleRes
@@ -70,7 +61,7 @@ export default [
70
61
  },
71
62
  // 获取数据详情
72
63
  {
73
- url: '/mock/details',
64
+ url: '/api/mock/details',
74
65
  method: 'get',
75
66
  response: () => {
76
67
  return detailsRes
@@ -78,7 +69,7 @@ export default [
78
69
  },
79
70
  // 获取表格数据
80
71
  {
81
- url: '/mock/demos/table',
72
+ url: '/api/mock/demos/table',
82
73
  method: 'get',
83
74
  response: () => {
84
75
  return tableRes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "data": {
3
- "token": "***user***token***",
3
+ "token": "test_user_token",
4
4
  "id": 1,
5
5
  "name": "小王",
6
6
  "workNo": "000000",
@@ -11,6 +11,26 @@
11
11
  "permissions": ["menu:view"],
12
12
  "abilityCoefficient": 0.0,
13
13
  "dict": {
14
+ "projectType": [
15
+ {
16
+ "label": "瀑布型",
17
+ "value": 0,
18
+ "displayColor": "#65DC79",
19
+ "sequence": 1
20
+ },
21
+ {
22
+ "label": "敏捷型",
23
+ "value": 1,
24
+ "displayColor": "#409EFF",
25
+ "sequence": 2
26
+ },
27
+ {
28
+ "label": "混合型",
29
+ "value": 2,
30
+ "displayColor": "#F9DD4A",
31
+ "sequence": 3
32
+ }
33
+ ],
14
34
  "defectiveWorkHourStatus": [
15
35
  {
16
36
  "label": "等待",
@@ -6,7 +6,7 @@ const res_success = {
6
6
  export default [
7
7
  // 退出登录
8
8
  {
9
- url: '/mock/api/auth/logout',
9
+ url: '/api/mock/auth/logout',
10
10
  method: 'get',
11
11
  response: () => {
12
12
  return res_success
@@ -14,7 +14,7 @@ export default [
14
14
  },
15
15
  // 修改密码
16
16
  {
17
- url: '/mock/api/auth/change-password',
17
+ url: '/api/mock/auth/change-password',
18
18
  method: 'post',
19
19
  response: () => {
20
20
  return res_success
@@ -22,7 +22,7 @@ export default [
22
22
  },
23
23
  // 修改单个字典
24
24
  {
25
- url: '/mock/api/dict-manager/detail',
25
+ url: '/api/mock/dict-manager/detail',
26
26
  method: 'post',
27
27
  response: () => {
28
28
  return res_success
@@ -30,7 +30,7 @@ export default [
30
30
  },
31
31
  // 表单新增
32
32
  {
33
- url: '/mock/demos/save',
33
+ url: '/api/mock/demos/save',
34
34
  method: 'post',
35
35
  response: () => {
36
36
  return res_success
@@ -38,7 +38,7 @@ export default [
38
38
  },
39
39
  // 数据删除
40
40
  {
41
- url: /^\/mock\/demos\/delete\/[a-zA-Z0-9-]+$/,
41
+ url: /^\/api\/mock\/demos\/delete\/[a-zA-Z0-9-]+$/,
42
42
  method: 'delete',
43
43
  response: () => {
44
44
  return res_success
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-jnrs-vue",
3
- "version": "1.2.21",
3
+ "version": "1.2.23",
4
4
  "description": "巨能前端工程化开发,Vue 项目模板脚手架",
5
5
  "keywords": [
6
6
  "vue",
@@ -17,8 +17,7 @@
17
17
  },
18
18
  "type": "module",
19
19
  "bin": {
20
- "create-jnrs-vue": "./bin/create.mjs",
21
- "upgrade-jnrs-vue": "./bin/upgrade.mjs"
20
+ "create-jnrs-vue": "./bin/create.mjs"
22
21
  },
23
22
  "files": [
24
23
  "bin",