Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
前端-黄佳鑫
jinfa-platform
Commits
717b0458
Commit
717b0458
authored
Jun 11, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:全局配置注入
parent
bb62bd71
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
7 deletions
+42
-7
global.d.ts
global.d.ts
+15
-0
package.json
package.json
+1
-0
gulpfile.js
scripts/gulpfile.js
+13
-2
cacheConfig.ts
src/constants/cacheConfig.ts
+12
-0
typings.d.ts
typings.d.ts
+1
-5
No files found.
global.d.ts
0 → 100644
View file @
717b0458
export
interface
CountryList
{
name
:
string
;
key
:
string
;
icon
:
string
;
}
export
interface
Global
{
logo
:
string
;
countryList
:
CountryList
[];
}
export
interface
RootObject
{
global
:
Global
;
}
\ No newline at end of file
package.json
View file @
717b0458
...
...
@@ -38,6 +38,7 @@
"
chalk
"
:
"^4.1.0"
,
"
fs-extra
"
:
"^9.0.1"
,
"
gulp
"
:
"^4.0.2"
,
"
json2ts
"
:
"^0.0.7"
,
"
ora
"
:
"^4.0.4"
}
}
scripts/gulpfile.js
View file @
717b0458
...
...
@@ -4,8 +4,12 @@ const fse = require('fs-extra')
const
Type
=
require
(
'./utils/type'
)
const
fetchConfig
=
require
(
'../demo'
).
fetchConfig
const
gulp
=
require
(
'gulp'
)
const
json2ts
=
require
(
'json2ts'
)
const
outputPath
=
path
.
resolve
(
__dirname
,
'../'
,
'config/base.config.json'
)
const
rootPath
=
'../'
;
const
outputPath
=
path
.
resolve
(
__dirname
,
rootPath
,
'config/base.config.json'
)
const
outputDts
=
path
.
resolve
(
__dirname
,
rootPath
,
'global.d.ts'
)
Logs
.
start
(
'gulp start'
)
...
...
@@ -24,7 +28,7 @@ function genarateBaseJson(obj, done) {
Logs
.
success
(
'write success'
)
Logs
.
stop
(
'Configuration has arrived locally'
,
'success'
)
done
(
)
genarateDtsFile
(
JSON
.
stringify
(
obj
),
done
)
}).
catch
(
err
=>
{
Logs
.
error
(
err
)
done
()
...
...
@@ -39,6 +43,13 @@ function genarateBaseJson(obj, done) {
}
}
function
genarateDtsFile
(
json
,
done
)
{
const
dtsResult
=
json2ts
.
convert
(
json
)
fse
.
outputFile
(
outputDts
,
dtsResult
).
then
(()
=>
{
done
()
})
}
/**
* 异步获取远程配置
* @todo
...
...
src/constants/cacheConfig.ts
0 → 100644
View file @
717b0458
/**
*
* **********
* 脚本注入全局配置
*
* **********
*/
import
SELF_CONFIG
from
'../../config/base.config.json'
import
{
RootObject
}
from
'../../global'
export
const
GlobalConfig
:
RootObject
=
SELF_CONFIG
typings.d.ts
View file @
717b0458
...
...
@@ -2,12 +2,9 @@ declare module '*.css';
declare
module
'*.less'
;
declare
module
"*.png"
;
declare
module
"classnames"
;
declare
module
"*.json"
;
declare
module
'*.svg'
{
export
function
ReactComponent
(
props
:
React
.
SVGProps
<
SVGSVGElement
>
):
React
.
ReactElement
const
url
:
string
export
default
url
}
declare
interface
GLOBAL_CONFIG
{
menu
:
string
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment