File tree 4 files changed +19
-13
lines changed
components/Editor/typesResolve
4 files changed +19
-13
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ export type TApplication = {
19
19
tls : boolean ;
20
20
develop_token : string ;
21
21
port : number ;
22
+ host : string ;
23
+ origin : string ;
22
24
} ;
23
25
24
26
export type TBundle = {
Original file line number Diff line number Diff line change @@ -7,12 +7,8 @@ import useGlobalStore from "@/pages/globalStore";
7
7
8
8
async function loadPackageTypings ( packageName : string ) {
9
9
const { currentApp } = useGlobalStore . getState ( ) ;
10
- const port = currentApp ?. port ;
11
10
12
- let url = `//${ currentApp ?. domain ?. domain } ` ;
13
- if ( port !== 80 && port !== 443 ) {
14
- url = `${ url } :${ port } ` ;
15
- }
11
+ const url = `//${ currentApp ?. host } ` ;
16
12
17
13
const res = await axios ( {
18
14
url : `${ url } /_/typing/package?packageName=${ packageName } ` ,
Original file line number Diff line number Diff line change @@ -32,15 +32,9 @@ const useFunctionStore = create<State>()(
32
32
33
33
if ( ! currentFunctionName ) return "" ;
34
34
35
- const protocol = currentApp ?. tls ? "https://" : "http://" ;
36
- const port = currentApp ?. port ;
35
+ const origin = currentApp ?. origin ;
37
36
38
- let host = currentApp ?. domain ?. domain ;
39
- if ( port !== 80 && port !== 443 ) {
40
- host = `${ host } :${ port } ` ;
41
- }
42
-
43
- return `${ protocol } ${ host } /${ currentFunctionName } ` ;
37
+ return `${ origin } /${ currentFunctionName } ` ;
44
38
} ,
45
39
46
40
setCurrentRequestId : ( requestId ) => {
Original file line number Diff line number Diff line change @@ -97,6 +97,20 @@ const useGlobalStore = create<State>()(
97
97
localStorage . setItem ( "app" , app . appid ) ;
98
98
set ( ( state ) => {
99
99
state . currentApp = app ;
100
+
101
+ if ( typeof state . currentApp === "object" ) {
102
+ const protocol = state . currentApp ?. tls ? "https://" : "http://" ;
103
+ const domain = state . currentApp ?. domain ?. domain ;
104
+ const port = state . currentApp ?. port ;
105
+
106
+ if ( port === 80 || port === 443 ) {
107
+ state . currentApp . host = domain ;
108
+ } else {
109
+ state . currentApp . host = `${ domain } :${ port } ` ;
110
+ }
111
+
112
+ state . currentApp . origin = protocol + state . currentApp . host ;
113
+ }
100
114
} ) ;
101
115
} ,
102
116
You can’t perform that action at this time.
0 commit comments