@skyfox2000/webui 1.3.12 → 1.3.14

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 (30) hide show
  1. package/lib/assets/modules/{file-upload-C2F7lPSM.js → file-upload-D8Ln4vVV.js} +1 -1
  2. package/lib/assets/modules/{index-BIrJNh7I.js → index-B2AK2Li9.js} +2 -2
  3. package/lib/assets/modules/{index-sCdzN6vg.js → index-BnDOMkVL.js} +1 -1
  4. package/lib/assets/modules/{index-Wb7_c6EZ.js → index-C8qhSdva.js} +2 -2
  5. package/lib/assets/modules/{menuTabs-Dk9meNAk.js → menuTabs-FUxE-a2D.js} +2 -2
  6. package/lib/assets/modules/{toolIcon-s2mFt6QR.js → toolIcon-bJ_WgHLU.js} +1 -1
  7. package/lib/assets/modules/{uploadList-B2L8NHoj.js → uploadList-BAX79qeV.js} +4 -4
  8. package/lib/assets/modules/{uploadList-C_T_ft8_.js → uploadList-BNkHE3fR.js} +653 -625
  9. package/lib/components/form/index.d.ts +2 -0
  10. package/lib/components/form/timePicker/index.vue.d.ts +6 -0
  11. package/lib/components/index.d.ts +1 -1
  12. package/lib/es/AceEditor/index.js +3 -3
  13. package/lib/es/BasicLayout/index.js +3 -3
  14. package/lib/es/Error403/index.js +1 -1
  15. package/lib/es/Error404/index.js +1 -1
  16. package/lib/es/ExcelForm/index.js +5 -5
  17. package/lib/es/UploadForm/index.js +4 -4
  18. package/lib/index.d.ts +1 -1
  19. package/lib/stores/hostInfo.d.ts +3 -1
  20. package/lib/webui.css +1 -1
  21. package/lib/webui.es.js +417 -396
  22. package/package.json +1 -1
  23. package/src/components/content/dialog/index.vue +6 -17
  24. package/src/components/content/table/index.vue +10 -28
  25. package/src/components/form/index.ts +3 -0
  26. package/src/components/form/timePicker/index.vue +24 -0
  27. package/src/components/index.ts +1 -0
  28. package/src/index.ts +1 -0
  29. package/src/stores/hostInfo.ts +72 -22
  30. package/src/utils/page.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyfox2000/webui",
3
- "version": "1.3.12",
3
+ "version": "1.3.14",
4
4
  "description": "后台前端通用组件定义",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -94,11 +94,8 @@ const doDialogClose = () => {
94
94
  };
95
95
  </script>
96
96
  <template>
97
- <Modal
98
- v-model:open="open"
99
- :wrapClassName="'modal mx-auto min-w-[430px] ' + (full ? 'full-modal w-full' : '')"
100
- :width="width"
101
- >
97
+ <Modal v-model:open="open" :wrapClassName="'modal mx-auto min-w-[430px] ' + (full ? 'full-modal w-full' : '')"
98
+ :width="width">
102
99
  <div class="overflow-y-auto w-full h-full">
103
100
  <slot></slot>
104
101
  </div>
@@ -107,20 +104,12 @@ const doDialogClose = () => {
107
104
  <Button @click="doDialogClose" v-if="cancelText !== ''">
108
105
  {{ cancelText ?? '取消' }}
109
106
  </Button>
110
- <Button
111
- @click="doDialogSaveAs"
112
- v-if="saveAsText !== '' && editorCtrl?.saveAsBtnVisible !== false"
113
- type="primary"
114
- :loading="editorCtrl?.isFormSaving.value"
115
- >
107
+ <Button @click="doDialogSaveAs" v-if="saveAsText !== '' && editorCtrl?.saveAsBtnVisible !== false"
108
+ type="primary" :loading="editorCtrl?.isFormSaving.value">
116
109
  {{ saveAsText ?? '另存为' }}
117
110
  </Button>
118
- <Button
119
- @click="doDialogSave"
120
- v-if="saveText !== '' && editorCtrl?.saveBtnVisible !== false"
121
- type="primary"
122
- :loading="editorCtrl?.isFormSaving.value"
123
- >
111
+ <Button @click="doDialogSave" v-if="saveText !== '' && editorCtrl?.saveBtnVisible !== false" type="primary"
112
+ :loading="editorCtrl?.isFormSaving.value">
124
113
  {{ saveText ?? '保存' }}
125
114
  </Button>
126
115
  </Space>
@@ -193,40 +193,22 @@ onMounted(async () => {
193
193
  });
194
194
  </script>
195
195
  <template>
196
- <Toolbar
197
- :grid-ctrl="gridCtrl"
198
- :editor-ctrl="gridCtrl.editor!"
199
- v-if="gridCtrl.buttons?.value.length || gridCtrl.tools?.length"
200
- />
201
- <Table
202
- v-if="visible"
203
- class="w-full"
204
- :row-key="props.primaryKey ?? gridCtrl.primaryKey ?? 'Id'"
205
- :data-source="dataList"
206
- :loading="gridCtrl.isGridLoading.value"
207
- :columns="columns"
208
- :pagination="pagination"
209
- :row-selection="rowSelection"
210
- :scroll="props.scroll || { x: 700, y: 1000 }"
211
- :size="gridCtrl.tableSize.value"
212
- bordered
213
- v-bind="attrs"
214
- >
196
+ <Toolbar :grid-ctrl="gridCtrl" :editor-ctrl="gridCtrl.editor!"
197
+ v-if="gridCtrl.buttons?.value.length || gridCtrl.tools?.length" />
198
+ <Table v-if="visible" class="w-full min-h-[480px]" :row-key="props.primaryKey ?? gridCtrl.primaryKey ?? 'Id'"
199
+ :data-source="dataList" :loading="gridCtrl.isGridLoading.value" :columns="columns" :pagination="pagination"
200
+ :row-selection="rowSelection" :scroll="props.scroll || { x: 700 }" :size="gridCtrl.tableSize.value" bordered
201
+ v-bind="attrs">
215
202
  <template #bodyCell="bodyCell">
216
203
  <slot name="bodyCell" :column="bodyCell?.column" :record="bodyCell?.record"></slot>
217
204
  <template v-if="gridCtrl && bodyCell?.column?.dataIndex === 'enabled'">
218
- <Switch
219
- v-model:checked="bodyCell.record.Enabled"
205
+ <Switch v-model:checked="bodyCell.record.Enabled"
220
206
  v-auth:disable="{ url: currentPath, role: ['Super', 'Admin'], permit: ':enabled' }"
221
- :disabled="statusDisabled ? statusDisabled(bodyCell.record) : false"
222
- :data="OPTIONS.EnableDisable"
223
- @click="gridStatusUpdate(gridCtrl, bodyCell.record)"
224
- :class="[
207
+ :disabled="statusDisabled ? statusDisabled(bodyCell.record) : false" :data="OPTIONS.EnableDisable"
208
+ @click="gridStatusUpdate(gridCtrl, bodyCell.record)" :class="[
225
209
  'w-[58px]',
226
210
  statusDisabled && statusDisabled(bodyCell.record) ? 'cursor-not-allowed disabled' : '',
227
- ]"
228
- :loading="bodyCell?.record.isLoading"
229
- />
211
+ ]" :loading="bodyCell?.record.isLoading" />
230
212
  </template>
231
213
  <template v-if="gridCtrl && bodyCell?.column?.dataIndex === 'operation'">
232
214
  <slot name="operate" :record="bodyCell?.record">
@@ -43,6 +43,9 @@ export { Switch };
43
43
  import Textarea from './textarea/index.vue';
44
44
  export { Textarea };
45
45
 
46
+ import TimePicker from './timePicker/index.vue';
47
+ export { TimePicker };
48
+
46
49
  import Transfer from './transfer/index.vue';
47
50
  export { Transfer };
48
51
  import TransferTable from './transfer/transferTable.vue';
