@scenetechnology/cj_element_table 0.0.1

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 (61) hide show
  1. package/.browserslistrc +4 -0
  2. package/.env.base +11 -0
  3. package/.env.dev +23 -0
  4. package/.env.gitee +23 -0
  5. package/.env.pro +24 -0
  6. package/.env.test +23 -0
  7. package/.eslintrc.js +18 -0
  8. package/README.md +24 -0
  9. package/babel.config.js +6 -0
  10. package/dist/cj_element_table.common.js +66535 -0
  11. package/dist/cj_element_table.common.js.map +1 -0
  12. package/dist/cj_element_table.css +1 -0
  13. package/dist/cj_element_table.umd.js +66554 -0
  14. package/dist/cj_element_table.umd.js.map +1 -0
  15. package/dist/cj_element_table.umd.min.js +61 -0
  16. package/dist/cj_element_table.umd.min.js.map +1 -0
  17. package/dist/demo.html +1 -0
  18. package/package.json +42 -0
  19. package/packages/components/SaveViewDialog.vue +109 -0
  20. package/packages/components/exportExcel.js +305 -0
  21. package/packages/components/exportTable.vue +361 -0
  22. package/packages/components/historyDialog.vue +100 -0
  23. package/packages/components/index.vue +1235 -0
  24. package/packages/components/tablesetting.vue +344 -0
  25. package/packages/components/tuo-drag.vue +197 -0
  26. package/packages/components/viewEdit.vue +239 -0
  27. package/packages/index.js +13 -0
  28. package/public/favicon.ico +0 -0
  29. package/public/index.html +17 -0
  30. package/src/App.vue +59 -0
  31. package/src/api/All.ts +104 -0
  32. package/src/assets/images/TablehederTool.png +0 -0
  33. package/src/assets/images/addIcon.png +0 -0
  34. package/src/assets/images/blue_lock.png +0 -0
  35. package/src/assets/images/changeIcon.png +0 -0
  36. package/src/assets/images/downImg.png +0 -0
  37. package/src/assets/images/kong_icon.png +0 -0
  38. package/src/assets/images/lbIcon.png +0 -0
  39. package/src/assets/images/lookImg.png +0 -0
  40. package/src/assets/images/model_title_icon.png +0 -0
  41. package/src/assets/images/pgIcon.png +0 -0
  42. package/src/assets/images/pzIcon.png +0 -0
  43. package/src/assets/images/tuozhui_icon.png +0 -0
  44. package/src/assets/images/view_save_icon.png +0 -0
  45. package/src/assets/images/view_setting_icon.png +0 -0
  46. package/src/assets/images/yaIcon.png +0 -0
  47. package/src/assets/logo.png +0 -0
  48. package/src/components/Dialog/index.ts +3 -0
  49. package/src/components/Dialog/src/Dialog.vue +72 -0
  50. package/src/components/HelloWorld.vue +60 -0
  51. package/src/components/Upload/index.vue +287 -0
  52. package/src/config/axios/config.ts +122 -0
  53. package/src/config/axios/index.ts +48 -0
  54. package/src/config/axios/service.ts +118 -0
  55. package/src/main.ts +13 -0
  56. package/src/router/index.ts +16 -0
  57. package/src/shims-vue.d.ts +6 -0
  58. package/tsconfig.json +41 -0
  59. package/types/global.d.ts +39 -0
  60. package/types/vite-env.d.ts +0 -0
  61. package/vue.config.js +24 -0
