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 0f246f7e
authored
Jul 10, 2024
by
vince
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat(project): support app custom loading template
1 parent
8952e947
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
10 deletions
internal/vite-config/src/plugins/inject-app-loading/loading-antd.html → internal/vite-config/src/plugins/inject-app-loading/default-loading-antd.html
internal/vite-config/src/plugins/inject-app-loading/loading.html → internal/vite-config/src/plugins/inject-app-loading/default-loading.html
internal/vite-config/src/plugins/inject-app-loading/index.ts
packages/@core/shared/cache/src/storage-manager.test.ts
packages/business/universal-ui/src/authentication/login.vue
internal/vite-config/src/plugins/inject-app-loading/loading-antd.html
→
internal/vite-config/src/plugins/inject-app-loading/
default-
loading-antd.html
View file @
0f246f7
...
@@ -65,7 +65,7 @@
...
@@ -65,7 +65,7 @@
display
:
block
;
display
:
block
;
width
:
20px
;
width
:
20px
;
height
:
20px
;
height
:
20px
;
background-color
:
#0065cc
;
background-color
:
hsl
(
var
(
--primary
,
210
100%
50%
))
;
border-radius
:
100%
;
border-radius
:
100%
;
opacity
:
0.3
;
opacity
:
0.3
;
transform
:
scale
(
0.75
);
transform
:
scale
(
0.75
);
...
...
internal/vite-config/src/plugins/inject-app-loading/loading.html
→
internal/vite-config/src/plugins/inject-app-loading/
default-
loading.html
View file @
0f246f7
...
@@ -56,7 +56,7 @@
...
@@ -56,7 +56,7 @@
width
:
48px
;
width
:
48px
;
height
:
5px
;
height
:
5px
;
content
:
''
;
content
:
''
;
background
:
hsl
(
var
(
--primary
)
/
50%
);
background
:
hsl
(
var
(
--primary
,
210
100%
50%
)
/
50%
);
border-radius
:
50%
;
border-radius
:
50%
;
animation
:
shadow-ani
0.5s
linear
infinite
;
animation
:
shadow-ani
0.5s
linear
infinite
;
}
}
...
@@ -68,7 +68,7 @@
...
@@ -68,7 +68,7 @@
width
:
100%
;
width
:
100%
;
height
:
100%
;
height
:
100%
;
content
:
''
;
content
:
''
;
background
:
hsl
(
var
(
--primary
));
background
:
hsl
(
var
(
--primary
,
210
100%
50%
));
border-radius
:
4px
;
border-radius
:
4px
;
animation
:
jump-ani
0.5s
linear
infinite
;
animation
:
jump-ani
0.5s
linear
infinite
;
}
}
...
...
internal/vite-config/src/plugins/inject-app-loading/index.ts
View file @
0f246f7
...
@@ -12,8 +12,9 @@ import { type PluginOption } from 'vite';
...
@@ -12,8 +12,9 @@ import { type PluginOption } from 'vite';
async
function
viteInjectAppLoadingPlugin
(
async
function
viteInjectAppLoadingPlugin
(
isBuild
:
boolean
,
isBuild
:
boolean
,
env
:
Record
<
string
,
any
>
=
{},
env
:
Record
<
string
,
any
>
=
{},
loadingTemplate
=
'loading.html'
,
):
Promise
<
PluginOption
|
undefined
>
{
):
Promise
<
PluginOption
|
undefined
>
{
const
loadingHtml
=
await
getLoadingRawByHtmlTemplate
();
const
loadingHtml
=
await
getLoadingRawByHtmlTemplate
(
loadingTemplate
);
const
envRaw
=
isBuild
?
'prod'
:
'dev'
;
const
envRaw
=
isBuild
?
'prod'
:
'dev'
;
const
cacheName
=
`'
${
env
.
VITE_APP_NAMESPACE
}
-
${
envRaw
}
-preferences-theme'`
;
const
cacheName
=
`'
${
env
.
VITE_APP_NAMESPACE
}
-
${
envRaw
}
-preferences-theme'`
;
...
@@ -47,10 +48,15 @@ async function viteInjectAppLoadingPlugin(
...
@@ -47,10 +48,15 @@ async function viteInjectAppLoadingPlugin(
/**
/**
* 用于获取loading的html模板
* 用于获取loading的html模板
*/
*/
async
function
getLoadingRawByHtmlTemplate
()
{
async
function
getLoadingRawByHtmlTemplate
(
loadingTemplate
:
string
)
{
const
__dirname
=
fileURLToPath
(
new
URL
(
'.'
,
import
.
meta
.
url
));
const
__dirname
=
fileURLToPath
(
new
URL
(
'.'
,
import
.
meta
.
url
));
const
loadingPath
=
join
(
__dirname
,
'./loading.html'
);
const
defaultLoadingPath
=
join
(
__dirname
,
'./default-loading.html'
);
if
(
!
fs
.
existsSync
(
loadingPath
))
{
// 支持在app内自定义loading模板,模版参考default-loading.html即可
const
appLoadingPath
=
join
(
process
.
cwd
(),
loadingTemplate
);
let
loadingPath
=
defaultLoadingPath
;
if
(
fs
.
existsSync
(
appLoadingPath
))
{
loadingPath
=
appLoadingPath
;
return
;
return
;
}
}
...
...
packages/@core/shared/cache/src/storage-manager.test.ts
View file @
0f246f7
...
@@ -3,12 +3,12 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
...
@@ -3,12 +3,12 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
import
{
StorageManager
}
from
'./storage-manager'
;
import
{
StorageManager
}
from
'./storage-manager'
;
describe
(
'storageManager'
,
()
=>
{
describe
(
'storageManager'
,
()
=>
{
let
storageManager
:
StorageManager
<
{
age
:
number
;
name
:
string
}
>
;
let
storageManager
:
StorageManager
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
vi
.
useFakeTimers
();
vi
.
useFakeTimers
();
localStorage
.
clear
();
localStorage
.
clear
();
storageManager
=
new
StorageManager
<
{
age
:
number
;
name
:
string
}
>
({
storageManager
=
new
StorageManager
({
prefix
:
'test_'
,
prefix
:
'test_'
,
});
});
});
});
...
...
packages/business/universal-ui/src/authentication/login.vue
View file @
0f246f7
...
@@ -102,7 +102,7 @@ const emit = defineEmits<{
...
@@ -102,7 +102,7 @@ const emit = defineEmits<{
const
router
=
useRouter
();
const
router
=
useRouter
();
const
REMEMBER_ME_KEY
=
'REMEMBER_ME_USERNAME'
;
const
REMEMBER_ME_KEY
=
`REMEMBER_ME_USERNAME_
${
location
.
hostname
}
`
;
const
localUsername
=
localStorage
.
getItem
(
REMEMBER_ME_KEY
)
||
''
;
const
localUsername
=
localStorage
.
getItem
(
REMEMBER_ME_KEY
)
||
''
;
...
...
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