@uxda/appkit 1.2.59 → 1.2.61

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/appkit.css CHANGED
@@ -1190,6 +1190,7 @@ page {
1190
1190
  display: flex;
1191
1191
  align-items: center;
1192
1192
  margin-bottom: 20px;
1193
+ font-weight: 600;
1193
1194
  }
1194
1195
  .notice-popup-hd-icon {
1195
1196
  width: 20px;
@@ -1210,6 +1211,7 @@ page {
1210
1211
  .notice-popup-bd-link {
1211
1212
  color: #007fff;
1212
1213
  margin-top: 2px;
1214
+ font-weight: 600;
1213
1215
  }
1214
1216
  .notice-popup-ft {
1215
1217
  display: flex;
@@ -1227,6 +1229,7 @@ page {
1227
1229
  border-radius: 15px;
1228
1230
  }
1229
1231
  .notice-banner {
1232
+ background: #e6f2ff;
1230
1233
  height: 30px;
1231
1234
  margin-bottom: 8px;
1232
1235
  }
package/dist/index.js CHANGED
@@ -554,9 +554,9 @@ const request = (config) => {
554
554
  ...config
555
555
  };
556
556
  return new Promise((resolve, reject) => {
557
- const data = config.data && clientConfig.translates && clientConfig.translates[c.url] ? clientConfig.translates[c.url]?.(c.data || {}) : c.data;
557
+ const data = config.data && clientConfig.translates && clientConfig.translates[c.url] ? clientConfig.translates[c.url](c.data || {}) : c.data;
558
558
  console.log(`[][][][][]HTTP.${c.method}, ${c.baseUrl}${c.url}`, data);
559
- clientConfig.vendor?.request({
559
+ clientConfig.vendor && clientConfig.vendor.request({
560
560
  url: `${c.baseUrl}${c.url}`,
561
561
  data,
562
562
  headers: c.headers,
@@ -570,8 +570,8 @@ const request = (config) => {
570
570
  }
571
571
  }
572
572
  if (raw.data) {
573
- const response = clientConfig.transforms && clientConfig.transforms[c.url] ? clientConfig.transforms[c.url]?.(raw.data) : raw.data;
574
- const paging = config.data?.page ? clientConfig.paging?.transform(raw.data) : void 0;
573
+ const response = clientConfig.transforms && clientConfig.transforms[c.url] ? clientConfig.transforms[c.url](raw.data) : raw.data;
574
+ const paging = config.data.page ? clientConfig.paging.transform(raw.data) : void 0;
575
575
  resolve(
576
576
  paging ? {
577
577
  ...paging,
@@ -602,9 +602,7 @@ const post = (url, data) => {
602
602
  };
603
603
  const defaultClientConfig = {
604
604
  baseUrl: "/",
605
- interceptors: [
606
- (raw) => raw.status == 401
607
- ]
605
+ interceptors: [(raw) => raw.status == 401]
608
606
  };
609
607
  let clientConfig = {
610
608
  ...defaultClientConfig
@@ -3647,7 +3645,7 @@ var script$1 = /* @__PURE__ */ defineComponent({
3647
3645
  bannerStyle: { type: null, required: false, default: "" },
3648
3646
  fixed: { type: Boolean, required: false, default: false }
3649
3647
  },
3650
- emits: ["detail", "close", "view"],
3648
+ emits: ["detail", "close", "view", "popup"],
3651
3649
  setup(__props, { emit: __emit }) {
3652
3650
  const props = __props;
3653
3651
  const { toReadFun, noticeClick } = useNotice();
@@ -3665,6 +3663,12 @@ var script$1 = /* @__PURE__ */ defineComponent({
3665
3663
  onMounted(() => {
3666
3664
  queryNoticeMsg();
3667
3665
  });
3666
+ watch(
3667
+ () => popMessages.value,
3668
+ () => {
3669
+ emits("popup", !!popMessages.value.length);
3670
+ }
3671
+ );
3668
3672
  async function queryNoticeMsg() {
3669
3673
  const appkitOptions = useAppKitOptions();
3670
3674
  const $http = useHttp();
@@ -3675,8 +3679,10 @@ var script$1 = /* @__PURE__ */ defineComponent({
3675
3679
  appCode: props.app || appkitOptions.app(),
3676
3680
  tenantId: appkitOptions.tenant()
3677
3681
  }).then((result) => {
3678
- bannerMessages.value = (result || []).filter((item) => item.noticeType !== void 0);
3679
- popMessages.value = (result || []).filter((item) => item.isPop);
3682
+ if (!Array.isArray(result))
3683
+ return;
3684
+ bannerMessages.value = result.filter((item) => item.noticeType !== void 0);
3685
+ popMessages.value = result.filter((item) => item.isPop);
3680
3686
  startMessageCarousel();
3681
3687
  });
3682
3688
  }
@@ -3708,7 +3714,7 @@ var script$1 = /* @__PURE__ */ defineComponent({
3708
3714
  stopMessageCarousel();
3709
3715
  const $http = useHttp();
3710
3716
  $http.post("/cas/msg/setMsgStatus", {
3711
- device: "PC",
3717
+ device: "MINI",
3712
3718
  deviceType: 0,
3713
3719
  noticeStatus: 1,
3714
3720
  receiveId: item.id
@@ -3718,7 +3724,6 @@ var script$1 = /* @__PURE__ */ defineComponent({
3718
3724
  icon: "none"
3719
3725
  });
3720
3726
  bannerMessages.value.splice(index, 1);
3721
- startMessageCarousel();
3722
3727
  }).catch(() => {
3723
3728
  startMessageCarousel();
3724
3729
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxda/appkit",
3
- "version": "1.2.59",
3
+ "version": "1.2.61",
4
4
  "description": "小程序应用开发包",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.ts",
@@ -33,7 +33,7 @@
33
33
  </template>
34
34
 
35
35
  <script lang="ts" setup>
36
- import { computed, onMounted, ref } from 'vue'
36
+ import { computed, onMounted, ref, watch } from 'vue'
37
37
  import { useHttp } from '../api'
38
38
  import { useAppKitOptions } from '../../Appkit'
39
39
  import DdNoticeBar from '../../components/dd-notice-bar/index.vue'
@@ -74,6 +74,13 @@ onMounted(() => {
74
74
  queryNoticeMsg()
75
75
  })
76
76
 
77
+ watch(
78
+ () => popMessages.value,
79
+ () => {
80
+ emits('popup', !!popMessages.value.length)
81
+ }
82
+ )
83
+
77
84
  // 查询当前用户当前应用系统消息
78
85
  async function queryNoticeMsg() {
79
86
  const appkitOptions = useAppKitOptions()
@@ -88,8 +95,10 @@ async function queryNoticeMsg() {
88
95
  tenantId: appkitOptions.tenant(),
89
96
  })
90
97
  .then((result) => {
91
- bannerMessages.value = (result || []).filter((item: any) => item.noticeType !== undefined)
92
- popMessages.value = (result || []).filter((item: any) => item.isPop)
98
+ if (!Array.isArray(result)) return
99
+
100
+ bannerMessages.value = result.filter((item: any) => item.noticeType !== undefined)
101
+ popMessages.value = result.filter((item: any) => item.isPop)
93
102
 
94
103
  startMessageCarousel()
95
104
  })
@@ -141,7 +150,7 @@ const onClose = debounce((item: any, index: number) => {
141
150
  })
142
151
  bannerMessages.value.splice(index, 1)
143
152
 
144
- startMessageCarousel()
153
+ // startMessageCarousel()
145
154
 
146
155
  // if (item.isRead === 0) {
147
156
  // toReadFun([item.id])
@@ -173,11 +182,12 @@ const onTouchEnd = debounce(() => {
173
182
  }, 100)
174
183
 
175
184
  // 父组件事件
176
- const emits = defineEmits(['detail', 'close', 'view'])
185
+ const emits = defineEmits(['detail', 'close', 'view', 'popup'])
177
186
  </script>
178
187
 
179
188
  <style lang="scss">
180
189
  .notice-banner {
190
+ background: #e6f2ff;
181
191
  height: 30px;
182
192
  margin-bottom: 8px;
183
193
  &.fixed {
@@ -120,6 +120,7 @@ const emits = defineEmits(['close', 'view'])
120
120
  display: flex;
121
121
  align-items: center;
122
122
  margin-bottom: 20px;
123
+ font-weight: 600;
123
124
  &-icon {
124
125
  width: 20px;
125
126
  height: 20px;
@@ -140,6 +141,7 @@ const emits = defineEmits(['close', 'view'])
140
141
  &-link {
141
142
  color: #007fff;
142
143
  margin-top: 2px;
144
+ font-weight: 600;
143
145
  }
144
146
  }
145
147
  &-ft {
@@ -1,7 +1,14 @@
1
- import { HttpInstance, HttpClientConfig,
2
- HttpMethod, HttpRequestConfig,
3
- RequestData, ResponseData,
4
- ResponseRaw } from './types'
1
+ import {
2
+ HttpInstance,
3
+ HttpClientConfig,
4
+ HttpMethod,
5
+ HttpRequestConfig,
6
+ RequestData,
7
+ ResponseData,
8
+ ResponseRaw,
9
+ Paging,
10
+ HttpTranslate,
11
+ } from './types'
5
12
  /**
6
13
  * Useage:
7
14
  * const $http = createHttp({
@@ -23,56 +30,60 @@ const request: HttpInstance['request'] = <T>(config: HttpRequestConfig) => {
23
30
  ...config,
24
31
  }
25
32
  return new Promise<T>((resolve, reject) => {
26
- const data = config.data
27
- && clientConfig.translates
28
- && clientConfig.translates[c.url]
29
- ? clientConfig.translates[c.url]?.(c.data || {})
33
+ const data =
34
+ config.data && clientConfig.translates && clientConfig.translates[c.url]
35
+ ? (clientConfig.translates[c.url] as HttpTranslate)(c.data || {})
30
36
  : c.data
31
37
  console.log(`[][][][][]HTTP.${c.method}, ${c.baseUrl}${c.url}`, data)
32
- clientConfig.vendor?.request({
33
- url: `${c.baseUrl}${c.url}`,
34
- data,
35
- headers: c.headers,
36
- method: c.method,
37
- }).then((raw: ResponseRaw) => {
38
- // 按顺序执行拦截器
39
- for (const interc of c.interceptors || []) {
40
- const r = interc(raw)
41
- if (r) {
42
- // 某拦截器命中时
43
- // 按拦截结果 决定是否继续执行
44
- reject('===INTERCEPTED===' + raw.status)
45
- return false
46
- }
47
- }
48
- if (raw.data) {
49
- // 当用户配置含有 transforms 时, 使用用户提供的 transform
50
- // 先 endpoints transform
51
- // 再组装分页数据
52
- const response = clientConfig.transforms
53
- && clientConfig.transforms[c.url]
54
- ? clientConfig.transforms[c.url]?.(raw.data) as T
55
- : raw.data as T
56
- // 前端要求分页
57
- // endpoints transform 之前格式化分页数据
58
- // 并拼装回原 raw 数据
59
- const paging = config.data?.page
60
- ? clientConfig.paging?.transform(raw.data)
61
- : void 0
62
- resolve(
63
- paging
64
- ? {
65
- ...paging,
66
- data: response
67
- } as T
68
- : response
69
- )
70
- } else {
71
- resolve(raw as any)
72
- }
73
- }).catch((e: any) => {
74
- console.log('request.catch===', e)
75
- })
38
+
39
+ clientConfig.vendor &&
40
+ clientConfig.vendor
41
+ .request({
42
+ url: `${c.baseUrl}${c.url}`,
43
+ data,
44
+ headers: c.headers,
45
+ method: c.method,
46
+ })
47
+ .then((raw: ResponseRaw) => {
48
+ // 按顺序执行拦截器
49
+ for (const interc of c.interceptors || []) {
50
+ const r = interc(raw)
51
+ if (r) {
52
+ // 某拦截器命中时
53
+ // 按拦截结果 决定是否继续执行
54
+ reject('===INTERCEPTED===' + raw.status)
55
+ return false
56
+ }
57
+ }
58
+ if (raw.data) {
59
+ // 当用户配置含有 transforms 时, 使用用户提供的 transform
60
+ // endpoints transform
61
+ // 再组装分页数据
62
+ const response =
63
+ clientConfig.transforms && clientConfig.transforms[c.url]
64
+ ? ((clientConfig.transforms[c.url] as HttpTranslate)(raw.data) as T)
65
+ : (raw.data as T)
66
+ // 前端要求分页
67
+ // endpoints transform 之前格式化分页数据
68
+ // 并拼装回原 raw 数据
69
+ const paging = (config.data as RequestData).page
70
+ ? (clientConfig.paging as Paging).transform(raw.data)
71
+ : void 0
72
+ resolve(
73
+ paging
74
+ ? ({
75
+ ...paging,
76
+ data: response,
77
+ } as T)
78
+ : response
79
+ )
80
+ } else {
81
+ resolve(raw as any)
82
+ }
83
+ })
84
+ .catch((e: any) => {
85
+ console.log('request.catch===', e)
86
+ })
76
87
  })
77
88
  }
78
89
 
@@ -80,7 +91,7 @@ const get: HttpInstance['get'] = <T = ResponseData>(url: string, data?: RequestD
80
91
  return request<T>({
81
92
  url,
82
93
  data,
83
- method: HttpMethod.get
94
+ method: HttpMethod.get,
84
95
  })
85
96
  }
86
97
 
@@ -88,7 +99,7 @@ const post: HttpInstance['post'] = <T = ResponseData>(url: string, data: Request
88
99
  return request<T>({
89
100
  url,
90
101
  data,
91
- method: HttpMethod.post
102
+ method: HttpMethod.post,
92
103
  })
93
104
  }
94
105
 
@@ -98,13 +109,11 @@ const post: HttpInstance['post'] = <T = ResponseData>(url: string, data: Request
98
109
  */
99
110
  const defaultClientConfig: HttpClientConfig = {
100
111
  baseUrl: '/',
101
- interceptors: [
102
- (raw) => raw.status == 401
103
- ]
112
+ interceptors: [(raw) => raw.status == 401],
104
113
  }
105
114
 
106
115
  let clientConfig = {
107
- ...defaultClientConfig
116
+ ...defaultClientConfig,
108
117
  }
109
118
 
110
119
  /**
@@ -112,15 +121,15 @@ let clientConfig = {
112
121
  * @param config
113
122
  * @returns
114
123
  */
115
- export function createHttp (config: HttpClientConfig): HttpInstance {
124
+ export function createHttp(config: HttpClientConfig): HttpInstance {
116
125
  clientConfig = {
117
126
  ...defaultClientConfig,
118
- ...config
127
+ ...config,
119
128
  }
120
129
 
121
130
  return {
122
131
  request,
123
132
  get,
124
- post
133
+ post,
125
134
  }
126
135
  }