@@ -0,0 +1,24 @@
1
+ <script setup lang="ts">
2
+ import { ref } from 'vue';
3
+ import { TimePicker } from 'ant-design-vue';
4
+ import locale from 'ant-design-vue/es/date-picker/locale/zh_CN';
5
+ import { formValidate, useInputFactory } from '@/index';
6
+ const props = defineProps<{
7
+ valueFormat?: string;
8
+ }>();
9
+
10
+ const { editorCtrl, labelText, errInfo } = useInputFactory();
11
+ const onBlur = () => {
12
+ if (errInfo?.value.errClass && editorCtrl) {
13
+ /// 重新开始验证
14
+ formValidate(editorCtrl);
15
+ }
16
+ };
17
+
18
+ const timeFormat = ref<string>(props.valueFormat ?? 'HH:mm');
19
+ </script>
20
+ <template>
21
+ <TimePicker class="w-full"
22
+ :class="[errInfo?.errClass === 'error' ? 'error !border-red-300 shadow-[0_0_3px_0px_#ff4d4f]' : '']"
23
+ :placeholder="'请选择' + labelText" :locale="locale" :valueFormat="timeFormat" @blur="onBlur" />
24
+ </template>
@@ -46,6 +46,7 @@ export {
46
46
  Select,
47
47
  Switch,
48
48
  Textarea,
49
+ TimePicker,
49
50
  Transfer,
50
51
  TransferTable,
51
52
  TreeSelect,
package/src/index.ts CHANGED
@@ -266,6 +266,7 @@ export {
266
266
  Select,
267
267
  Switch,
268
268
  Textarea,
269
+ TimePicker,
269
270
  Transfer,
270
271
  TransferTable,
271
272
  TreeSelect,
@@ -41,7 +41,20 @@ export const useHostInfo = defineStore('hostInfo', {
41
41
  }),
42
42
  actions: {
43
43
  /**
44
- * 加载站点信息,如加载失败,则使用本地缓存或默认参数
44
+ * 获取站点API地址
45
+ */
46
+ getSiteHostApi(): string {
47
+ // 首先检查环境变量中是否有VITE_SITEHOST_API
48
+ if (import.meta.env.VITE_SITEHOST_API) {
49
+ return import.meta.env.VITE_SITEHOST_API;
50
+ }
51
+
52
+ // 默认返回空字符串
53
+ return '';
54
+ },
55
+
56
+ /**
57
+ * 加载站点信息
45
58
  * @param hostApi 启动配置主机地址
46
59
  * @param hostKey 站点信息,默认为当前主域名
47
60
  * @param mainOpenApis 宿主机开放接口
@@ -51,19 +64,20 @@ export const useHostInfo = defineStore('hostInfo', {
51
64
  this._setHostInfo(mainOpenApis.getHostInfo());
52
65
  return;
53
66
  }
67
+
68
+ // 如果没有传入hostApi,则尝试从环境变量获取
69
+ let siteHostApi = (hostApi || this.getSiteHostApi()).trim();
70
+ if (!siteHostApi || siteHostApi === '/') {
71
+ siteHostApi = window.location.origin;
72
+ }
73
+ if (siteHostApi.endsWith('/')) {
74
+ siteHostApi = siteHostApi.slice(0, -1);
75
+ }
76
+
54
77
  return new Promise((resolve) => {
55
- if (!API_HOST['SITEHOST_API']) API_HOST['SITEHOST_API'] = hostApi;
78
+ if (!API_HOST['SITEHOST_API']) API_HOST['SITEHOST_API'] = siteHostApi;
56
79
 
57
80
  const host = hostKey || window.location.origin;
58
- // const cacheKey = `${CacheKeys.HOST_INFO}${host}`;
59
-
60
- // 尝试从缓存获取
61
- // const cachedHostInfo = Cache.getData<HostInfo>(cacheKey);
62
- // if (cachedHostInfo) {
63
- // this._setHostInfo(cachedHostInfo);
64
- // resolve();
65
- // return;
66
- // }
67
81
 
68
82
  // 从服务器获取
69
83
  httpPost<HostInfo>(HostUrlList.host, {
@@ -74,13 +88,8 @@ export const useHostInfo = defineStore('hostInfo', {
74
88
  if (result?.status === ResStatus.SUCCESS && result.data) {
75
89
  const hostInfo = result.data as HostInfo;
76
90
  this._setHostInfo(hostInfo);
77
-
78
- // 使用缓存代替持久化存储
79
- // 检查是否有 lastTime 字段
80
- // if (hostInfo.lastTime) {
81
- // Cache.setWithServerTime(cacheKey, hostInfo, hostInfo.lastTime);
82
- // }
83
- // 不存储,避免数据无法更新
91
+ } else {
92
+ this._setHostInfo(null);
84
93
  }
85
94
  resolve();
86
95
  });
@@ -88,18 +97,59 @@ export const useHostInfo = defineStore('hostInfo', {
88
97
  },
89
98
 
90
99
  /**
91
- * 设置主机信息(私有方法)
100
+ * 清除主机信息
101
+ */
102
+ clear(): void {
103
+ this.hostInfo = {
104
+ Host: '',
105
+ Title: '',
106
+ API_HOST: {},
107
+ SERVER_HOST: {},
108
+ MIDDLEWARES: {},
109
+ ExtraProps: {},
110
+ ExtraPropLines: [],
111
+ } as HostInfo;
112
+ },
113
+
114
+ /**
115
+ * 设置主机信息
92
116
  */
93
- _setHostInfo(hostInfo: HostInfo): void {
117
+ _setHostInfo(hostInfo: HostInfo | null): void {
94
118
  this.hostInfo = {
95
119
  ...this.hostInfo,
96
120
  ...hostInfo,
97
121
  };
122
+
123
+ // 更新全局API配置
98
124
  if (this.hostInfo.API_HOST) {
99
- for (const key in this.hostInfo.API_HOST) API_HOST[key] = this.hostInfo.API_HOST[key];
125
+ for (const key in this.hostInfo.API_HOST) {
126
+ let apiHost = this.hostInfo.API_HOST[key];
127
+ apiHost =
128
+ apiHost.startsWith('http://') || apiHost.startsWith('https://') || apiHost.startsWith('//')
129
+ ? apiHost
130
+ : window.location.origin + apiHost;
131
+ if (apiHost.endsWith('/')) {
132
+ apiHost = apiHost.slice(0, -1);
133
+ }
134
+ this.hostInfo.API_HOST[key] = apiHost;
135
+ API_HOST[key] = apiHost;
136
+ }
100
137
  }
138
+
139
+ // 更新全局服务器配置
101
140
  if (this.hostInfo.SERVER_HOST) {
102
- for (const key in this.hostInfo.SERVER_HOST) SERVER_HOST[key] = this.hostInfo.SERVER_HOST[key];
141
+ for (const key in this.hostInfo.SERVER_HOST) {
142
+ let serverHost = this.hostInfo.SERVER_HOST[key];
143
+ serverHost =
144
+ serverHost.startsWith('http://') || serverHost.startsWith('https://') || serverHost.startsWith('//')
145
+ ? serverHost
146
+ : window.location.origin + serverHost;
147
+ if (serverHost.endsWith('/')) {
148
+ serverHost = serverHost.slice(0, -1);
149
+ }
150
+ this.hostInfo.SERVER_HOST[key] = serverHost;
151
+ SERVER_HOST[key] = serverHost;
152
+ }
103
153
  }
104
154
  },
105
155
 
package/src/utils/page.ts CHANGED
@@ -90,7 +90,7 @@ const initUrls = (apiUrls: ApiUrls) => {
90
90
  if (!apiUrls.urls[urlKey]!.api) {
91
91
  apiUrls.urls[urlKey]!.api = apiUrls.api;
92
92
  }
93
- if (!apiUrls.urls[urlKey]!.authorize) {
93
+ if (apiUrls.urls[urlKey]!.authorize === undefined) {
94
94
  apiUrls.urls[urlKey]!.authorize = apiUrls.authorize;
95
95
  }
96
96
  }