Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
W
webPoint
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
Close sidebar
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
pica-spa
webPoint
提交
20f6886b
提交
20f6886b
编写于
10月 27, 2021
作者:
xiaoping.di
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
埋点公用文件
上级
流水线
#39010
已失败 于阶段
变更
3
流水线
1
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
229 行增加
和
0 行删除
+229
-0
node_main.js
node_main.js
+74
-0
public_uat.js
public_uat.js
+89
-0
public_uat_ssr.js
public_uat_ssr.js
+66
-0
未找到文件。
node_main.js
0 → 100644
浏览文件 @
20f6886b
const
path
=
require
(
'path'
);
const
axios
=
require
(
'axios'
);
const
fs
=
require
(
'fs'
);
const
projectName
=
require
(
'./package.json'
).
name
;
const
filePath
=
path
.
join
(
__dirname
,
'src'
);
// 先删除文件
function
deleOldJson
()
{
const
json_path
=
path
.
join
(
__dirname
,
'src/menu_code.json'
);
try
{
fs
.
unlinkSync
(
json_path
);
}
catch
(
err
)
{
console
.
log
(
'没有json 文件'
);
}
}
deleOldJson
();
// 文件夹是不是存在
function
isFileExisted
(
filePath
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
fs
.
access
(
filePath
,
(
err
)
=>
{
if
(
err
)
{
return
reject
(
false
);
}
else
{
return
resolve
(
true
);
}
});
});
}
// 请求接口获取menucode
function
getMenuCode
()
{
const
url
=
'https://sc.yunqueyi.com/basic-data/menuCode/fetch'
;
// let url="https://dev-sc.yunqueyi.com/basic-data/menuCode/fetch";
console
.
log
(
projectName
);
axios
.
get
(
url
,
{
params
:{
'projectName'
:
projectName
}})
.
then
(
res
=>
{
const
resData
=
res
.
data
;
if
(
resData
.
code
==
'000000'
)
{
if
(
!
resData
.
data
)
{
console
.
log
(
'接口data 数据为空'
);
return
;
}
console
.
log
(
resData
.
data
.
menuCodeDtoList
);
return
writerJsonFile
(
JSON
.
stringify
(
resData
.
data
.
menuCodeDtoList
));
}
else
{
console
.
log
(
'获取接口失败'
);
}
}).
catch
(
error
=>
{
console
.
error
(
'请求menu接口失败error'
,
error
);
});
}
// 写入json 文件
function
writerJsonFile
(
data
)
{
const
wpath
=
filePath
+
'/menu_code.json'
;
fs
.
writeFileSync
(
wpath
,
data
);
console
.
log
(
'写入文件成功'
);
}
// 创建目录
function
createFiles
(
filePath
)
{
fs
.
mkdir
(
filePath
,
function
(
err
)
{
if
(
!
err
)
{
getMenuCode
();
}
else
{
console
.
log
(
'创建目录失败'
);
}
});
}
isFileExisted
(
filePath
).
then
(()
=>
{
return
getMenuCode
();
}).
catch
(()
=>
{
// 没有文件创建文件
createFiles
(
filePath
);
});
public_uat.js
0 → 100644
浏览文件 @
20f6886b
import
axios
from
'axios'
;
import
{
name
}
from
'../package.json'
;
// 整理路由
const
routerObj
=
{};
const
titleObj
=
{};
let
baseUrl
=
process
.
env
.
VUE_APP_BASE_ROUTE_URL
||
process
.
env
.
BASE_URL
||
''
;
let
fullHost
=
location
.
host
||
''
;
if
(
fullHost
.
indexOf
(
'uat-'
)
!=
-
1
)
{
fullHost
=
fullHost
.
replace
(
'uat-'
,
''
);
}
if
(
fullHost
.
indexOf
(
'http'
)
==
-
1
)
{
fullHost
=
(
window
.
location
.
protocol
||
'https:'
)
+
'//'
+
fullHost
;
}
let
rMode
=
'history'
;
if
(
window
.
location
.
hash
)
{
rMode
=
'hash'
;
baseUrl
=
baseUrl
||
location
.
pathname
;
}
let
projectName
=
name
;
// 处理路由children
function
allRouter
(
ele
,
spath
)
{
for
(
var
i
=
0
;
i
<
ele
.
length
;
i
++
)
{
if
(
ele
[
i
].
path
)
{
let
key
=
''
;
if
(
spath
&&
spath
!=
'/'
)
{
key
=
spath
+
'/'
+
ele
[
i
].
path
;
}
else
{
key
=
ele
[
i
].
path
;
}
routerObj
[
key
]
=
key
;
titleObj
[
key
]
=
ele
[
i
].
meta
&&
ele
[
i
].
meta
.
title
;
if
(
ele
[
i
].
children
)
{
allRouter
(
ele
[
i
].
children
,
ele
[
i
].
path
);
}
}
}
}
// 处理路由
function
handleAllRouter
(
parmsObj
)
{
parmsObj
.
mode
=
parmsObj
.
mode
||
rMode
;
projectName
=
parmsObj
.
projectName
||
projectName
;
baseUrl
=
parmsObj
.
baseUrl
||
baseUrl
||
''
;
const
fhost
=
parmsObj
.
fullHost
||
fullHost
;
if
(
baseUrl
.
substr
(
baseUrl
.
length
-
1
,
1
)
==
'/'
)
{
baseUrl
=
baseUrl
.
substr
(
0
,
baseUrl
.
length
-
1
);
}
if
(
parmsObj
.
mode
==
'hash'
)
{
baseUrl
=
baseUrl
+
'/#'
;
}
allRouter
(
parmsObj
.
routerConfig
,
''
);
const
arr
=
[];
for
(
var
key
in
routerObj
)
{
const
optionObj
=
{};
optionObj
.
url
=
routerObj
[
key
];
optionObj
.
fullPath
=
fhost
+
baseUrl
+
routerObj
[
key
];
optionObj
.
host
=
fhost
;
optionObj
.
title
=
titleObj
[
key
];
arr
.
push
(
optionObj
);
}
sendAllRouterInfo
(
arr
);
}
// 发送请求
function
sendAllRouterInfo
(
data
)
{
let
url
=
''
;
if
(
process
.
env
.
NODE_ENV
==
'development'
)
{
url
=
'https://dev-sc.yunqueyi.com/basic-data/menuCode/upload'
;
}
else
if
(
process
.
env
.
VUE_APP_ENV
==
'uat'
)
{
url
=
'https://sc.yunqueyi.com/basic-data/menuCode/upload'
;
}
if
(
!
url
)
{
return
;
}
const
obj
=
{
projectName
:
projectName
,
menuCodeDtoList
:
data
};
console
.
log
(
obj
);
axios
({
method
:
'post'
,
url
:
url
,
data
:
obj
}).
then
(
res
=>
{
console
.
log
(
'请求接口成功了'
,
res
.
data
);
return
;
}).
catch
(
err
=>
{
console
.
log
(
'errerrerr'
,
err
);
return
;
});
}
export
default
handleAllRouter
;
public_uat_ssr.js
0 → 100644
浏览文件 @
20f6886b
var
axios
=
require
(
'axios'
);
// 整理路由
const
routerObj
=
{};
let
baseUrl
=
''
;
let
port
=
(
process
.
env
.
PORT
==
"80"
||
process
.
env
.
PORT
==
"443"
)
?
''
:
(
":"
+
process
.
env
.
PORT
)
let
fullHost
=
process
.
env
.
HOST
+
port
;
let
projectName
=
require
(
"../package.json"
).
name
//production
// 处理路由children
function
allRouter
(
ele
){
for
(
var
i
=
0
;
i
<
ele
.
length
;
i
++
){
if
(
ele
[
i
].
path
){
//let key= baseUrl+spath+(spath ? "/" : '')+ele[i].path;
let
key
=
ele
[
i
].
path
;
routerObj
[
key
]
=
key
;
}
}
};
// 处理路由
function
handleAllRouter
(
ObjParms
){
// baseUrl
baseUrl
=
ObjParms
.
baseUrl
||
''
;
let
fhost
=
ObjParms
.
fullHost
||
fullHost
;
allRouter
(
ObjParms
.
routes
,
''
);
if
(
baseUrl
.
substr
(
baseUrl
.
length
-
1
,
1
)
==
"/"
){
baseUrl
=
baseUrl
.
substr
(
0
,
baseUrl
.
length
-
1
)
}
let
arr
=
[];
for
(
var
key
in
routerObj
){
let
optionObj
=
{};
optionObj
.
url
=
routerObj
[
key
];
optionObj
.
fullPath
=
fhost
+
baseUrl
+
routerObj
[
key
]
optionObj
.
host
=
fhost
;
arr
.
push
(
optionObj
)
}
sendAllRouterInfo
(
arr
)
};
// 发送请求
function
sendAllRouterInfo
(
data
){
let
url
=
"https://dev-sc.yunqueyi.com/basic-data/menuCode/upload"
;
if
(
process
.
env
.
NUXT_ENV_APP
!=
"development"
){
url
=
"https://sc.yunqueyi.com/basic-data/menuCode/upload"
;
}
let
obj
=
{
projectName
:
projectName
,
menuCodeDtoList
:
data
}
axios
({
method
:
'post'
,
url
:
url
,
data
:
obj
}).
then
(
res
=>
{
console
.
log
(
"请求接口成功了"
,
res
.
data
)
return
}).
catch
(
err
=>
{
console
.
log
(
"请求接口失败了"
)
return
});
};
// 定制化路由
// [{
// path:"/capital",
// meta:{isMountedReport:true,callback:()=>{return []}}
// }]
module
.
exports
=
handleAllRouter
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录