Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 88c1216e
authored
Mar 26, 2026
by
chenwq1
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:部署
1 parent
5253a6b2
Pipeline
#142
for
88c1216e
failed
in 0 seconds
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
65 additions
and
32 deletions
apps/web/venus-usedcar-quality/env.d.ts
apps/web/venus-usedcar-quality/package.json
apps/web/venus-usedcar-quality/src/config/center.ts
apps/web/venus-usedcar-quality/src/config/constants.ts
apps/web/venus-usedcar-quality/src/router/index.ts
apps/web/venus-usedcar-quality/src/views/login/LoginMobile.vue
apps/web/venus-usedcar-quality/src/views/login/LoginPad.vue
apps/web/venus-usedcar-quality/src/views/login/useLogin.ts
apps/web/venus-usedcar-quality/vite.config.ts
apps/web/venus-usedcar-quality/env.d.ts
View file @
88c1216
...
...
@@ -27,6 +27,8 @@ interface ImportMetaEnv {
readonly
VITE_APP_TITLE
:
string
;
readonly
VITE_API_BASE_URL
:
string
;
readonly
VITE_APP_ENV
:
"development"
|
"staging"
|
"production"
;
/** 静态资源与路由公共路径,如 /venus-usedcar-h5/;不设时非 development 构建默认为该子路径 */
readonly
VITE_PUBLIC_BASE
?:
string
;
}
interface
ImportMeta
{
...
...
apps/web/venus-usedcar-quality/package.json
View file @
88c1216
{
"name"
:
"venus-usedcar-
h5
"
,
"name"
:
"venus-usedcar-
quality
"
,
"version"
:
"1.0.0"
,
"description"
:
"二手车H5移动端应用"
,
"private"
:
true
,
...
...
apps/web/venus-usedcar-quality/src/config/center.ts
View file @
88c1216
...
...
@@ -12,23 +12,6 @@ const defaultBaseURL = import.meta.env.VITE_API_BASE_URL ?? "";
let
config
:
Record
<
string
,
unknown
>
=
{};
let
requestInstance
:
null
|
Request
=
null
;
function
getCached
<
T
>
(
key
:
string
):
null
|
T
{
try
{
const
item
=
localStorage
.
getItem
(
key
);
return
item
?
(
JSON
.
parse
(
item
)
as
T
)
:
null
;
}
catch
{
return
null
;
}
}
function
setCache
(
key
:
string
,
value
:
unknown
):
void
{
try
{
localStorage
.
setItem
(
key
,
JSON
.
stringify
(
value
));
}
catch
{
/* ignore */
}
}
function
getToken
():
string
{
const
token
=
localStorage
.
getItem
(
TOKEN_KEY
);
return
token
?
`Bearer
${
token
}
`
:
""
;
...
...
@@ -109,21 +92,14 @@ function initRequestInstance(cfg: Record<string, unknown>): void {
}
/**
* 获取远程配置(
优先缓存
)
* 获取远程配置(
不落 localStorage,每次调用都请求配置中心;登录页进入时由路由再次拉取
)
*/
export
async
function
fetchConfig
():
Promise
<
Record
<
string
,
unknown
>>
{
const
cached
=
getCached
<
Record
<
string
,
unknown
>>
(
CONFIG_CACHE_KEY
);
if
(
cached
)
{
config
=
cached
;
initRequestInstance
(
config
);
return
config
;
}
try
{
const
res
=
await
fetch
(
CONFIG_CENTER_URL
);
const
res
=
await
fetch
(
CONFIG_CENTER_URL
,
{
cache
:
"no-store"
}
);
const
data
=
(
await
res
.
json
())
as
Record
<
string
,
unknown
>
;
if
(
data
)
{
config
=
(
data
?.
data
??
data
)
as
Record
<
string
,
unknown
>
;
setCache
(
CONFIG_CACHE_KEY
,
config
);
initRequestInstance
(
config
);
}
else
{
initRequestInstance
({
apiBaseUrl
:
defaultBaseURL
});
...
...
apps/web/venus-usedcar-quality/src/config/constants.ts
View file @
88c1216
/*
* @Author: cen
* @Date: 2026-03-25 20:49:38
* @Description:
* @FilePath: /venus-usedcar-h5/apps/web/venus-usedcar-quality/src/config/constants.ts
* @LastEditTime: 2026-03-26 19:53:34
* @LastEditors: cenchengwei@foreverht.com
* 可以输入预定的版权声明、个性签名、空行等
*/
/**
* 应用级常量(配置中心、鉴权存储 key 等)
*/
/** 二手车 H5 配置请求 URL */
export
const
CONFIG_CENTER_URL
=
"https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=venus-usedcar-config
&env=develop
"
;
"https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=venus-usedcar-config"
;
/** 配置缓存 key */
export
const
CONFIG_CACHE_KEY
=
"venus_usedcar_config"
;
...
...
apps/web/venus-usedcar-quality/src/router/index.ts
View file @
88c1216
import
{
createRouter
,
createWebHistory
}
from
"vue-router"
;
import
{
fetchConfig
}
from
"@/config/center"
;
import
{
LOGIN_REDIRECT_KEY
}
from
"@/config/constants"
;
import
{
useUserStore
}
from
"@stores/modules/user.ts"
;
import
{
closeToast
,
showLoadingToast
}
from
"vant"
;
...
...
@@ -23,8 +24,18 @@ const router = createRouter({
// 不需要登录的白名单路由
const
WHITE_LIST
=
new
Set
([
"/inspect-detail"
,
"/inspect-report"
,
"/login"
]);
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
router
.
beforeEach
(
async
(
to
,
from
,
next
)
=>
{
const
userStore
=
useUserStore
();
const
hasToken
=
!!
userStore
.
token
;
// SPA 内进入登录页时再拉配置(首屏由 main 拉过;已登录去登录页会重定向,不必请求)
if
(
to
.
path
===
"/login"
&&
from
.
matched
.
length
>
0
&&
!
hasToken
)
{
try
{
await
fetchConfig
();
}
catch
{
/* 失败时沿用内存/默认配置 */
}
}
if
(
routeLoadingTimer
!==
undefined
)
{
clearTimeout
(
routeLoadingTimer
);
...
...
@@ -47,8 +58,6 @@ router.beforeEach((to, from, next) => {
document
.
title
=
`
${
to
.
meta
.
title
}
-
${
import
.
meta
.
env
.
VITE_APP_TITLE
}
`
;
}
const
hasToken
=
!!
userStore
.
token
;
// 1. 有 token 的情况
if
(
hasToken
)
{
// 已经登录还去登录页,直接跳到首页或来源页
...
...
apps/web/venus-usedcar-quality/src/views/login/LoginMobile.vue
View file @
88c1216
...
...
@@ -5,6 +5,7 @@ const {
phone
,
code
,
sending
,
loggingIn
,
countdown
,
hasSent
,
handleSendCode
,
...
...
@@ -61,7 +62,9 @@ const {
<van-button
block
class=
"mt-6 !h-[52px] border-0 !bg-[#185EFE] !text-[#ffffff] text-[16px] font-medium"
:disabled=
"!phone || !code"
:disabled=
"!phone || !code || loggingIn"
:loading=
"loggingIn"
loading-text=
"登录中..."
round
@
click=
"handleLogin"
>
登录
...
...
apps/web/venus-usedcar-quality/src/views/login/LoginPad.vue
View file @
88c1216
...
...
@@ -5,6 +5,7 @@ const {
phone
,
code
,
sending
,
loggingIn
,
countdown
,
hasSent
,
handleSendCode
,
...
...
@@ -57,6 +58,9 @@ const {
<van-button
block
class=
"mt-6 !h-[52px] w-[83%] border-0 bg-gradient-to-r from-[#84a9ff] to-[#90b5ff] text-[16px] font-medium"
:disabled=
"!phone || !code || loggingIn"
:loading=
"loggingIn"
loading-text=
"登录中..."
round
type=
"primary"
@
click=
"handleLogin"
>
...
...
apps/web/venus-usedcar-quality/src/views/login/useLogin.ts
View file @
88c1216
...
...
@@ -25,6 +25,7 @@ export function useLogin() {
});
const
sending
=
ref
(
false
);
const
loggingIn
=
ref
(
false
);
const
countdown
=
ref
(
0
);
const
hasSent
=
ref
(
false
);
let
timer
:
null
|
number
=
null
;
...
...
@@ -77,6 +78,7 @@ export function useLogin() {
}
try
{
loggingIn
.
value
=
true
;
const
res
=
await
login
({
phone
:
phone
.
value
,
verifyCode
:
code
.
value
,
...
...
@@ -101,6 +103,8 @@ export function useLogin() {
}
catch
(
error
)
{
console
.
error
(
"login error"
,
error
);
showFailToast
(
"登录失败,请稍后重试"
);
}
finally
{
loggingIn
.
value
=
false
;
}
};
...
...
@@ -108,6 +112,7 @@ export function useLogin() {
phone
,
code
,
sending
,
loggingIn
,
countdown
,
hasSent
,
handleSendCode
,
...
...
apps/web/venus-usedcar-quality/vite.config.ts
View file @
88c1216
/*
* @Author: cen
* @Date: 2026-03-26 10:52:58
* @Description:
* @FilePath: /venus-usedcar-h5/apps/web/venus-usedcar-quality/vite.config.ts
* @LastEditTime: 2026-03-26 18:56:16
* @LastEditors: cenchengwei@foreverht.com
* 可以输入预定的版权声明、个性签名、空行等
*/
import
{
dirname
,
resolve
}
from
"node:path"
;
import
process
from
"node:process"
;
import
{
fileURLToPath
}
from
"node:url"
;
...
...
@@ -13,10 +22,26 @@ const __dirname = dirname(__filename);
const
PORT
=
8082
;
function
normalizePublicBase
(
path
:
string
):
string
{
if
(
!
path
||
path
===
"/"
)
return
"/"
;
return
path
.
endsWith
(
"/"
)
?
path
:
`
${
path
}
/`
;
}
export
default
defineConfig
(({
mode
})
=>
{
const
env
=
loadEnv
(
mode
,
process
.
cwd
(),
"VITE_"
);
// 部署在 https://host/venus-usedcar-h5/;开发为根路径。可用 .env.* 中 VITE_PUBLIC_BASE 覆盖
let
base
:
string
;
if
(
env
.
VITE_PUBLIC_BASE
)
{
base
=
normalizePublicBase
(
env
.
VITE_PUBLIC_BASE
);
}
else
if
(
mode
===
"development"
)
{
base
=
"/"
;
}
else
{
base
=
"/venus-usedcar-h5/"
;
}
return
{
base
,
plugins
:
[
vue
(),
AutoImport
({
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment