2
0

初始化项目

This commit is contained in:
caiyuchao
2024-11-14 11:06:38 +08:00
parent 988b9e6799
commit 4ffac789e1
320 changed files with 34244 additions and 0 deletions

3
src/plugins/assets.ts Normal file
View File

@@ -0,0 +1,3 @@
import 'virtual:svg-icons-register';
import 'uno.css';
import '../styles/css/global.css';

9
src/plugins/dayjs.ts Normal file
View File

@@ -0,0 +1,9 @@
import { extend } from 'dayjs';
import localeData from 'dayjs/plugin/localeData';
import { setDayjsLocale } from '../locales/dayjs';
export function setupDayjs() {
extend(localeData);
setDayjsLocale();
}

12
src/plugins/iconify.ts Normal file
View File

@@ -0,0 +1,12 @@
import { addAPIProvider, disableCache } from '@iconify/vue';
/** Setup the iconify offline */
export function setupIconifyOffline() {
const { VITE_ICONIFY_URL } = import.meta.env;
if (VITE_ICONIFY_URL) {
addAPIProvider('', { resources: [VITE_ICONIFY_URL] });
disableCache('all');
}
}

4
src/plugins/index.ts Normal file
View File

@@ -0,0 +1,4 @@
export * from './loading';
export * from './nprogress';
export * from './iconify';
export * from './dayjs';

45
src/plugins/loading.ts Normal file
View File

@@ -0,0 +1,45 @@
// @unocss-include
import { getRgbOfColor } from '@sa/utils';
import { $t } from '@/locales';
import { localStg } from '@/utils/storage';
import systemLogo from '@/assets/svg-icon/logo.svg?raw';
export function setupLoading() {
const themeColor = localStg.get('themeColor') || '#646cff';
const { r, g, b } = getRgbOfColor(themeColor);
const primaryColor = `--primary-color: ${r} ${g} ${b}`;
const loadingClasses = [
'left-0 top-0',
'left-0 bottom-0 animate-delay-500',
'right-0 top-0 animate-delay-1000',
'right-0 bottom-0 animate-delay-1500'
];
const logoWithClass = systemLogo.replace('<svg', `<svg class="size-128px text-primary"`);
const dot = loadingClasses
.map(item => {
return `<div class="absolute w-16px h-16px bg-primary rounded-8px animate-pulse ${item}"></div>`;
})
.join('\n');
const loading = `
<div class="fixed-center flex-col" style="${primaryColor}">
${logoWithClass}
<div class="w-56px h-56px my-36px">
<div class="relative h-full animate-spin">
${dot}
</div>
</div>
<h2 class="text-28px font-500 text-#646464">${$t('system.title')}</h2>
</div>`;
const app = document.getElementById('app');
if (app) {
app.innerHTML = loading;
}
}

9
src/plugins/nprogress.ts Normal file
View File

@@ -0,0 +1,9 @@
import NProgress from 'nprogress';
/** Setup plugin NProgress */
export function setupNProgress() {
NProgress.configure({ easing: 'ease', speed: 500 });
// mount on window
window.NProgress = NProgress;
}