Merge branch 'master' into chore-action

This commit is contained in:
lvxiaojiao 2023-07-05 18:23:15 +08:00
commit 2528e7f0e8
10 changed files with 51 additions and 194 deletions

View File

@ -738,10 +738,25 @@ export function isApiOutdated(
} }
export function isValidApi(api: string) { export function isValidApi(api: string) {
return ( if (!api || typeof api !== 'string') {
api && return false;
/^(?:(https?|wss?|taf):\/\/[^\/]+)?(\/?[^\s\/\?]*){1,}(\?.*)?$/.test(api) }
); const idx = api.indexOf('://');
// 不允许直接相对路径写 api
// 不允许 :// 结尾
if ((!~idx && api[0] !== '/') || (~idx && idx + 3 === api.length)) {
return false;
}
try {
// 不补一个协议URL 判断为 false
api = (~idx ? '' : 'schema://domain') + api;
new URL(api);
} catch (error) {
return false;
}
return true;
} }
export function isEffectiveApi( export function isEffectiveApi(

View File

@ -35,7 +35,7 @@ test('EventAction:ajax', async () => {
actionType: 'ajax', actionType: 'ajax',
args: { args: {
api: { api: {
url: 'api/xxx', url: '/api/xxx',
method: 'get' method: 'get'
}, },
messages: { messages: {
@ -71,7 +71,7 @@ test('EventAction:ajax', async () => {
actionType: 'ajax', actionType: 'ajax',
args: { args: {
api: { api: {
url: 'api/xxx', url: '/api/xxx',
method: 'get' method: 'get'
}, },
messages: { messages: {

View File

@ -35,7 +35,7 @@ test('EventAction:custom', async () => {
actionType: 'custom', actionType: 'custom',
args: { args: {
script: script:
"doAction({actionType: 'ajax', args: {api: 'api/xxx'}, outputVar: 'result'});" "doAction({actionType: 'ajax', args: {api: '/api/xxx'}, outputVar: 'result'});"
} }
}, },
{ {
@ -60,7 +60,7 @@ test('EventAction:custom', async () => {
actionType: 'custom', actionType: 'custom',
args: { args: {
script: script:
"doAction({actionType: 'ajax', args: {api: 'api/xxx'}, outputVar: 'result'});event.stopPropagation();" "doAction({actionType: 'ajax', args: {api: '/api/xxx'}, outputVar: 'result'});event.stopPropagation();"
} }
}, },
{ {

View File

@ -60,7 +60,7 @@ test('EventAction:prevent', async () => {
actionType: 'ajax', actionType: 'ajax',
args: { args: {
api: { api: {
url: 'api/xxx', url: '/api/xxx',
method: 'get' method: 'get'
} }
} }

View File

@ -415,7 +415,6 @@ exports[`Renderer:input table add 1`] = `
> >
<table <table
class="cxd-Table-table cxd-Table-table" class="cxd-Table-table cxd-Table-table"
style="width: 0px; table-layout: auto;"
> >
<thead> <thead>
<tr <tr
@ -424,7 +423,7 @@ exports[`Renderer:input table add 1`] = `
<th <th
class="cxd-Table-operationCell" class="cxd-Table-operationCell"
data-index="5" data-index="5"
style="width: 0px; height: 0px;" style="width: 1%;"
> >
<div <div
class="cxd-TableCell--title v-middle nowrap" class="cxd-TableCell--title v-middle nowrap"
@ -449,7 +448,6 @@ exports[`Renderer:input table add 1`] = `
class="cxd-Table-tr--odd cxd-Table-tr--1th" class="cxd-Table-tr--odd cxd-Table-tr--1th"
data-id="1" data-id="1"
data-index="0" data-index="0"
style="height: 0px;"
> >
<td <td
class="v-middle nowrap" class="v-middle nowrap"

View File

@ -1108,11 +1108,9 @@ exports[`Renderer: crud keepItemSelectionOnPageChange & maxKeepItemSelectionLeng
/> />
<div <div
class="cxd-Table-wrapper" class="cxd-Table-wrapper"
style="width: 0px;"
> >
<table <table
class="cxd-Table-table" class="cxd-Table-table"
style="width: 0px; table-layout: auto; transform: translateX(-0px);"
> >
<colgroup> <colgroup>
<col <col
@ -1120,11 +1118,9 @@ exports[`Renderer: crud keepItemSelectionOnPageChange & maxKeepItemSelectionLeng
/> />
<col <col
data-index="3" data-index="3"
width="0"
/> />
<col <col
data-index="4" data-index="4"
width="0"
/> />
</colgroup> </colgroup>
<thead> <thead>
@ -1150,7 +1146,6 @@ exports[`Renderer: crud keepItemSelectionOnPageChange & maxKeepItemSelectionLeng
<th <th
class="cxd-TableCell--sortable" class="cxd-TableCell--sortable"
data-index="3" data-index="3"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -1199,7 +1194,6 @@ exports[`Renderer: crud keepItemSelectionOnPageChange & maxKeepItemSelectionLeng
<th <th
class="" class=""
data-index="4" data-index="4"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -1938,24 +1932,19 @@ exports[`Renderer:crud basic interval headerToolbar footerToolbar 1`] = `
/> />
<div <div
class="cxd-Table-wrapper" class="cxd-Table-wrapper"
style="width: 0px;"
> >
<table <table
class="cxd-Table-table" class="cxd-Table-table"
style="width: 0px; table-layout: auto; transform: translateX(-0px);"
> >
<colgroup> <colgroup>
<col <col
data-index="3" data-index="3"
width="0"
/> />
<col <col
data-index="4" data-index="4"
width="0"
/> />
<col <col
data-index="5" data-index="5"
width="0"
/> />
</colgroup> </colgroup>
<thead> <thead>
@ -1963,7 +1952,6 @@ exports[`Renderer:crud basic interval headerToolbar footerToolbar 1`] = `
<th <th
class="" class=""
data-index="3" data-index="3"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -1983,7 +1971,6 @@ exports[`Renderer:crud basic interval headerToolbar footerToolbar 1`] = `
<th <th
class="" class=""
data-index="4" data-index="4"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -2003,7 +1990,6 @@ exports[`Renderer:crud basic interval headerToolbar footerToolbar 1`] = `
<th <th
class="" class=""
data-index="5" data-index="5"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -3790,24 +3776,19 @@ exports[`Renderer:crud source & alwaysShowPagination 1`] = `
/> />
<div <div
class="cxd-Table-wrapper" class="cxd-Table-wrapper"
style="width: 0px;"
> >
<table <table
class="cxd-Table-table" class="cxd-Table-table"
style="width: 0px; table-layout: auto; transform: translateX(-0px);"
> >
<colgroup> <colgroup>
<col <col
data-index="3" data-index="3"
width="0"
/> />
<col <col
data-index="4" data-index="4"
width="0"
/> />
<col <col
data-index="5" data-index="5"
width="0"
/> />
</colgroup> </colgroup>
<thead> <thead>
@ -3815,7 +3796,6 @@ exports[`Renderer:crud source & alwaysShowPagination 1`] = `
<th <th
class="" class=""
data-index="3" data-index="3"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -3835,7 +3815,6 @@ exports[`Renderer:crud source & alwaysShowPagination 1`] = `
<th <th
class="" class=""
data-index="4" data-index="4"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -3855,7 +3834,6 @@ exports[`Renderer:crud source & alwaysShowPagination 1`] = `
<th <th
class="" class=""
data-index="5" data-index="5"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"

View File

@ -257,20 +257,16 @@ exports[`Renderer:Pagination 1`] = `
/> />
<div <div
class="cxd-Table-wrapper" class="cxd-Table-wrapper"
style="width: 0px;"
> >
<table <table
class="cxd-Table-table" class="cxd-Table-table"
style="width: 0px; table-layout: auto; transform: translateX(-0px);"
> >
<colgroup> <colgroup>
<col <col
data-index="3" data-index="3"
width="0"
/> />
<col <col
data-index="4" data-index="4"
width="0"
/> />
</colgroup> </colgroup>
<thead> <thead>
@ -278,7 +274,6 @@ exports[`Renderer:Pagination 1`] = `
<th <th
class="" class=""
data-index="3" data-index="3"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -298,7 +293,6 @@ exports[`Renderer:Pagination 1`] = `
<th <th
class="" class=""
data-index="4" data-index="4"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"

View File

@ -370,20 +370,16 @@ exports[`Renderer:table 1`] = `
/> />
<div <div
class="cxd-Table-wrapper" class="cxd-Table-wrapper"
style="width: 0px;"
> >
<table <table
class="cxd-Table-table" class="cxd-Table-table"
style="width: 0px; table-layout: auto; transform: translateX(-0px);"
> >
<colgroup> <colgroup>
<col <col
data-index="3" data-index="3"
width="0"
/> />
<col <col
data-index="4" data-index="4"
width="0"
/> />
</colgroup> </colgroup>
<thead> <thead>
@ -391,7 +387,6 @@ exports[`Renderer:table 1`] = `
<th <th
class="" class=""
data-index="3" data-index="3"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -411,7 +406,6 @@ exports[`Renderer:table 1`] = `
<th <th
class="" class=""
data-index="4" data-index="4"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -831,20 +825,16 @@ exports[`Renderer:table align 1`] = `
/> />
<div <div
class="cxd-Table-wrapper" class="cxd-Table-wrapper"
style="width: 0px;"
> >
<table <table
class="cxd-Table-table" class="cxd-Table-table"
style="width: 0px; table-layout: auto; transform: translateX(-0px);"
> >
<colgroup> <colgroup>
<col <col
data-index="3" data-index="3"
width="0"
/> />
<col <col
data-index="4" data-index="4"
width="0"
/> />
</colgroup> </colgroup>
<thead> <thead>
@ -852,7 +842,6 @@ exports[`Renderer:table align 1`] = `
<th <th
class="" class=""
data-index="3" data-index="3"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -872,7 +861,7 @@ exports[`Renderer:table align 1`] = `
<th <th
class="" class=""
data-index="4" data-index="4"
style="text-align: right; width: 0px; height: 0px;" style="text-align: right;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -1476,40 +1465,31 @@ exports[`Renderer:table children 1`] = `
/> />
<div <div
class="cxd-Table-wrapper" class="cxd-Table-wrapper"
style="width: 0px;"
> >
<table <table
class="cxd-Table-table" class="cxd-Table-table"
style="width: 0px; table-layout: auto; transform: translateX(-0px);"
> >
<colgroup> <colgroup>
<col <col
data-index="2" data-index="2"
width="0"
/> />
<col <col
data-index="3" data-index="3"
width="0"
/> />
<col <col
data-index="4" data-index="4"
width="0"
/> />
<col <col
data-index="5" data-index="5"
width="0"
/> />
<col <col
data-index="6" data-index="6"
width="0"
/> />
<col <col
data-index="7" data-index="7"
width="0"
/> />
<col <col
data-index="8" data-index="8"
width="0"
/> />
</colgroup> </colgroup>
<thead> <thead>
@ -1517,7 +1497,6 @@ exports[`Renderer:table children 1`] = `
<th <th
class="cxd-Table-expandCell" class="cxd-Table-expandCell"
data-index="2" data-index="2"
style="width: 0px; height: 0px;"
> >
<a <a
class="cxd-Table-expandBtn" class="cxd-Table-expandBtn"
@ -1531,7 +1510,6 @@ exports[`Renderer:table children 1`] = `
<th <th
class="" class=""
data-index="3" data-index="3"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -1551,7 +1529,6 @@ exports[`Renderer:table children 1`] = `
<th <th
class="" class=""
data-index="4" data-index="4"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -1571,7 +1548,6 @@ exports[`Renderer:table children 1`] = `
<th <th
class="" class=""
data-index="5" data-index="5"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -1591,7 +1567,6 @@ exports[`Renderer:table children 1`] = `
<th <th
class="" class=""
data-index="6" data-index="6"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -1611,7 +1586,6 @@ exports[`Renderer:table children 1`] = `
<th <th
class="" class=""
data-index="7" data-index="7"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -1631,7 +1605,6 @@ exports[`Renderer:table children 1`] = `
<th <th
class="" class=""
data-index="8" data-index="8"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -2032,20 +2005,16 @@ exports[`Renderer:table classNameExpr 1`] = `
/> />
<div <div
class="cxd-Table-wrapper" class="cxd-Table-wrapper"
style="width: 0px;"
> >
<table <table
class="cxd-Table-table" class="cxd-Table-table"
style="width: 0px; table-layout: auto; transform: translateX(-0px);"
> >
<colgroup> <colgroup>
<col <col
data-index="3" data-index="3"
width="0"
/> />
<col <col
data-index="4" data-index="4"
width="0"
/> />
</colgroup> </colgroup>
<thead> <thead>
@ -2053,7 +2022,6 @@ exports[`Renderer:table classNameExpr 1`] = `
<th <th
class="" class=""
data-index="3" data-index="3"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -2073,7 +2041,6 @@ exports[`Renderer:table classNameExpr 1`] = `
<th <th
class="" class=""
data-index="4" data-index="4"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -2120,7 +2087,6 @@ exports[`Renderer:table column head style className 1`] = `
> >
<table <table
class="cxd-Table-table cxd-Table-table tableClassName" class="cxd-Table-table cxd-Table-table tableClassName"
style="width: 0px; table-layout: auto;"
> >
<thead> <thead>
<tr <tr
@ -2129,7 +2095,6 @@ exports[`Renderer:table column head style className 1`] = `
<th <th
class="" class=""
data-index="4" data-index="4"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -2153,7 +2118,6 @@ exports[`Renderer:table column head style className 1`] = `
class="cxd-Table-tr--odd cxd-Table-tr--1th" class="cxd-Table-tr--odd cxd-Table-tr--1th"
data-id="1" data-id="1"
data-index="0" data-index="0"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -2169,7 +2133,6 @@ exports[`Renderer:table column head style className 1`] = `
class="cxd-Table-tr--even cxd-Table-tr--1th" class="cxd-Table-tr--even cxd-Table-tr--1th"
data-id="2" data-id="2"
data-index="1" data-index="1"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -2185,7 +2148,6 @@ exports[`Renderer:table column head style className 1`] = `
class="cxd-Table-tr--odd cxd-Table-tr--1th" class="cxd-Table-tr--odd cxd-Table-tr--1th"
data-id="3" data-id="3"
data-index="2" data-index="2"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -2201,7 +2163,6 @@ exports[`Renderer:table column head style className 1`] = `
class="cxd-Table-tr--even cxd-Table-tr--1th" class="cxd-Table-tr--even cxd-Table-tr--1th"
data-id="4" data-id="4"
data-index="3" data-index="3"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -2217,7 +2178,6 @@ exports[`Renderer:table column head style className 1`] = `
class="cxd-Table-tr--odd cxd-Table-tr--1th" class="cxd-Table-tr--odd cxd-Table-tr--1th"
data-id="5" data-id="5"
data-index="4" data-index="4"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -2233,7 +2193,6 @@ exports[`Renderer:table column head style className 1`] = `
class="cxd-Table-tr--even cxd-Table-tr--1th" class="cxd-Table-tr--even cxd-Table-tr--1th"
data-id="6" data-id="6"
data-index="5" data-index="5"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -2249,7 +2208,6 @@ exports[`Renderer:table column head style className 1`] = `
class="cxd-Table-tr--odd cxd-Table-tr--1th" class="cxd-Table-tr--odd cxd-Table-tr--1th"
data-id="7" data-id="7"
data-index="6" data-index="6"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -2265,7 +2223,6 @@ exports[`Renderer:table column head style className 1`] = `
class="cxd-Table-tr--even cxd-Table-tr--1th" class="cxd-Table-tr--even cxd-Table-tr--1th"
data-id="8" data-id="8"
data-index="7" data-index="7"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -2281,7 +2238,6 @@ exports[`Renderer:table column head style className 1`] = `
class="cxd-Table-tr--odd cxd-Table-tr--1th" class="cxd-Table-tr--odd cxd-Table-tr--1th"
data-id="9" data-id="9"
data-index="8" data-index="8"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -2297,7 +2253,6 @@ exports[`Renderer:table column head style className 1`] = `
class="cxd-Table-tr--even cxd-Table-tr--1th" class="cxd-Table-tr--even cxd-Table-tr--1th"
data-id="10" data-id="10"
data-index="9" data-index="9"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -2663,7 +2618,6 @@ exports[`Renderer:table column head style className 1`] = `
> >
<table <table
class="cxd-Table-table cxd-Table-table tableClassName" class="cxd-Table-table cxd-Table-table tableClassName"
style="width: 0px; table-layout: auto;"
> >
<thead> <thead>
<tr <tr
@ -2672,7 +2626,6 @@ exports[`Renderer:table column head style className 1`] = `
<th <th
class="" class=""
data-index="4" data-index="4"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -2695,20 +2648,16 @@ exports[`Renderer:table column head style className 1`] = `
</div> </div>
<div <div
class="cxd-Table-wrapper" class="cxd-Table-wrapper"
style="width: 0px;"
> >
<table <table
class="cxd-Table-table tableClassName" class="cxd-Table-table tableClassName"
style="width: 0px; table-layout: auto; transform: translateX(-0px);"
> >
<colgroup> <colgroup>
<col <col
data-index="3" data-index="3"
width="0"
/> />
<col <col
data-index="4" data-index="4"
width="0"
/> />
</colgroup> </colgroup>
<thead> <thead>
@ -2716,7 +2665,6 @@ exports[`Renderer:table column head style className 1`] = `
<th <th
class="" class=""
data-index="3" data-index="3"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -2736,7 +2684,6 @@ exports[`Renderer:table column head style className 1`] = `
<th <th
class="" class=""
data-index="4" data-index="4"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -3320,32 +3267,25 @@ exports[`Renderer:table combine Renderer:table combineNum only 1`] = `
/> />
<div <div
class="cxd-Table-wrapper" class="cxd-Table-wrapper"
style="width: 0px;"
> >
<table <table
class="cxd-Table-table cxd-Table-table--withCombine" class="cxd-Table-table cxd-Table-table--withCombine"
style="width: 0px; table-layout: auto; transform: translateX(-0px);"
> >
<colgroup> <colgroup>
<col <col
data-index="3" data-index="3"
width="0"
/> />
<col <col
data-index="4" data-index="4"
width="0"
/> />
<col <col
data-index="5" data-index="5"
width="0"
/> />
<col <col
data-index="6" data-index="6"
width="0"
/> />
<col <col
data-index="7" data-index="7"
width="0"
/> />
</colgroup> </colgroup>
<thead> <thead>
@ -3353,7 +3293,6 @@ exports[`Renderer:table combine Renderer:table combineNum only 1`] = `
<th <th
class="" class=""
data-index="3" data-index="3"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -3373,7 +3312,6 @@ exports[`Renderer:table combine Renderer:table combineNum only 1`] = `
<th <th
class="" class=""
data-index="4" data-index="4"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -3393,7 +3331,6 @@ exports[`Renderer:table combine Renderer:table combineNum only 1`] = `
<th <th
class="" class=""
data-index="5" data-index="5"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -3413,7 +3350,6 @@ exports[`Renderer:table combine Renderer:table combineNum only 1`] = `
<th <th
class="" class=""
data-index="6" data-index="6"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -3433,7 +3369,6 @@ exports[`Renderer:table combine Renderer:table combineNum only 1`] = `
<th <th
class="" class=""
data-index="7" data-index="7"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -4092,32 +4027,25 @@ exports[`Renderer:table combine Renderer:table combineNum with fromIndex 1`] = `
/> />
<div <div
class="cxd-Table-wrapper" class="cxd-Table-wrapper"
style="width: 0px;"
> >
<table <table
class="cxd-Table-table cxd-Table-table--withCombine" class="cxd-Table-table cxd-Table-table--withCombine"
style="width: 0px; table-layout: auto; transform: translateX(-0px);"
> >
<colgroup> <colgroup>
<col <col
data-index="3" data-index="3"
width="0"
/> />
<col <col
data-index="4" data-index="4"
width="0"
/> />
<col <col
data-index="5" data-index="5"
width="0"
/> />
<col <col
data-index="6" data-index="6"
width="0"
/> />
<col <col
data-index="7" data-index="7"
width="0"
/> />
</colgroup> </colgroup>
<thead> <thead>
@ -4125,7 +4053,6 @@ exports[`Renderer:table combine Renderer:table combineNum with fromIndex 1`] = `
<th <th
class="" class=""
data-index="3" data-index="3"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -4145,7 +4072,6 @@ exports[`Renderer:table combine Renderer:table combineNum with fromIndex 1`] = `
<th <th
class="" class=""
data-index="4" data-index="4"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -4165,7 +4091,6 @@ exports[`Renderer:table combine Renderer:table combineNum with fromIndex 1`] = `
<th <th
class="" class=""
data-index="5" data-index="5"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -4185,7 +4110,6 @@ exports[`Renderer:table combine Renderer:table combineNum with fromIndex 1`] = `
<th <th
class="" class=""
data-index="6" data-index="6"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -4205,7 +4129,6 @@ exports[`Renderer:table combine Renderer:table combineNum with fromIndex 1`] = `
<th <th
class="" class=""
data-index="7" data-index="7"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -5023,32 +4946,25 @@ exports[`Renderer:table groupName-default 1`] = `
/> />
<div <div
class="cxd-Table-wrapper" class="cxd-Table-wrapper"
style="width: 0px;"
> >
<table <table
class="cxd-Table-table" class="cxd-Table-table"
style="width: 0px; table-layout: auto; transform: translateX(-0px);"
> >
<colgroup> <colgroup>
<col <col
data-index="3" data-index="3"
width="0"
/> />
<col <col
data-index="4" data-index="4"
width="0"
/> />
<col <col
data-index="5" data-index="5"
width="0"
/> />
<col <col
data-index="6" data-index="6"
width="0"
/> />
<col <col
data-index="8" data-index="8"
width="0"
/> />
</colgroup> </colgroup>
<thead> <thead>
@ -5057,7 +4973,6 @@ exports[`Renderer:table groupName-default 1`] = `
colspan="2" colspan="2"
data-index="3" data-index="3"
rowspan="1" rowspan="1"
style="width: 0px; height: 0px;"
> >
<span <span
class="cxd-TplField" class="cxd-TplField"
@ -5071,7 +4986,6 @@ exports[`Renderer:table groupName-default 1`] = `
colspan="3" colspan="3"
data-index="5" data-index="5"
rowspan="1" rowspan="1"
style="width: 0px; height: 0px;"
> >
<span <span
class="cxd-TplField" class="cxd-TplField"
@ -5086,7 +5000,6 @@ exports[`Renderer:table groupName-default 1`] = `
<th <th
class="" class=""
data-index="3" data-index="3"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -5106,7 +5019,6 @@ exports[`Renderer:table groupName-default 1`] = `
<th <th
class="" class=""
data-index="4" data-index="4"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -5126,7 +5038,6 @@ exports[`Renderer:table groupName-default 1`] = `
<th <th
class="" class=""
data-index="5" data-index="5"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -5146,7 +5057,6 @@ exports[`Renderer:table groupName-default 1`] = `
<th <th
class="" class=""
data-index="6" data-index="6"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -5166,7 +5076,6 @@ exports[`Renderer:table groupName-default 1`] = `
<th <th
class="" class=""
data-index="8" data-index="8"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -5988,32 +5897,25 @@ exports[`Renderer:table groupName-middleNoGroupName 1`] = `
/> />
<div <div
class="cxd-Table-wrapper" class="cxd-Table-wrapper"
style="width: 0px;"
> >
<table <table
class="cxd-Table-table" class="cxd-Table-table"
style="width: 0px; table-layout: auto; transform: translateX(-0px);"
> >
<colgroup> <colgroup>
<col <col
data-index="3" data-index="3"
width="0"
/> />
<col <col
data-index="4" data-index="4"
width="undefined"
/> />
<col <col
data-index="5" data-index="5"
width="undefined"
/> />
<col <col
data-index="6" data-index="6"
width="0"
/> />
<col <col
data-index="8" data-index="8"
width="0"
/> />
</colgroup> </colgroup>
<thead> <thead>
@ -6022,7 +5924,6 @@ exports[`Renderer:table groupName-middleNoGroupName 1`] = `
colspan="1" colspan="1"
data-index="3" data-index="3"
rowspan="1" rowspan="1"
style="width: 0px; height: 0px;"
> >
<span <span
class="cxd-TplField" class="cxd-TplField"
@ -6038,7 +5939,6 @@ exports[`Renderer:table groupName-middleNoGroupName 1`] = `
data-index="4" data-index="4"
label="Grade" label="Grade"
rowspan="2" rowspan="2"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -6061,7 +5961,6 @@ exports[`Renderer:table groupName-middleNoGroupName 1`] = `
data-index="5" data-index="5"
label="Version" label="Version"
rowspan="2" rowspan="2"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -6082,7 +5981,6 @@ exports[`Renderer:table groupName-middleNoGroupName 1`] = `
colspan="2" colspan="2"
data-index="6" data-index="6"
rowspan="1" rowspan="1"
style="width: 0px; height: 0px;"
> >
<span <span
class="cxd-TplField" class="cxd-TplField"
@ -6097,7 +5995,6 @@ exports[`Renderer:table groupName-middleNoGroupName 1`] = `
<th <th
class="" class=""
data-index="3" data-index="3"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -6117,7 +6014,6 @@ exports[`Renderer:table groupName-middleNoGroupName 1`] = `
<th <th
class="" class=""
data-index="6" data-index="6"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -6137,7 +6033,6 @@ exports[`Renderer:table groupName-middleNoGroupName 1`] = `
<th <th
class="" class=""
data-index="8" data-index="8"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -6948,32 +6843,25 @@ exports[`Renderer:table groupName-startNoGroupName 1`] = `
/> />
<div <div
class="cxd-Table-wrapper" class="cxd-Table-wrapper"
style="width: 0px;"
> >
<table <table
class="cxd-Table-table" class="cxd-Table-table"
style="width: 0px; table-layout: auto; transform: translateX(-0px);"
> >
<colgroup> <colgroup>
<col <col
data-index="3" data-index="3"
width="undefined"
/> />
<col <col
data-index="4" data-index="4"
width="undefined"
/> />
<col <col
data-index="5" data-index="5"
width="undefined"
/> />
<col <col
data-index="6" data-index="6"
width="0"
/> />
<col <col
data-index="8" data-index="8"
width="0"
/> />
</colgroup> </colgroup>
<thead> <thead>
@ -6984,7 +6872,6 @@ exports[`Renderer:table groupName-startNoGroupName 1`] = `
data-index="3" data-index="3"
label="Engine" label="Engine"
rowspan="2" rowspan="2"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -7007,7 +6894,6 @@ exports[`Renderer:table groupName-startNoGroupName 1`] = `
data-index="4" data-index="4"
label="Grade" label="Grade"
rowspan="2" rowspan="2"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -7030,7 +6916,6 @@ exports[`Renderer:table groupName-startNoGroupName 1`] = `
data-index="5" data-index="5"
label="Version" label="Version"
rowspan="2" rowspan="2"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -7051,7 +6936,6 @@ exports[`Renderer:table groupName-startNoGroupName 1`] = `
colspan="2" colspan="2"
data-index="6" data-index="6"
rowspan="1" rowspan="1"
style="width: 0px; height: 0px;"
> >
<span <span
class="cxd-TplField" class="cxd-TplField"
@ -7066,7 +6950,6 @@ exports[`Renderer:table groupName-startNoGroupName 1`] = `
<th <th
class="" class=""
data-index="6" data-index="6"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -7086,7 +6969,6 @@ exports[`Renderer:table groupName-startNoGroupName 1`] = `
<th <th
class="" class=""
data-index="8" data-index="8"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -7904,32 +7786,25 @@ exports[`Renderer:table groupName-withTpl 1`] = `
/> />
<div <div
class="cxd-Table-wrapper" class="cxd-Table-wrapper"
style="width: 0px;"
> >
<table <table
class="cxd-Table-table" class="cxd-Table-table"
style="width: 0px; table-layout: auto; transform: translateX(-0px);"
> >
<colgroup> <colgroup>
<col <col
data-index="3" data-index="3"
width="0"
/> />
<col <col
data-index="4" data-index="4"
width="0"
/> />
<col <col
data-index="5" data-index="5"
width="0"
/> />
<col <col
data-index="6" data-index="6"
width="0"
/> />
<col <col
data-index="8" data-index="8"
width="0"
/> />
</colgroup> </colgroup>
<thead> <thead>
@ -7938,7 +7813,6 @@ exports[`Renderer:table groupName-withTpl 1`] = `
colspan="2" colspan="2"
data-index="3" data-index="3"
rowspan="1" rowspan="1"
style="width: 0px; height: 0px;"
> >
<span <span
class="cxd-TplField" class="cxd-TplField"
@ -7952,7 +7826,6 @@ exports[`Renderer:table groupName-withTpl 1`] = `
colspan="3" colspan="3"
data-index="5" data-index="5"
rowspan="1" rowspan="1"
style="width: 0px; height: 0px;"
> >
<span <span
class="cxd-TplField" class="cxd-TplField"
@ -7967,7 +7840,6 @@ exports[`Renderer:table groupName-withTpl 1`] = `
<th <th
class="" class=""
data-index="3" data-index="3"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -7987,7 +7859,6 @@ exports[`Renderer:table groupName-withTpl 1`] = `
<th <th
class="" class=""
data-index="4" data-index="4"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -8007,7 +7878,6 @@ exports[`Renderer:table groupName-withTpl 1`] = `
<th <th
class="" class=""
data-index="5" data-index="5"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -8027,7 +7897,6 @@ exports[`Renderer:table groupName-withTpl 1`] = `
<th <th
class="" class=""
data-index="6" data-index="6"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -8047,7 +7916,6 @@ exports[`Renderer:table groupName-withTpl 1`] = `
<th <th
class="" class=""
data-index="8" data-index="8"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -8099,7 +7967,6 @@ exports[`Renderer:table isHead fixed 1`] = `
> >
<table <table
class="cxd-Table-table cxd-Table-table" class="cxd-Table-table cxd-Table-table"
style="width: 0px; table-layout: auto;"
> >
<thead> <thead>
<tr <tr
@ -8108,7 +7975,6 @@ exports[`Renderer:table isHead fixed 1`] = `
<th <th
class="" class=""
data-index="4" data-index="4"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -8132,7 +7998,6 @@ exports[`Renderer:table isHead fixed 1`] = `
class="cxd-Table-tr--odd cxd-Table-tr--1th" class="cxd-Table-tr--odd cxd-Table-tr--1th"
data-id="1" data-id="1"
data-index="0" data-index="0"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -8148,7 +8013,6 @@ exports[`Renderer:table isHead fixed 1`] = `
class="cxd-Table-tr--even cxd-Table-tr--1th" class="cxd-Table-tr--even cxd-Table-tr--1th"
data-id="2" data-id="2"
data-index="1" data-index="1"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -8164,7 +8028,6 @@ exports[`Renderer:table isHead fixed 1`] = `
class="cxd-Table-tr--odd cxd-Table-tr--1th" class="cxd-Table-tr--odd cxd-Table-tr--1th"
data-id="3" data-id="3"
data-index="2" data-index="2"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -8180,7 +8043,6 @@ exports[`Renderer:table isHead fixed 1`] = `
class="cxd-Table-tr--even cxd-Table-tr--1th" class="cxd-Table-tr--even cxd-Table-tr--1th"
data-id="4" data-id="4"
data-index="3" data-index="3"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -8196,7 +8058,6 @@ exports[`Renderer:table isHead fixed 1`] = `
class="cxd-Table-tr--odd cxd-Table-tr--1th" class="cxd-Table-tr--odd cxd-Table-tr--1th"
data-id="5" data-id="5"
data-index="4" data-index="4"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -8212,7 +8073,6 @@ exports[`Renderer:table isHead fixed 1`] = `
class="cxd-Table-tr--even cxd-Table-tr--1th" class="cxd-Table-tr--even cxd-Table-tr--1th"
data-id="6" data-id="6"
data-index="5" data-index="5"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -8228,7 +8088,6 @@ exports[`Renderer:table isHead fixed 1`] = `
class="cxd-Table-tr--odd cxd-Table-tr--1th" class="cxd-Table-tr--odd cxd-Table-tr--1th"
data-id="7" data-id="7"
data-index="6" data-index="6"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -8244,7 +8103,6 @@ exports[`Renderer:table isHead fixed 1`] = `
class="cxd-Table-tr--even cxd-Table-tr--1th" class="cxd-Table-tr--even cxd-Table-tr--1th"
data-id="8" data-id="8"
data-index="7" data-index="7"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -8260,7 +8118,6 @@ exports[`Renderer:table isHead fixed 1`] = `
class="cxd-Table-tr--odd cxd-Table-tr--1th" class="cxd-Table-tr--odd cxd-Table-tr--1th"
data-id="9" data-id="9"
data-index="8" data-index="8"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -8276,7 +8133,6 @@ exports[`Renderer:table isHead fixed 1`] = `
class="cxd-Table-tr--even cxd-Table-tr--1th" class="cxd-Table-tr--even cxd-Table-tr--1th"
data-id="10" data-id="10"
data-index="9" data-index="9"
style="height: 0px;"
> >
<td <td
class="" class=""
@ -8642,7 +8498,6 @@ exports[`Renderer:table isHead fixed 1`] = `
> >
<table <table
class="cxd-Table-table cxd-Table-table" class="cxd-Table-table cxd-Table-table"
style="width: 0px; table-layout: auto;"
> >
<thead> <thead>
<tr <tr
@ -8651,7 +8506,6 @@ exports[`Renderer:table isHead fixed 1`] = `
<th <th
class="" class=""
data-index="4" data-index="4"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -8674,20 +8528,16 @@ exports[`Renderer:table isHead fixed 1`] = `
</div> </div>
<div <div
class="cxd-Table-wrapper" class="cxd-Table-wrapper"
style="width: 0px;"
> >
<table <table
class="cxd-Table-table" class="cxd-Table-table"
style="width: 0px; table-layout: auto; transform: translateX(-0px);"
> >
<colgroup> <colgroup>
<col <col
data-index="3" data-index="3"
width="0"
/> />
<col <col
data-index="4" data-index="4"
width="0"
/> />
</colgroup> </colgroup>
<thead> <thead>
@ -8695,7 +8545,6 @@ exports[`Renderer:table isHead fixed 1`] = `
<th <th
class="" class=""
data-index="3" data-index="3"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"
@ -8715,7 +8564,6 @@ exports[`Renderer:table isHead fixed 1`] = `
<th <th
class="" class=""
data-index="4" data-index="4"
style="width: 0px; height: 0px;"
> >
<div <div
class="cxd-TableCell--title" class="cxd-TableCell--title"

View File

@ -1,7 +1,7 @@
import {render as amisRender} from '../../src'; import {render as amisRender} from '../../src';
import {wait, makeEnv} from '../helper'; import {wait, makeEnv} from '../helper';
import {render, fireEvent, cleanup} from '@testing-library/react'; import {render, fireEvent, cleanup} from '@testing-library/react';
import {buildApi, isApiOutdated} from 'amis-core'; import {buildApi, isApiOutdated, isValidApi} from 'amis-core';
test('api:buildApi', () => { test('api:buildApi', () => {
expect(buildApi('/api/xxx')).toMatchObject({ expect(buildApi('/api/xxx')).toMatchObject({
@ -322,3 +322,22 @@ test('api:cache', async () => {
expect(fetcher).toHaveBeenCalledTimes(1); // 只请求一次,第二次请求从缓存中取 expect(fetcher).toHaveBeenCalledTimes(1); // 只请求一次,第二次请求从缓存中取
expect(container).toMatchSnapshot(); expect(container).toMatchSnapshot();
}); });
test('api:isvalidapi', () => {
expect(isValidApi('api/xxx')).toBeFalsy();
expect(isValidApi('api/xxx?a=1')).toBeFalsy();
expect(isValidApi('/x')).toBeTruthy();
expect(isValidApi('/api/xxx?a=1&b=2&c=3')).toBeTruthy();
expect(isValidApi('http://xxxdomain')).toBeTruthy();
expect(isValidApi('http://xxxdomain/')).toBeTruthy();
expect(isValidApi('http://xxxdomain/api')).toBeTruthy();
expect(isValidApi('app://')).toBeFalsy();
expect(isValidApi('app://x')).toBeTruthy();
expect(isValidApi('app://x?a=1')).toBeTruthy();
expect(isValidApi('app://x?a=1&b=2')).toBeTruthy();
expect(isValidApi('app://x b?a=1&b=2')).toBeFalsy();
expect(isValidApi('app://x%20b?a=1&b=2')).toBeTruthy();
expect(isValidApi('ftp://127.0.0.1/xxx')).toBeTruthy();
expect(isValidApi('wss://127.0.0.1/xxx')).toBeTruthy();
expect(isValidApi('taf://127.0.0.1/xxx')).toBeTruthy();
});

View File

@ -1221,6 +1221,11 @@ export default class Table extends React.Component<TableProps, object> {
this.outterWidth = outter.offsetWidth; this.outterWidth = outter.offsetWidth;
this.outterHeight = outter.offsetHeight; this.outterHeight = outter.offsetHeight;
// 没有渲染则跳过
if (!this.totalWidth) {
return;
}
let widths: { let widths: {
[propName: string]: number; [propName: string]: number;
} = (this.widths = {}); } = (this.widths = {});