@@ -0,0 +1,287 @@
1
+ <template>
2
+ <el-upload
3
+ id="uploadID"
4
+ ref="upload"
5
+ v-model:file-list="file_list"
6
+ :action="uploadUrl"
7
+ :limit="props.limit"
8
+ :before-upload="beforeUpload"
9
+ :on-success="handleSuccess"
10
+ :on-error="handleError"
11
+ :show-file-list="props.showFileList"
12
+ :on-exceed="handleExceed"
13
+ :on-change="handleChange"
14
+ :on-preview="handlePreview"
15
+ :headers="headers"
16
+ :data="data"
17
+ :accept="fileTypes"
18
+ :name="name"
19
+ >
20
+ <el-button v-show="showButton" :id="targetId" :type="buttonType">{{ buttonText }}</el-button>
21
+ <el-switch
22
+ v-model="data.auth"
23
+ v-if="show_auth"
24
+ @click.stop
25
+ class="mb-2"
26
+ :active-value="1"
27
+ :inactive-value="2"
28
+ @click="authChange"
29
+ inline-prompt
30
+ active-text="可下载"
31
+ inactive-text="仅预览"
32
+ style="margin-left: 20px"
33
+ />
34
+ <div slot="tip" class="el-upload__tip" v-if="tipText">{{ tipText }}</div>
35
+ </el-upload>
36
+ <ElDialog v-model="viewShow" title="预览" :minHeight="600" width="970px" @clickClose="viewClose">
37
+ <iframe
38
+ id="iframe"
39
+ :src="viewUrl"
40
+ style="width: 100%; height: 500px; overflow-y: auto"
41
+ v-show="imgview == ''"
42
+ frameborder="0"
43
+ ></iframe>
44
+ <el-image
45
+ :src="imgview"
46
+ v-if="imgview"
47
+ :zoom-rate="1.2"
48
+ :max-scale="7"
49
+ :min-scale="0.2"
50
+ :initial-index="555"
51
+ :preview-teleported="true"
52
+ fit="cover"
53
+ :z-index="9999"
54
+ style="margin: 0 auto; display: block"
55
+ />
56
+ <template #footer>
57
+ <ElButton
58
+ v-if="data.auth == 1 || is_root || cruuent_id == create_by_id"
59
+ type="primary"
60
+ @click="download_file"
61
+ >下载</ElButton
62
+ >
63
+ <ElButton @click="viewShow = false">取消</ElButton>
64
+ </template>
65
+ </ElDialog>
66
+ </template>
67
+
68
+ <script setup lang="ts">
69
+ import { ref, onMounted, watch } from 'vue'
70
+ import { ElDialog, ElUpload, ElButton, ElMessage, ElSwitch, ElImage } from 'element-plus'
71
+ import { config } from '@/config/axios/config'
72
+ import { useRoute } from 'vue-router'
73
+ import { File_update_all } from '@/api/All.ts'
74
+ let route_path = ''
75
+ const route = useRoute()
76
+ if(route&&route.name)
77
+ {
78
+ route_path = route.name
79
+ }
80
+ const props = withDefaults(
81
+ defineProps<{
82
+ limit?: number // 限制上传文件数量
83
+ file_list_default: any[] // 文件列表回显
84
+ uploadUrl: string // 上传地址
85
+ showButton: boolean // 是否显示上传按钮
86
+ fileTypes?: string // 文件类型
87
+ tipText?: string // 提示语
88
+ name?: string
89
+ buttonText?: string // 按钮文字
90
+ verify?: number // 是否需要验证后缀 1是0否
91
+ auth?: number // 权限 1可下载 2仅预览
92
+ create_by_id?: string // 创建人id
93
+ show_auth?: boolean // 是否显示权限开关
94
+ showFileList?: boolean // 是否显示文件列表
95
+ targetId: string // 按钮id 方便在隐藏按钮时获取button触发上传
96
+ buttonType?: 'default' | 'primary' | 'success' | 'warning' | 'danger'
97
+ }>(),
98
+ {
99
+ uploadUrl:
100
+ process.env.NODE_ENV == 'development'
101
+ ? 'http://192.168.1.229:3005/simp/api/File/upload'
102
+ : '/simp/api/File/upload',
103
+ fileTypes: '',
104
+ showButton: true,
105
+ tipText: '',
106
+ show_auth: false,
107
+ showFileList: true,
108
+ buttonText: '点击上传',
109
+ verify: 0,
110
+ auth: 1,
111
+ buttonType: 'primary'
112
+ }
113
+ )
114
+ const is_root = ref(window.localStorage.getItem('is_root') == 'true')
115
+ // const cruuent_id = ref(JSON.parse(window.sessionStorage.getItem('user')).id)
116
+ const cruuent_id = ref('666')
117
+
118
+ const create_by_id = ref(
119
+ props.create_by_id ||
120
+ (props.file_list_default?.length ? props.file_list_default[0].create_by : undefined)
121
+ )
122
+ const current_file = ref('')
123
+ const file_list = ref(
124
+ (props.file_list_default || [])?.map((item) => {
125
+ if (item?.original_name) {
126
+ item.name = item.original_name
127
+ }
128
+ return item
129
+ })
130
+ )
131
+
132
+ const data = ref({
133
+ simp_token: sessionStorage.getItem('token') as string,
134
+ project_id: (sessionStorage.getItem('project_id') as string)
135
+ ? (sessionStorage.getItem('project_id') as string)
136
+ : (localStorage.getItem('inspect_project_id') as string),
137
+ tag: route_path,
138
+ verify: props.verify,
139
+ auth: props.file_list_default?.length ? +props.file_list_default[0].auth : props.auth
140
+ })
141
+ watch(
142
+ () => props.file_list_default,
143
+ (newVal) => {
144
+ file_list.value = (newVal || [])?.map((item) => {
145
+ if (item?.original_name) {
146
+ item.name = item.original_name
147
+ }
148
+ return item
149
+ })
150
+ data.value.auth = props.file_list_default?.length
151
+ ? +props.file_list_default[0].auth
152
+ : props.auth
153
+ }
154
+ )
155
+ const emit = defineEmits<{
156
+ (e: 'success', response: any, file: File): void
157
+ (e: 'change', file_list: any): void
158
+ (e: 'change_file_list', file_list: any): void
159
+ }>()
160
+
161
+ const upload = ref(null)
162
+
163
+ const headers = ref({
164
+ cjostoken: localStorage.getItem('simp_token') as string
165
+ })
166
+ const authChange = () => {
167
+ File_update_all({ ids: getids().join(), auth: data.value.auth }).then((res) => {
168
+ ElMessage.success(res.msg || '修改成功')
169
+ file_list.value.forEach((item: any) => {
170
+ item.auth = data.value.auth
171
+ })
172
+ console.log(file_list.value, 11)
173
+ if (file_list.value?.length > 0) {
174
+ emit('change_file_list', file_list.value)
175
+ }
176
+ })
177
+ }
178
+ const handleExceed = () => {
179
+ ElMessage.error('超过文件数量限制')
180
+ }
181
+
182
+ const beforeUpload = (file: File) => {
183
+ return true
184
+ }
185
+
186
+ const handleSuccess = (response: any, file: File, fileList: File[]) => {
187
+ let fieldResponse = []
188
+ ElMessage.info(response.msg || '上传成功')
189
+ fileList.forEach((item: any) => {
190
+ if (item.response) {
191
+ fieldResponse.push(item.response.data[0])
192
+ } else {
193
+ fieldResponse.push(item)
194
+ }
195
+ })
196
+ emit('success', fieldResponse)
197
+ }
198
+
199
+ const handleError = (error: any, file: File, fileList: File[]) => {
200
+ ElMessage.error('上传失败')
201
+ }
202
+ const handleChange = (uploadFile: any, uploadFiles: any) => {
203
+ console.log(uploadFile.response, 'uploadFile.response')
204
+ if (uploadFile.response) {
205
+ let ids = getids()
206
+ emit('change', ids)
207
+ }
208
+ }
209
+ const getids = () => {
210
+ let ids = []
211
+ file_list.value.forEach((item: any) => {
212
+ if (item.response) {
213
+ item.id = item.response.data[0]?.id
214
+ }
215
+ ids.push(item.id as never)
216
+ })
217
+ return ids
218
+ }
219
+ const download_file = () => {
220
+ let downsrc = `${config.simpUrl}${current_file.value}`
221
+ const a = document.createElement('a')
222
+ a.download = ''
223
+ a.href = downsrc
224
+ a.click()
225
+ }
226
+ const handlePreview = (file: File) => {
227
+ console.log(file, 'file')
228
+ if (file.src) {
229
+ current_file.value = file.src
230
+ } else {
231
+ current_file.value = file.response.data[0]?.src
232
+ }
233
+ console.log(current_file.value, 'current_file.value')
234
+ lookkkFile(current_file.value)
235
+ }
236
+ const encodeURLToBase64ThenURIComponent = (url) => {
237
+ // 先将 URL 进行 base64 编码
238
+ var base64Encoded = btoa(url)
239
+ // 再将 base64 编码后的结果进行 URL 编码
240
+ var encodedURL = encodeURIComponent(base64Encoded)
241
+ return encodedURL
242
+ }
243
+ const lookkkFile = (e) => {
244
+ let url = 'http://simp' + e
245
+ const isImage = /\.(jpg|jpeg|png|gif|bmp|webp)$/i.test(e)
246
+ console.log(isImage)
247
+ if (isImage) {
248
+ imgview.value = config.simpUrl + e
249
+ viewShow.value = true
250
+ } else {
251
+ imgview.value = '' // Handle non-image files with document viewer
252
+ var result = encodeURLToBase64ThenURIComponent(url)
253
+ viewShow.value = true
254
+ viewUrl.value = config.simpUrl + 'preview/onlinePreview?url=' + result
255
+ }
256
+ console.log(imgview.value, 111)
257
+ }
258
+ onMounted(() => {})
259
+ const viewShow = ref(false)
260
+ const viewUrl = ref('')
261
+ const imgview = ref('')
262
+
263
+ const viewClose = () => {
264
+ viewShow.value = false
265
+ viewUrl.value = ''
266
+ imgview.value = ''
267
+ }
268
+ </script>
269
+
270
+ <style lang="less" scoped >
271
+ .el-upload__tip {
272
+ margin-top: 10px;
273
+ color: #909399;
274
+ display: block;
275
+ }
276
+ #uploadID .el-upload {
277
+ width: 100%;
278
+ display: block !important;
279
+ }
280
+ :deep(.el-upload-list__item) {
281
+ height: 20px;
282
+ line-height: 20px;
283
+ }
284
+ :deep(.el-upload-list) {
285
+ margin: 0;
286
+ }
287
+ </style>
@@ -0,0 +1,122 @@
1
+ const config: {
2
+ base_url: {
3
+ base: string
4
+ dev: string
5
+ pro: string
6
+ test: string
7
+ }
8
+ result_code: number | string
9
+ default_headers: string,
10
+ request_timeout: number,
11
+ viewUrl: string,
12
+ uploadurl: string,
13
+ uploadImgUrl: string,
14
+ cjosUrl: string,
15
+ simpUrl: string,
16
+ upUse: string,
17
+ simpUseUrl: string,
18
+ flowUrl: string,
19
+ wflowUrl: string,
20
+ simptrainingspaceUrl: string,
21
+ simpSasUrl: string,
22
+ useProjectUrl: string,
23
+ simpelementsUrl: string,
24
+ } = {
25
+ /**
26
+ * api请求基础路径
27
+ */
28
+ base_url: {
29
+ // 开发环境接口前缀//hkemergency
30
+ base: 'http://192.168.1.229:3005/policy/api/',
31
+
32
+
33
+
34
+ // 打包开发环境接口前缀
35
+ dev: '',
36
+ // 打包生产环境接口前缀
37
+ pro: window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + '/policy/api/',
38
+
39
+ // 打包测试环境接口前缀
40
+ test: ''
41
+ },
42
+
43
+ /**
44
+ * 接口成功返回状态码
45
+ */
46
+ result_code: '200',
47
+
48
+ /**
49
+ * 接口请求超时时间
50
+ */
51
+ request_timeout: 60000,
52
+
53
+ /**
54
+ * 默认接口请求类型
55
+ * 可选值:application/x-www-form-urlencoded multipart/form-data
56
+ */
57
+
58
+ default_headers: 'application/json',
59
+ viewUrl: window.location.protocol + '//' + window.location.hostname + ':' + window.location.port,//查看图片路径
60
+ uploadurl: window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + '/admin/',//上传路径
61
+ cjosUrl: ``,
62
+ simpUseUrl :``,
63
+ simptrainingspaceUrl :``,
64
+ simpSasUrl :``,
65
+ useProjectUrl : ``,
66
+ simpelementsUrl : ``,
67
+ upUse:'',
68
+ simpUrl:'',
69
+ uploadImgUrl:'',
70
+ flowUrl:'',
71
+ wflowUrl:'',
72
+ }
73
+ if (process.env.NODE_ENV == 'development') {
74
+ config.uploadImgUrl = config.base_url.base
75
+
76
+ // config.viewUrl='http://192.168.1.114:8038/'
77
+ // if(window.location.port)
78
+ // {
79
+ // config.viewUrl=window.location.protocol+'//'+window.location.hostname+':'+window.location.port
80
+ // }else{
81
+ // config.viewUrl=window.location.protocol+'//'+window.location.hostname
82
+ // }
83
+ config.wflowUrl = "http://192.168.1.229:3005/wflow/admin/"
84
+ config.viewUrl = 'https://gps.gy.jxcc.com/car'
85
+ config.simpUrl = 'http://192.168.1.229:3005/'//'http://222.174.114.2:30090/'
86
+ config.upUse = "http://192.168.1.229:3005/simp/api/file/verify"
87
+ config.simpUseUrl = "http://192.168.1.229:3005/simp/index.php/api/"
88
+ config.flowUrl = 'http://192.168.1.93:88/simpflow/simpflow/index.html#/workspace/approval?zhiduguanli=true'
89
+
90
+ } else {
91
+ config.uploadImgUrl = config.base_url.pro
92
+ config.wflowUrl = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + "/wflow/admin/"
93
+ if (window.location.port) {
94
+ config.viewUrl = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port
95
+ } else {
96
+ config.viewUrl = window.location.protocol + '//' + window.location.hostname
97
+ }
98
+ config.flowUrl = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + '/simpflow/simpflow/index.html#/workspace/approval?zhiduguanli=true'
99
+ config.simpUrl = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + '/'
100
+ config.upUse = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + "/simp/api/file/verify"
101
+ if (localStorage.getItem('is_root') === 'true' || localStorage.getItem('is_root') === 'false') {
102
+ if (window.location.port) {
103
+ config.viewUrl = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + '/simp/'
104
+ config.base_url.pro = window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + '/policy/api/'
105
+ } else {
106
+ config.viewUrl = window.location.protocol + '//' + window.location.hostname + '/simp/'
107
+ config.base_url.pro = window.location.protocol + '//' + window.location.hostname + '/policy/api/'
108
+ }
109
+ config.uploadImgUrl = config.base_url.pro
110
+ }
111
+
112
+
113
+ }
114
+
115
+
116
+ config.cjosUrl = `${config.simpUrl}prod-api/v1/auth/`
117
+ config.simpUseUrl = `${config.simpUrl}simp/index.php/api/`
118
+ config.simptrainingspaceUrl = `${config.simpUrl}simptrainingspace/api/`
119
+ config.simpSasUrl = `${config.simpUrl}simp-sas/api/`
120
+ config.useProjectUrl = `${config.simpUrl}policy/api/`
121
+ config.simpelementsUrl = `${config.simpUrl}simpelements/api/`
122
+ export { config }
@@ -0,0 +1,48 @@
1
+ import { service } from './service'
2
+
3
+ import { config } from './config'
4
+
5
+ const { default_headers } = config
6
+
7
+ const request = (option: any) => {
8
+ const { url, method, params, data, headersType, responseType } = option;
9
+
10
+ // 判断是否需要附加特定的请求头
11
+ const shouldIncludeHeaders = url.includes('prod-api/v1/auth');
12
+
13
+ // 构建 headers 对象
14
+ const headers: any = {
15
+ 'Content-Type': headersType || default_headers,
16
+ };
17
+
18
+ // 如果 URL 包含 'prod-api/v1/auth',添加额外的 headers
19
+ if (shouldIncludeHeaders) {
20
+ headers['Currentproject'] = localStorage.getItem('current_project_id');
21
+ headers['Projects'] = localStorage.getItem('user_projects');
22
+ headers['Authorization'] = 'Bearer ' + sessionStorage.getItem('token');
23
+ }
24
+
25
+ // 返回请求
26
+ return service({
27
+ url: url,
28
+ method,
29
+ params,
30
+ data,
31
+ responseType: responseType,
32
+ headers: headers,
33
+ });
34
+ }
35
+ export default {
36
+ get: <T = any>(option: any) => {
37
+ return request({ method: 'get', ...option }) as unknown as T
38
+ },
39
+ post: <T = any>(option: any) => {
40
+ return request({ method: 'post', ...option }) as unknown as T
41
+ },
42
+ delete: <T = any>(option: any) => {
43
+ return request({ method: 'delete', ...option }) as unknown as T
44
+ },
45
+ put: <T = any>(option: any) => {
46
+ return request({ method: 'put', ...option }) as unknown as T
47
+ }
48
+ }
@@ -0,0 +1,118 @@
1
+ import axios, {
2
+ AxiosInstance,
3
+ InternalAxiosRequestConfig,
4
+ AxiosRequestHeaders,
5
+ AxiosResponse,
6
+ AxiosError
7
+ } from 'axios'
8
+
9
+ import qs from 'qs'
10
+
11
+ import { config } from './config'
12
+
13
+ import { ElMessage } from 'element-plus'
14
+
15
+ const { result_code, base_url } = config
16
+
17
+ // 要修改
18
+ // export const PATH_URL = base_url[import.meta.env.VITE_API_BASEPATH as keyof typeof base_url]
19
+ export const PATH_URL = '192.168.1.229:92'
20
+
21
+ // import { resetRouter } from '@/router'
22
+ // import { useRouter } from 'vue-router'
23
+
24
+ // 创建axios实例
25
+ const service: AxiosInstance = axios.create({
26
+ baseURL: PATH_URL, // api 的 base_url
27
+ timeout: config.request_timeout // 请求超时时间
28
+ })
29
+
30
+ // let token = null
31
+ let token: string | null = null
32
+ // request拦截器
33
+ service.interceptors.request.use(
34
+ (config: InternalAxiosRequestConfig) => {
35
+ if (sessionStorage.getItem('token')) {
36
+ token = sessionStorage.getItem('token')
37
+ }
38
+ config.headers['car-token'] = token;
39
+ config.headers['Authorization'] = 'Bearer ' + token;
40
+ if (localStorage.getItem('is_root') === 'true' || localStorage.getItem('is_root') === 'false') {
41
+ if (localStorage.getItem('is_root')) {
42
+ config.headers['cjostoken'] = localStorage.getItem('simp_token')
43
+ }
44
+ }
45
+ if (!config.url?.includes('prod-api/v1/auth')) {
46
+ config.headers['cjostoken'] = localStorage.getItem('simp_token')
47
+ }
48
+ if (config.method === 'post') {
49
+ config.data = config.data ?? {};
50
+ config.data.simp_token = sessionStorage.getItem('token') as string
51
+ config.data.project_id = sessionStorage.getItem('project_id') as string
52
+ ? sessionStorage.getItem('project_id') as string
53
+ : localStorage.getItem('inspect_project_id') as string
54
+
55
+ }
56
+ if (
57
+ config.method === 'post' && (config.headers as AxiosRequestHeaders)['Content-Type'] === 'application/x-www-form-urlencoded') {
58
+ config.data = qs.stringify(config.data)
59
+ }
60
+ // ;(config.headers as AxiosRequestHeaders)['Token'] = 'test test'
61
+ // get参数编码
62
+ if (config.method === 'get') {
63
+ config.params.simp_token = sessionStorage.getItem('token') as string
64
+ config.params.project_id = sessionStorage.getItem('project_id') as string
65
+ ? sessionStorage.getItem('project_id') as string
66
+ : localStorage.getItem('inspect_project_id') as string
67
+ // let url = config.url as string
68
+ // url += '?'
69
+ // const keys = Object.keys(config.params)
70
+ // for (const key of keys) {
71
+ // if (config.params[key] !== void 0 && config.params[key] !== null) {
72
+ // url += `${key}=${encodeURIComponent(config.params[key])}&`
73
+ // }
74
+ // }
75
+ // url = url.substring(0, url.length - 1)
76
+ // config.url = url
77
+ }
78
+ return config
79
+ },
80
+ (error: AxiosError) => {
81
+ // Do something with request error
82
+ console.log(error) // for debug
83
+ Promise.reject(error)
84
+ }
85
+ )
86
+
87
+ // response 拦截器
88
+ service.interceptors.response.use(
89
+ (response: AxiosResponse<any>) => {
90
+
91
+ if (response.config.responseType === 'blob') {
92
+ // 如果是文件流,直接过
93
+ return response
94
+ } else if (response.data.code == result_code) {
95
+ return response.data
96
+ } else if (response.data.body) {
97
+ return response.data
98
+ } else {
99
+ // ElMessage.error(response.data.msg)
100
+ return response
101
+ }
102
+ },
103
+ (error: AxiosError) => {
104
+ console.log('***', error) // for debug
105
+ try {
106
+ // if (error.response.status == 401) {//401退出登录
107
+ if (error.response && error.response.status === 401) {//401退出登录
108
+ console.log('退出登录');
109
+
110
+ // resetRouter() // 重置静态路由表
111
+ }
112
+ } catch (e) { }
113
+ // ElMessage.error(error.response.data.msg)
114
+ return Promise.reject(error)
115
+ }
116
+ )
117
+
118
+ export { service }
package/src/main.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { createApp } from 'vue'
2
+ import App from './App.vue'
3
+ import ElementPlus from 'element-plus'
4
+ import 'element-plus/dist/index.css'
5
+ import zhCn from 'element-plus/es/locale/lang/zh-cn'
6
+ // import router from './router'
7
+
8
+ const app = createApp(App)
9
+ app.use(ElementPlus, {
10
+ locale: zhCn,
11
+ })
12
+ // app.use(router)
13
+ app.mount('#app')
@@ -0,0 +1,16 @@
1
+ import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
2
+
3
+ const routes: Array<RouteRecordRaw> = [
4
+ {
5
+ path: '/',
6
+ name: 'Home',
7
+ component: () => import('../App.vue')
8
+ }
9
+ ]
10
+
11
+ const router = createRouter({
12
+ history: createWebHistory(),
13
+ routes
14
+ })
15
+
16
+ export default router
@@ -0,0 +1,6 @@
1
+ /* eslint-disable */
2
+ declare module '*.vue' {
3
+ import type { DefineComponent } from 'vue'
4
+ const component: DefineComponent<{}, {}, any>
5
+ export default component
6
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es5",
4
+ "module": "esnext",
5
+ "strict": true,
6
+ "jsx": "preserve",
7
+ "importHelpers": true,
8
+ "moduleResolution": "node",
9
+ "skipLibCheck": true,
10
+ "esModuleInterop": true,
11
+ "allowSyntheticDefaultImports": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "useDefineForClassFields": true,
14
+ "sourceMap": true,
15
+ "baseUrl": ".",
16
+ "types": [
17
+ "webpack-env"
18
+ ],
19
+ "paths": {
20
+ "@/*": [
21
+ "src/*"
22
+ ]
23
+ },
24
+ "lib": [
25
+ "esnext",
26
+ "dom",
27
+ "dom.iterable",
28
+ "scripthost"
29
+ ]
30
+ },
31
+ "include": [
32
+ "src/**/*.ts",
33
+ "src/**/*.tsx",
34
+ "src/**/*.vue",
35
+ "tests/**/*.ts",
36
+ "tests/**/*.tsx"
37
+ ],
38
+ "exclude": [
39
+ "node_modules"
40
+ ]
41
+ }
@@ -0,0 +1,39 @@
1
+ import type { CSSProperties } from 'vue'
2
+ declare global {
3
+ declare interface Fn<T = any> {
4
+ (...arg: T[]): T
5
+ }
6
+
7
+ declare type Nullable<T> = T | null
8
+
9
+ declare type ElRef<T extends HTMLElement = HTMLDivElement> = Nullable<T>
10
+
11
+ declare type Recordable<T = any, K = string> = Record<K extends null | undefined ? string : K, T>
12
+
13
+ declare type ComponentRef<T> = InstanceType<T>
14
+
15
+ declare type LocaleType = 'zh-CN' | 'en'
16
+
17
+ declare type AxiosHeaders =
18
+ | 'application/json'
19
+ | 'application/x-www-form-urlencoded'
20
+ | 'multipart/form-data'
21
+
22
+ declare type AxiosMethod = 'get' | 'post' | 'delete' | 'put'
23
+
24
+ declare type AxiosResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'
25
+
26
+ declare interface AxiosConfig {
27
+ params?: any
28
+ data?: any
29
+ url?: string
30
+ method?: AxiosMethod
31
+ headersType?: string
32
+ responseType?: AxiosResponseType
33
+ }
34
+
35
+ declare interface IResponse<T = any> {
36
+ code: string
37
+ data: T extends any ? T : T & any
38
+ }
39
+ }
File without changes