ch3chi-commons-vue 1.2.0 → 1.8.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.
- package/package.json +2 -1
- package/src/api/ApiService.ts +869 -0
- package/src/auth/AuthorizationService.ts +138 -0
- package/src/auth/PermissionDescriptor.ts +99 -0
- package/src/auth/keys.ts +5 -0
- package/src/components/CAlert.vue +188 -0
- package/src/components/CAlertDefine.ts +20 -0
- package/src/components/CBSToast.vue +119 -0
- package/src/components/CGlobalSpinner.vue +84 -0
- package/src/components/CImage.vue +67 -0
- package/src/components/CRowCheckBox.vue +75 -0
- package/src/components/CRowTextInput.vue +27 -0
- package/src/components/CTable.vue +524 -0
- package/src/components/CTableDefine.ts +566 -0
- package/src/components/CTableTD.vue +28 -0
- package/src/components/HasPermission.vue +28 -0
- package/src/components/form/CChangePasswordFormField.vue +146 -0
- package/src/components/form/CCheckBoxFormField.vue +91 -0
- package/src/components/form/CCheckBoxPlatFormField.vue +94 -0
- package/src/components/form/CDateFormField.vue +149 -0
- package/src/components/form/CDateQueryField.vue +111 -0
- package/src/components/form/CDateRangeFormField.vue +138 -0
- package/src/components/form/CFilePickerFormField.vue +471 -0
- package/src/components/form/CRadioFormField.vue +62 -0
- package/src/components/form/CRadioPlatFormField.vue +67 -0
- package/src/components/form/CSelectFormField.vue +175 -0
- package/src/components/form/CTextAreaFormField.vue +84 -0
- package/src/components/form/CTextInputFormField.vue +99 -0
- package/src/components/form/CTinyMCEEditorFormField.vue +99 -0
- package/src/components/form/SCTextInputFormField.vue +129 -0
- package/src/composables/useCheckBoxFormField.ts +126 -0
- package/src/composables/useRadioFormField.ts +106 -0
- package/src/directive/CBootstrapDirective.ts +83 -0
- package/src/directive/CDateFormatterDirective.ts +37 -0
- package/src/directive/CFTurnstileDirective.ts +46 -0
- package/src/directive/CFormDirective.ts +57 -0
- package/src/directive/PermissionDirective.ts +102 -0
- package/src/env.d.ts +19 -0
- package/src/index.ts +83 -0
- package/src/model/BSFieldStyleConfig.ts +349 -0
- package/src/model/BaseDictionary.ts +86 -0
- package/src/model/BaseFormDataModel.ts +623 -0
- package/src/model/BaseListViewModel.ts +392 -0
- package/src/model/CBSModalViewModel.ts +91 -0
- package/src/model/CFileDataModel.ts +181 -0
- package/src/model/CImageViewModel.ts +34 -0
- package/src/model/CMenuItem.ts +199 -0
- package/src/model/EmailReceiverDataModel.ts +149 -0
- package/src/model/EmptyDataModel.ts +25 -0
- package/src/model/FormOptions.ts +112 -0
- package/src/model/LoginDataModel.ts +51 -0
- package/src/model/PasswordDataModel.ts +70 -0
- package/src/model/QueryParameter.ts +310 -0
- package/src/model/SessionUser.ts +110 -0
- package/src/model/ShowMessageDataModel.ts +69 -0
- package/src/model/TokenUser.ts +157 -0
- package/src/stores/FormDataStore.ts +73 -0
- package/src/stores/ViewStore.ts +701 -0
- package/src/stores/VueSessionStoreInstaller.ts +22 -0
- package/src/types/turnstile.d.ts +8 -0
- package/src/utils/CToolUtils.ts +133 -0
- package/dist/api/ApiService.d.ts +0 -233
- package/dist/auth/AuthorizationService.d.ts +0 -56
- package/dist/auth/PermissionDescriptor.d.ts +0 -37
- package/dist/components/CAlert.vue.d.ts +0 -17
- package/dist/components/CAlertDefine.d.ts +0 -14
- package/dist/components/CBSToast.vue.d.ts +0 -6
- package/dist/components/CGlobalSpinner.vue.d.ts +0 -13
- package/dist/components/CRowCheckBox.vue.d.ts +0 -14
- package/dist/components/CRowTextInput.vue.d.ts +0 -10
- package/dist/components/CTable.vue.d.ts +0 -24
- package/dist/components/CTableDefine.d.ts +0 -201
- package/dist/components/CTableTD.vue.d.ts +0 -7
- package/dist/components/form/CChangePasswordFormField.vue.d.ts +0 -14
- package/dist/components/form/CCheckBoxFormField.vue.d.ts +0 -30
- package/dist/components/form/CDateFormField.vue.d.ts +0 -17
- package/dist/components/form/CDateQueryField.vue.d.ts +0 -16
- package/dist/components/form/CDateRangeFormField.vue.d.ts +0 -17
- package/dist/components/form/CFilePickerFormField.vue.d.ts +0 -28
- package/dist/components/form/CRadioFormField.vue.d.ts +0 -30
- package/dist/components/form/CSelectFormField.vue.d.ts +0 -18
- package/dist/components/form/CTextAreaFormField.vue.d.ts +0 -16
- package/dist/components/form/CTextInputFormField.vue.d.ts +0 -22
- package/dist/directive/CBootstrapDirective.d.ts +0 -17
- package/dist/directive/CDateFormatterDirective.d.ts +0 -10
- package/dist/directive/CFTurnstileDirective.d.ts +0 -15
- package/dist/directive/CFormDirective.d.ts +0 -9
- package/dist/directive/PermissionDirective.d.ts +0 -15
- package/dist/index.cjs.js +0 -19103
- package/dist/index.d.ts +0 -45
- package/dist/index.es.js +0 -19086
- package/dist/model/BSFieldStyleConfig.d.ts +0 -121
- package/dist/model/BaseDictionary.d.ts +0 -34
- package/dist/model/BaseFormDataModel.d.ts +0 -199
- package/dist/model/BaseListViewModel.d.ts +0 -165
- package/dist/model/CBSModalViewModel.d.ts +0 -44
- package/dist/model/CFileDataModel.d.ts +0 -74
- package/dist/model/CImageViewModel.d.ts +0 -8
- package/dist/model/CMenuItem.d.ts +0 -86
- package/dist/model/EmailReceiverDataModel.d.ts +0 -57
- package/dist/model/EmptyDataModel.d.ts +0 -7
- package/dist/model/FormOptions.d.ts +0 -60
- package/dist/model/LoginDataModel.d.ts +0 -12
- package/dist/model/PasswordDataModel.d.ts +0 -15
- package/dist/model/QueryParameter.d.ts +0 -92
- package/dist/model/SessionUser.d.ts +0 -45
- package/dist/model/ShowMessageDataModel.d.ts +0 -44
- package/dist/model/TokenUser.d.ts +0 -50
- package/dist/stores/FormDataStore.d.ts +0 -31
- package/dist/stores/ViewStore.d.ts +0 -349
- package/dist/style.css +0 -223
- package/dist/utils/CToolUtils.d.ts +0 -53
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import HasPermission from '../components/HasPermission.vue';
|
|
3
|
+
import { SESSION_STORE_KEY } from '../auth/keys';
|
|
4
|
+
import { UserSessionActions } from './ViewStore';
|
|
5
|
+
import {createPermissionDirectives} from "../directive/PermissionDirective";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* VueSessionStoreInstaller 是一個 Vue 插件,用於全域註冊與提供使用者會話相關的功能。
|
|
9
|
+
* 它會將傳入的 sessionStore 實例注入到 Vue 應用中,並註冊一個權限檢查的組件和指令。
|
|
10
|
+
*/
|
|
11
|
+
export default {
|
|
12
|
+
install(app: App, options: { sessionStore: UserSessionActions }) {
|
|
13
|
+
// 1. 全域提供 sessionStore 實例
|
|
14
|
+
app.provide(SESSION_STORE_KEY, options.sessionStore);
|
|
15
|
+
|
|
16
|
+
// 2. 註冊全域組件
|
|
17
|
+
app.component('HasPermission', HasPermission);
|
|
18
|
+
|
|
19
|
+
// 3. (選配) 如果你也想保留指令版,也可以在這裡一起註冊
|
|
20
|
+
app.directive('permission', createPermissionDirectives(options));
|
|
21
|
+
}
|
|
22
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import _ from "lodash";
|
|
3
|
+
import * as yup from "yup";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 空函式
|
|
7
|
+
*/
|
|
8
|
+
export const voidFunction = () => {}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 延遲指定毫秒數
|
|
12
|
+
* @param ms 毫秒數
|
|
13
|
+
*/
|
|
14
|
+
export const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 從 params 中挑選有值的屬性並指派到 payload 中
|
|
18
|
+
* @param payload
|
|
19
|
+
* @param params
|
|
20
|
+
*/
|
|
21
|
+
export const pickAndAssign = (payload: Record<string, any>, params: Record<string, any>) =>
|
|
22
|
+
_.assign(payload, _.pickBy(params, _.identity));
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 寫入 Vue ref 物件的值
|
|
26
|
+
* @param refObj
|
|
27
|
+
* @param value
|
|
28
|
+
*/
|
|
29
|
+
export const writeVueRefValue = (refObj: any, value: any) => {
|
|
30
|
+
if(_.isNil(refObj) || !('value' in refObj)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
refObj.value = value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Lodash 擴充工具
|
|
38
|
+
*/
|
|
39
|
+
export const lodashExTools = {
|
|
40
|
+
// 安全取得物件屬性值
|
|
41
|
+
getVal: (obj: any, path: string | null | undefined, defaultValue?: any) => {
|
|
42
|
+
if(_.isNil(path) || _.isEmpty(path)) {
|
|
43
|
+
return defaultValue;
|
|
44
|
+
}
|
|
45
|
+
return _.get(obj, path, defaultValue);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 檢查是否有相同的檔案
|
|
51
|
+
* @param fileList 檔案列表
|
|
52
|
+
* @param file 要檢查的檔案
|
|
53
|
+
*/
|
|
54
|
+
export const checkHasSameFile = (fileList: File[], file: File) => {
|
|
55
|
+
return fileList.some(item => item.name === file.name
|
|
56
|
+
&& item.size === file.size
|
|
57
|
+
&& item.type === file.type
|
|
58
|
+
&& item.lastModified === file.lastModified);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 格式化物件中的所有日期屬性為指定格式的字串。
|
|
63
|
+
* @param obj
|
|
64
|
+
*/
|
|
65
|
+
export function formatDatesInObject(obj: any): any {
|
|
66
|
+
if (_.isNil(obj)) {
|
|
67
|
+
return obj;
|
|
68
|
+
}
|
|
69
|
+
// 如果是 FormData,直接回傳,不處理
|
|
70
|
+
if (obj instanceof FormData) {
|
|
71
|
+
return obj;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 如果是 Date 或 dayjs 物件,進行格式化
|
|
75
|
+
if (dayjs.isDayjs(obj) || obj instanceof Date) {
|
|
76
|
+
// 格式化日期成字串
|
|
77
|
+
// console.log(`format date: ${obj} ISO string => ${dayjs(obj).toISOString()}`);
|
|
78
|
+
// console.log(`format date: ${obj} with timezone => ${dayjs(obj).tz('Asia/Taipei').toISOString()}`);
|
|
79
|
+
// console.log(`format date: ${obj} pattern => ${dayjs(obj).format('YYYY-MM-DDTHH:mm:ssZ')}`);
|
|
80
|
+
// return dayjs(obj).toISOString();
|
|
81
|
+
return dayjs(obj).format('YYYY-MM-DDTHH:mm:ss');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// 如果是陣列,遞迴處理每個元素
|
|
85
|
+
if (_.isArray(obj)) {
|
|
86
|
+
return obj.map(item => formatDatesInObject(item));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 如果是物件,遞迴處理每個屬性值
|
|
90
|
+
if (_.isObject(obj)) {
|
|
91
|
+
return _.mapValues(obj, value => formatDatesInObject(value));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// 其他類型直接回傳
|
|
95
|
+
return obj;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 建立一個日期區間驗證器,用於 yup 的 test 方法中。
|
|
100
|
+
* @param startDateKey
|
|
101
|
+
* @param endDateKey
|
|
102
|
+
* @param startDateMessage
|
|
103
|
+
* @param endDateMessage
|
|
104
|
+
*/
|
|
105
|
+
export function makeDateRangeValidator({
|
|
106
|
+
startDateKey, endDateKey, startDateMessage, endDateMessage
|
|
107
|
+
}: {startDateKey: string, endDateKey: string, startDateMessage: string, endDateMessage: string}) {
|
|
108
|
+
return function (this: yup.TestContext, formValues: Record<string, any>) {
|
|
109
|
+
const startsAt = formValues[startDateKey];
|
|
110
|
+
const endsAt = formValues[endDateKey];
|
|
111
|
+
if (startsAt == null && endsAt == null) {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
const errors: yup.ValidationError[] = [];
|
|
115
|
+
|
|
116
|
+
if (startsAt && endsAt && (startsAt > endsAt)) {
|
|
117
|
+
errors.push(this.createError({
|
|
118
|
+
path: startDateKey,
|
|
119
|
+
message: startDateMessage
|
|
120
|
+
}));
|
|
121
|
+
errors.push(this.createError({
|
|
122
|
+
path: endDateKey,
|
|
123
|
+
message: endDateMessage
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
if (errors.length > 0) {
|
|
127
|
+
// 注意:這裡我們回傳一個新的 ValidationError 實例,它包裹了所有收集到的錯誤
|
|
128
|
+
return new yup.ValidationError(errors);
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
package/dist/api/ApiService.d.ts
DELETED
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
import { AxiosProgressEvent, AxiosRequestConfig, AxiosResponse, RawAxiosResponseHeaders } from 'axios';
|
|
2
|
-
import { AccessToken } from '../model/TokenUser';
|
|
3
|
-
/**
|
|
4
|
-
* ApiEndpoint 定義 API 端點的結構
|
|
5
|
-
*/
|
|
6
|
-
export interface ApiEndpoint {
|
|
7
|
-
path: string;
|
|
8
|
-
method: string;
|
|
9
|
-
isAuthenticated?: boolean;
|
|
10
|
-
security?: string[];
|
|
11
|
-
withCredentials?: boolean;
|
|
12
|
-
isRefreshTokenEndpoint?: boolean;
|
|
13
|
-
errorMessageMap?: Record<number, string>;
|
|
14
|
-
noSpinner?: boolean;
|
|
15
|
-
headers?: Record<string, string>;
|
|
16
|
-
metaData?: Record<string, any>;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* CreateEndpointOptions 定義建立 ApiEndpoint 時的選項
|
|
20
|
-
* 通常用於設定預設值
|
|
21
|
-
*/
|
|
22
|
-
export interface CreateEndpointOptions {
|
|
23
|
-
isAuthenticated?: boolean;
|
|
24
|
-
security?: string[];
|
|
25
|
-
headers?: Record<string, string>;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* ApiRequest 定義 API 請求的結構
|
|
29
|
-
*/
|
|
30
|
-
export declare class ApiRequest {
|
|
31
|
-
endpointKey: string;
|
|
32
|
-
headers?: Record<string, string>;
|
|
33
|
-
pathParam?: Record<string, any>;
|
|
34
|
-
queryParam?: Record<string, any>;
|
|
35
|
-
postBody?: Record<string, any> | FormData;
|
|
36
|
-
isDownloadMode?: boolean;
|
|
37
|
-
downloadFileName?: string;
|
|
38
|
-
onUploadProgress?: (progressEvent: AxiosProgressEvent) => void;
|
|
39
|
-
axiosConfig?: AxiosRequestConfig;
|
|
40
|
-
noSpinner?: boolean;
|
|
41
|
-
constructor(data: ApiRequest);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* ApiResponse 定義 API 回應的結構
|
|
45
|
-
*/
|
|
46
|
-
export declare class ApiResponse {
|
|
47
|
-
httpStatus: number;
|
|
48
|
-
status?: number;
|
|
49
|
-
message?: string;
|
|
50
|
-
data?: any;
|
|
51
|
-
nativeError?: any;
|
|
52
|
-
paging?: Record<string, any>;
|
|
53
|
-
blobData?: Blob;
|
|
54
|
-
headers?: RawAxiosResponseHeaders;
|
|
55
|
-
details?: any;
|
|
56
|
-
axiosResponse?: AxiosResponse;
|
|
57
|
-
constructor(data?: Partial<ApiResponse>);
|
|
58
|
-
isOk(): boolean;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* ApiRejectError 定義 API 呼叫失敗時的自訂錯誤
|
|
62
|
-
* 此物件給 ApiService.call 呼叫後,並且回傳 Promise.reject() 使用
|
|
63
|
-
*/
|
|
64
|
-
export declare class ApiRejectError extends Error {
|
|
65
|
-
response: ApiResponse;
|
|
66
|
-
type?: string;
|
|
67
|
-
constructor(response: ApiResponse);
|
|
68
|
-
notFound(): this;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* ApiService 提供呼叫後端 API 的功能
|
|
72
|
-
*/
|
|
73
|
-
export declare class ApiService {
|
|
74
|
-
private static _options;
|
|
75
|
-
private static _apiEndpoints;
|
|
76
|
-
private static _customHeaders;
|
|
77
|
-
private static _customHeaderProvider?;
|
|
78
|
-
private static _customErrorMessageMap;
|
|
79
|
-
private static _accessToken?;
|
|
80
|
-
private static _accessTokenProvider?;
|
|
81
|
-
private static _refreshTokenPromise?;
|
|
82
|
-
private static _axiosInstance?;
|
|
83
|
-
private static _failedRequestQueue;
|
|
84
|
-
private static _isRefreshing;
|
|
85
|
-
static set accessToken(token: AccessToken);
|
|
86
|
-
static set accessTokenProvider(provider: () => Promise<AccessToken | undefined>);
|
|
87
|
-
static getAccessToken(): Promise<AccessToken | undefined>;
|
|
88
|
-
/**
|
|
89
|
-
* 靜態方法,新增全域自訂標頭
|
|
90
|
-
* @param key
|
|
91
|
-
* @param value
|
|
92
|
-
*/
|
|
93
|
-
static addHeader(key: string, value: string): void;
|
|
94
|
-
/**
|
|
95
|
-
* 靜態方法,移除全域自訂標頭
|
|
96
|
-
* @param key
|
|
97
|
-
*/
|
|
98
|
-
static removeHeader(key: string): void;
|
|
99
|
-
/**
|
|
100
|
-
* 靜態方法,設定自訂標頭提供者
|
|
101
|
-
* @param provider
|
|
102
|
-
*/
|
|
103
|
-
static customHeaderProvider(provider: (endpoint: ApiEndpoint, header: Record<string, any>) => Promise<Record<string, string>>): void;
|
|
104
|
-
constructor();
|
|
105
|
-
/**
|
|
106
|
-
* 靜態方法,配置 ApiService
|
|
107
|
-
* 為方便管理,建議在專案啟動時呼叫此方法註冊所有端點
|
|
108
|
-
* 可以配置
|
|
109
|
-
* - debugMode: 是否啟用除錯模式
|
|
110
|
-
* - baseUrl: API 伺服器的基礎 URL
|
|
111
|
-
* - contextPath: API 的上下文路徑
|
|
112
|
-
* - proxyEnable: 是否啟用代理
|
|
113
|
-
* - proxyBaseUrl: 代理的基礎 URL
|
|
114
|
-
* - showSpinnerFunc: 顯示全域載入動畫的函式
|
|
115
|
-
* - hideSpinnerFunc: 隱藏全域載入動畫的函式
|
|
116
|
-
* - showErrorToastFunc: 顯示全域錯誤提示的函式
|
|
117
|
-
* - endpoints: 預設註冊的 API 端點
|
|
118
|
-
* - customHeaders: 全域自訂標頭
|
|
119
|
-
* - customErrorMessageMap: 全域自訂錯誤訊息對應
|
|
120
|
-
* - createEndpointOptions: 建立端點時的預設選項
|
|
121
|
-
* - refreshTokenFunc: 刷新存取權杖的函式
|
|
122
|
-
* - onAuthenticateFailed: 認證失敗時的回調函式
|
|
123
|
-
* @param config
|
|
124
|
-
*/
|
|
125
|
-
static configure(config: {
|
|
126
|
-
debugMode?: boolean;
|
|
127
|
-
baseUrl?: string;
|
|
128
|
-
contextPath?: string;
|
|
129
|
-
proxyEnable?: boolean;
|
|
130
|
-
proxyBaseUrl?: string;
|
|
131
|
-
showSpinnerFunc?: () => void;
|
|
132
|
-
hideSpinnerFunc?: () => void;
|
|
133
|
-
showErrorToastFunc?: (param: {
|
|
134
|
-
title?: string;
|
|
135
|
-
content?: string;
|
|
136
|
-
}) => void;
|
|
137
|
-
endpoints: Record<string, ApiEndpoint>;
|
|
138
|
-
customHeaders?: Record<string, string>;
|
|
139
|
-
customHeaderProvider?: (endpoint: ApiEndpoint, header: Record<string, any>) => Promise<Record<string, string>>;
|
|
140
|
-
customErrorMessageMap?: Record<number, string>;
|
|
141
|
-
createEndpointOptions?: CreateEndpointOptions;
|
|
142
|
-
refreshTokenFunc?: () => Promise<AccessToken>;
|
|
143
|
-
onAuthenticateFailed?: (param: {
|
|
144
|
-
apiEndpoint: ApiEndpoint;
|
|
145
|
-
apiRequest: ApiRequest;
|
|
146
|
-
}) => void;
|
|
147
|
-
}): void;
|
|
148
|
-
/**
|
|
149
|
-
* 靜態方法,新增單一 API 端點
|
|
150
|
-
* @param key
|
|
151
|
-
* @param endpoint
|
|
152
|
-
*/
|
|
153
|
-
static addEndpoints(key: string, endpoint: ApiEndpoint): void;
|
|
154
|
-
/**
|
|
155
|
-
* 靜態方法,方便直接呼叫 API
|
|
156
|
-
* @param request
|
|
157
|
-
*/
|
|
158
|
-
static call(request: ApiRequest): Promise<ApiResponse>;
|
|
159
|
-
/**
|
|
160
|
-
* 靜態方法,方便直接下載檔案
|
|
161
|
-
* @param request
|
|
162
|
-
*/
|
|
163
|
-
static download(request: ApiRequest): Promise<void>;
|
|
164
|
-
/**
|
|
165
|
-
* 取得指定的 API 端點資訊
|
|
166
|
-
* @param endpointKey
|
|
167
|
-
*/
|
|
168
|
-
getEndpoint(endpointKey: string): ApiEndpoint | undefined;
|
|
169
|
-
/**
|
|
170
|
-
* 取得完整的 API URL
|
|
171
|
-
* @param endpointKey
|
|
172
|
-
*/
|
|
173
|
-
getFullUrl(endpointKey: string): string | undefined;
|
|
174
|
-
/**
|
|
175
|
-
* 組合完整的 API URL
|
|
176
|
-
* @param endpoint
|
|
177
|
-
*/
|
|
178
|
-
makeBaseUrl(endpoint: ApiEndpoint): string | undefined;
|
|
179
|
-
/**
|
|
180
|
-
* 呼叫 API
|
|
181
|
-
* @param request
|
|
182
|
-
*/
|
|
183
|
-
callApi(request: ApiRequest): Promise<ApiResponse>;
|
|
184
|
-
/**
|
|
185
|
-
* 下載檔案
|
|
186
|
-
* @param request
|
|
187
|
-
*/
|
|
188
|
-
downloadFile(request: ApiRequest): Promise<void>;
|
|
189
|
-
/**
|
|
190
|
-
* 決定下載檔案名稱
|
|
191
|
-
* @param request
|
|
192
|
-
* @param response
|
|
193
|
-
*/
|
|
194
|
-
resolveExportFileName(request: ApiRequest, response: ApiResponse): string;
|
|
195
|
-
/**
|
|
196
|
-
* 解碼 RFC 2047 編碼的字串
|
|
197
|
-
* @param str RFC 2047 編碼的字串
|
|
198
|
-
*/
|
|
199
|
-
decodeRfc2047(str: string): string;
|
|
200
|
-
/**
|
|
201
|
-
* 檢查是否啟用 Bearer Token 認證
|
|
202
|
-
*/
|
|
203
|
-
private static hasBearerAuth;
|
|
204
|
-
/**
|
|
205
|
-
* 設定 axios 攔截器
|
|
206
|
-
*/
|
|
207
|
-
private static setupAxiosInterceptors;
|
|
208
|
-
/**
|
|
209
|
-
* 設定認證相關的 interceptors
|
|
210
|
-
*/
|
|
211
|
-
private static setupAuthInterceptorsOnBearerAuth;
|
|
212
|
-
/**
|
|
213
|
-
* 刷新 access token
|
|
214
|
-
*/
|
|
215
|
-
static refreshToken(): Promise<AccessToken>;
|
|
216
|
-
/**
|
|
217
|
-
* 檢查並刷新 token(如果需要)
|
|
218
|
-
*/
|
|
219
|
-
private static refreshTokenIfNeeded;
|
|
220
|
-
/**
|
|
221
|
-
* 處理佇列中的失敗請求
|
|
222
|
-
*/
|
|
223
|
-
private static processFailedRequestQueue;
|
|
224
|
-
/**
|
|
225
|
-
* 處理認證失敗
|
|
226
|
-
*/
|
|
227
|
-
private static handleAuthenticationFailed;
|
|
228
|
-
/**
|
|
229
|
-
* 取得 axios 實例
|
|
230
|
-
*/
|
|
231
|
-
private static getAxiosInstance;
|
|
232
|
-
}
|
|
233
|
-
export declare const __ApiServiceDefine__: ApiEndpoint;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { CMenuItem, MenuItem } from '../model/CMenuItem';
|
|
2
|
-
/**
|
|
3
|
-
* 提供選單項目的參數介面
|
|
4
|
-
*/
|
|
5
|
-
type ProvideMenuByPermissionParams = {
|
|
6
|
-
roleCode: string;
|
|
7
|
-
permissions: string[];
|
|
8
|
-
picker?: (roleCode: string) => MenuItem[];
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* AuthorizationService 類別負責處理權限相關的邏輯
|
|
12
|
-
*/
|
|
13
|
-
export declare class AuthorizationService {
|
|
14
|
-
/**
|
|
15
|
-
* 角色權限映射表
|
|
16
|
-
* 定義角色對應多個權限項目
|
|
17
|
-
* @private
|
|
18
|
-
*/
|
|
19
|
-
private static _rolePermissionMap;
|
|
20
|
-
/**
|
|
21
|
-
* 選單定義映射表
|
|
22
|
-
* 定義不同角色對應的選單結構
|
|
23
|
-
* @private
|
|
24
|
-
*/
|
|
25
|
-
private static _menuDefineMap;
|
|
26
|
-
/**
|
|
27
|
-
* 設定角色權限映射
|
|
28
|
-
* @param map 角色權限映射物件
|
|
29
|
-
*/
|
|
30
|
-
static set rolePermissionMap(map: Record<string, string[]>);
|
|
31
|
-
/**
|
|
32
|
-
* 設定選單定義映射
|
|
33
|
-
* @param map
|
|
34
|
-
*/
|
|
35
|
-
static set menuDefineMap(map: Record<string, MenuItem[]>);
|
|
36
|
-
/**
|
|
37
|
-
* 配置角色與權限關係,以及選單定義映射
|
|
38
|
-
* @param config 配置物件
|
|
39
|
-
*/
|
|
40
|
-
static configure(config: {
|
|
41
|
-
rolePermissionMap?: Record<string, string[]>;
|
|
42
|
-
menuDefineMap: Record<string, MenuItem[]>;
|
|
43
|
-
}): void;
|
|
44
|
-
/**
|
|
45
|
-
* 檢查角色列表是否包含所需的權限
|
|
46
|
-
* @param roleCodes
|
|
47
|
-
* @param requiredPermission
|
|
48
|
-
*/
|
|
49
|
-
static hasPermissionByRole(roleCodes: string[], requiredPermission: string): boolean;
|
|
50
|
-
/**
|
|
51
|
-
* 根據角色列表提供選單項目
|
|
52
|
-
* @param param 配置參數
|
|
53
|
-
*/
|
|
54
|
-
static provideMenuByPermission(param: ProvideMenuByPermissionParams): CMenuItem[];
|
|
55
|
-
}
|
|
56
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 權限:操作字串列舉
|
|
3
|
-
*/
|
|
4
|
-
export declare enum PermissionAction {
|
|
5
|
-
NONE = "NONE",// 無操作
|
|
6
|
-
SIGN_IN = "SIGN_IN",// 登入
|
|
7
|
-
SIGN_OUT = "SIGN_OUT",// 登出
|
|
8
|
-
FORGOT_PASSWORD = "FORGOT_PASSWORD",// 忘記密碼
|
|
9
|
-
RESET_PASSWORD = "RESET_PASSWORD",// 重設個人密碼
|
|
10
|
-
CHANGE_PASSWORD = "CHANGE_PASSWORD",// 更改密碼
|
|
11
|
-
CREATE = "CREATE",// 建立資料
|
|
12
|
-
SEARCH = "SEARCH",// 查詢列表
|
|
13
|
-
READ = "READ",// 讀取資料
|
|
14
|
-
UPDATE = "UPDATE",// 更新資料
|
|
15
|
-
DELETE = "DELETE",// 刪除資料
|
|
16
|
-
EXPORT = "EXPORT"
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* 權限描述類別
|
|
20
|
-
*/
|
|
21
|
-
export declare class PermissionDescriptor {
|
|
22
|
-
module: string;
|
|
23
|
-
action: PermissionAction;
|
|
24
|
-
supportedActions: PermissionAction[];
|
|
25
|
-
constructor(data?: Partial<PermissionDescriptor> | string);
|
|
26
|
-
/**
|
|
27
|
-
* 檢查是否屬於同一個 module
|
|
28
|
-
* @param toCheckPermissions
|
|
29
|
-
*/
|
|
30
|
-
checkModule(toCheckPermissions: string[]): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* 檢查是否具有指定的權限
|
|
33
|
-
* @param toCheckPermissions
|
|
34
|
-
*/
|
|
35
|
-
checkPermission(toCheckPermissions: string[]): boolean;
|
|
36
|
-
}
|
|
37
|
-
export declare const __PermissionStringDefine__: PermissionAction;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { CAlertModalData } from './CAlertDefine';
|
|
2
|
-
type __VLS_Props = {
|
|
3
|
-
id?: string;
|
|
4
|
-
};
|
|
5
|
-
declare function show(data?: CAlertModalData): void;
|
|
6
|
-
declare function hide(): void;
|
|
7
|
-
declare const _default: import('vue').DefineComponent<__VLS_Props, {
|
|
8
|
-
show: typeof show;
|
|
9
|
-
hide: typeof hide;
|
|
10
|
-
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
11
|
-
"c.modal.ok": (...args: any[]) => void;
|
|
12
|
-
"c.modal.cancel": (...args: any[]) => void;
|
|
13
|
-
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
14
|
-
"onC.modal.ok"?: ((...args: any[]) => any) | undefined;
|
|
15
|
-
"onC.modal.cancel"?: ((...args: any[]) => any) | undefined;
|
|
16
|
-
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
17
|
-
export default _default;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface CAlertModalData {
|
|
2
|
-
type?: CAlertModalType | string;
|
|
3
|
-
title?: string;
|
|
4
|
-
content?: string;
|
|
5
|
-
onCancel?: () => void;
|
|
6
|
-
onOk?: () => void;
|
|
7
|
-
}
|
|
8
|
-
export declare enum CAlertModalType {
|
|
9
|
-
Error = "error",// 警告類型
|
|
10
|
-
Alert = "alert",// 警告類型
|
|
11
|
-
Confirm = "confirm",// 確認類型
|
|
12
|
-
Info = "info"
|
|
13
|
-
}
|
|
14
|
-
export declare const __CAlertModelDefine__: CAlertModalData & CAlertModalType;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CAlertModalData } from '../components/CAlertDefine';
|
|
2
|
-
declare function addToast(data: CAlertModalData): void;
|
|
3
|
-
declare const _default: import('vue').DefineComponent<{}, {
|
|
4
|
-
addToast: typeof addToast;
|
|
5
|
-
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
6
|
-
export default _default;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
type __VLS_Props = {
|
|
2
|
-
show?: boolean;
|
|
3
|
-
color?: string;
|
|
4
|
-
delayMS?: number;
|
|
5
|
-
isDelay?: boolean;
|
|
6
|
-
};
|
|
7
|
-
declare function showSpinner(): void;
|
|
8
|
-
declare function hide(): void;
|
|
9
|
-
declare const _default: import('vue').DefineComponent<__VLS_Props, {
|
|
10
|
-
show: typeof showSpinner;
|
|
11
|
-
hide: typeof hide;
|
|
12
|
-
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
13
|
-
export default _default;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ComputedRef } from 'vue';
|
|
2
|
-
type __VLS_Props = {
|
|
3
|
-
align?: 'left' | 'center' | 'right';
|
|
4
|
-
rowData: Record<string, any>;
|
|
5
|
-
cancelable?: boolean;
|
|
6
|
-
disableComputed?: ComputedRef<boolean>;
|
|
7
|
-
readMode?: boolean;
|
|
8
|
-
};
|
|
9
|
-
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
10
|
-
"update:checked": (...args: any[]) => void;
|
|
11
|
-
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
12
|
-
"onUpdate:checked"?: ((...args: any[]) => any) | undefined;
|
|
13
|
-
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
14
|
-
export default _default;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
type __VLS_Props = {
|
|
2
|
-
rowData: Record<string, any>;
|
|
3
|
-
dataName: string;
|
|
4
|
-
};
|
|
5
|
-
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
6
|
-
"update:textInput": (...args: any[]) => void;
|
|
7
|
-
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
8
|
-
"onUpdate:textInput"?: ((...args: any[]) => any) | undefined;
|
|
9
|
-
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLInputElement>;
|
|
10
|
-
export default _default;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Reactive } from 'vue';
|
|
2
|
-
import { BaseFormDataModel } from '../model/BaseFormDataModel';
|
|
3
|
-
import { QueryParameter } from '../model/QueryParameter';
|
|
4
|
-
import { CTableColumn } from './CTableDefine';
|
|
5
|
-
type CTableProps<T extends QueryParameter, V extends BaseFormDataModel> = {
|
|
6
|
-
queryParam?: Reactive<T>;
|
|
7
|
-
columns: CTableColumn[];
|
|
8
|
-
dataList?: V[];
|
|
9
|
-
disablePagination?: boolean;
|
|
10
|
-
multiSort?: boolean;
|
|
11
|
-
pageSizeOptions?: number[];
|
|
12
|
-
styleConfig?: Record<string, any>;
|
|
13
|
-
};
|
|
14
|
-
type __VLS_Props = CTableProps<QueryParameter, BaseFormDataModel>;
|
|
15
|
-
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
16
|
-
"table-action": (...args: any[]) => void;
|
|
17
|
-
"page-change": (...args: any[]) => void;
|
|
18
|
-
"sort-change": (...args: any[]) => void;
|
|
19
|
-
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
20
|
-
"onTable-action"?: ((...args: any[]) => any) | undefined;
|
|
21
|
-
"onPage-change"?: ((...args: any[]) => any) | undefined;
|
|
22
|
-
"onSort-change"?: ((...args: any[]) => any) | undefined;
|
|
23
|
-
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, HTMLDivElement>;
|
|
24
|
-
export default _default;
|