Skip to content

Commit 0f246f7

Browse files
committed
feat(project): support app custom loading template
1 parent 8952e94 commit 0f246f7

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

internal/vite-config/src/plugins/inject-app-loading/loading-antd.html renamed to internal/vite-config/src/plugins/inject-app-loading/default-loading-antd.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
display: block;
6666
width: 20px;
6767
height: 20px;
68-
background-color: #0065cc;
68+
background-color: hsl(var(--primary, 210 100% 50%));
6969
border-radius: 100%;
7070
opacity: 0.3;
7171
transform: scale(0.75);

internal/vite-config/src/plugins/inject-app-loading/loading.html renamed to internal/vite-config/src/plugins/inject-app-loading/default-loading.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
width: 48px;
5757
height: 5px;
5858
content: '';
59-
background: hsl(var(--primary) / 50%);
59+
background: hsl(var(--primary, 210 100% 50%) / 50%);
6060
border-radius: 50%;
6161
animation: shadow-ani 0.5s linear infinite;
6262
}
@@ -68,7 +68,7 @@
6868
width: 100%;
6969
height: 100%;
7070
content: '';
71-
background: hsl(var(--primary));
71+
background: hsl(var(--primary, 210 100% 50%));
7272
border-radius: 4px;
7373
animation: jump-ani 0.5s linear infinite;
7474
}

internal/vite-config/src/plugins/inject-app-loading/index.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import { type PluginOption } from 'vite';
1212
async function viteInjectAppLoadingPlugin(
1313
isBuild: boolean,
1414
env: Record<string, any> = {},
15+
loadingTemplate = 'loading.html',
1516
): Promise<PluginOption | undefined> {
16-
const loadingHtml = await getLoadingRawByHtmlTemplate();
17+
const loadingHtml = await getLoadingRawByHtmlTemplate(loadingTemplate);
1718
const envRaw = isBuild ? 'prod' : 'dev';
1819
const cacheName = `'${env.VITE_APP_NAMESPACE}-${envRaw}-preferences-theme'`;
1920

@@ -47,10 +48,15 @@ async function viteInjectAppLoadingPlugin(
4748
/**
4849
* 用于获取loading的html模板
4950
*/
50-
async function getLoadingRawByHtmlTemplate() {
51+
async function getLoadingRawByHtmlTemplate(loadingTemplate: string) {
5152
const __dirname = fileURLToPath(new URL('.', import.meta.url));
52-
const loadingPath = join(__dirname, './loading.html');
53-
if (!fs.existsSync(loadingPath)) {
53+
const defaultLoadingPath = join(__dirname, './default-loading.html');
54+
// 支持在app内自定义loading模板,模版参考default-loading.html即可
55+
const appLoadingPath = join(process.cwd(), loadingTemplate);
56+
let loadingPath = defaultLoadingPath;
57+
58+
if (fs.existsSync(appLoadingPath)) {
59+
loadingPath = appLoadingPath;
5460
return;
5561
}
5662

packages/@core/shared/cache/src/storage-manager.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
33
import { StorageManager } from './storage-manager';
44

55
describe('storageManager', () => {
6-
let storageManager: StorageManager<{ age: number; name: string }>;
6+
let storageManager: StorageManager;
77

88
beforeEach(() => {
99
vi.useFakeTimers();
1010
localStorage.clear();
11-
storageManager = new StorageManager<{ age: number; name: string }>({
11+
storageManager = new StorageManager({
1212
prefix: 'test_',
1313
});
1414
});

packages/business/universal-ui/src/authentication/login.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const emit = defineEmits<{
102102
103103
const router = useRouter();
104104
105-
const REMEMBER_ME_KEY = 'REMEMBER_ME_USERNAME';
105+
const REMEMBER_ME_KEY = `REMEMBER_ME_USERNAME_${location.hostname}`;
106106
107107
const localUsername = localStorage.getItem(REMEMBER_ME_KEY) || '';
108108

0 commit comments

Comments
 (0)