项目微调

引入按需自动导入插件,避免开发人员显示导入vue的函数
This commit is contained in:
2024-10-09 20:03:07 +08:00
parent c8d15c5b76
commit 6b0128921b
27 changed files with 2159 additions and 104 deletions

View File

@@ -5,7 +5,7 @@ VITE_GLOB_APP_TITLE=PQS-9100自动检测平台
VITE_PORT=18091
# 启动时自动打开浏览器
VITE_OPEN=false
VITE_OPEN=true
# 打包后是否生成包分析文件
VITE_REPORT=false

View File

@@ -0,0 +1,284 @@
{
"globals": {
"Component": true,
"ComponentPublicInstance": true,
"ComputedRef": true,
"EffectScope": true,
"ElMessage": true,
"ElMessageBox": true,
"ElNotification": true,
"InjectionKey": true,
"PropType": true,
"Ref": true,
"VNode": true,
"asyncComputed": true,
"autoResetRef": true,
"computed": true,
"computedAsync": true,
"computedEager": true,
"computedInject": true,
"computedWithControl": true,
"controlledComputed": true,
"controlledRef": true,
"createApp": true,
"createEventHook": true,
"createGlobalState": true,
"createInjectionState": true,
"createReactiveFn": true,
"createReusableTemplate": true,
"createSharedComposable": true,
"createTemplatePromise": true,
"createUnrefFn": true,
"customRef": true,
"debouncedRef": true,
"debouncedWatch": true,
"defineAsyncComponent": true,
"defineComponent": true,
"eagerComputed": true,
"effectScope": true,
"extendRef": true,
"getCurrentInstance": true,
"getCurrentScope": true,
"h": true,
"ignorableWatch": true,
"inject": true,
"isDefined": true,
"isProxy": true,
"isReactive": true,
"isReadonly": true,
"isRef": true,
"makeDestructurable": true,
"markRaw": true,
"nextTick": true,
"onActivated": true,
"onBeforeMount": true,
"onBeforeUnmount": true,
"onBeforeUpdate": true,
"onClickOutside": true,
"onDeactivated": true,
"onErrorCaptured": true,
"onKeyStroke": true,
"onLongPress": true,
"onMounted": true,
"onRenderTracked": true,
"onRenderTriggered": true,
"onScopeDispose": true,
"onServerPrefetch": true,
"onStartTyping": true,
"onUnmounted": true,
"onUpdated": true,
"pausableWatch": true,
"provide": true,
"reactify": true,
"reactifyObject": true,
"reactive": true,
"reactiveComputed": true,
"reactiveOmit": true,
"reactivePick": true,
"readonly": true,
"ref": true,
"refAutoReset": true,
"refDebounced": true,
"refDefault": true,
"refThrottled": true,
"refWithControl": true,
"resolveComponent": true,
"resolveRef": true,
"resolveUnref": true,
"shallowReactive": true,
"shallowReadonly": true,
"shallowRef": true,
"syncRef": true,
"syncRefs": true,
"templateRef": true,
"throttledRef": true,
"throttledWatch": true,
"toRaw": true,
"toReactive": true,
"toRef": true,
"toRefs": true,
"toValue": true,
"triggerRef": true,
"tryOnBeforeMount": true,
"tryOnBeforeUnmount": true,
"tryOnMounted": true,
"tryOnScopeDispose": true,
"tryOnUnmounted": true,
"unref": true,
"unrefElement": true,
"until": true,
"useActiveElement": true,
"useAnimate": true,
"useArrayDifference": true,
"useArrayEvery": true,
"useArrayFilter": true,
"useArrayFind": true,
"useArrayFindIndex": true,
"useArrayFindLast": true,
"useArrayIncludes": true,
"useArrayJoin": true,
"useArrayMap": true,
"useArrayReduce": true,
"useArraySome": true,
"useArrayUnique": true,
"useAsyncQueue": true,
"useAsyncState": true,
"useAttrs": true,
"useBase64": true,
"useBattery": true,
"useBluetooth": true,
"useBreakpoints": true,
"useBroadcastChannel": true,
"useBrowserLocation": true,
"useCached": true,
"useClipboard": true,
"useCloned": true,
"useColorMode": true,
"useConfirmDialog": true,
"useCounter": true,
"useCssModule": true,
"useCssVar": true,
"useCssVars": true,
"useCurrentElement": true,
"useCycleList": true,
"useDark": true,
"useDateFormat": true,
"useDebounce": true,
"useDebounceFn": true,
"useDebouncedRefHistory": true,
"useDeviceMotion": true,
"useDeviceOrientation": true,
"useDevicePixelRatio": true,
"useDevicesList": true,
"useDisplayMedia": true,
"useDocumentVisibility": true,
"useDraggable": true,
"useDropZone": true,
"useElementBounding": true,
"useElementByPoint": true,
"useElementHover": true,
"useElementSize": true,
"useElementVisibility": true,
"useEventBus": true,
"useEventListener": true,
"useEventSource": true,
"useEyeDropper": true,
"useFavicon": true,
"useFetch": true,
"useFileDialog": true,
"useFileSystemAccess": true,
"useFocus": true,
"useFocusWithin": true,
"useFps": true,
"useFullscreen": true,
"useGamepad": true,
"useGeolocation": true,
"useIdle": true,
"useImage": true,
"useInfiniteScroll": true,
"useIntersectionObserver": true,
"useInterval": true,
"useIntervalFn": true,
"useKeyModifier": true,
"useLastChanged": true,
"useLocalStorage": true,
"useMagicKeys": true,
"useManualRefHistory": true,
"useMediaControls": true,
"useMediaQuery": true,
"useMemoize": true,
"useMemory": true,
"useMounted": true,
"useMouse": true,
"useMouseInElement": true,
"useMousePressed": true,
"useMutationObserver": true,
"useNavigatorLanguage": true,
"useNetwork": true,
"useNow": true,
"useObjectUrl": true,
"useOffsetPagination": true,
"useOnline": true,
"usePageLeave": true,
"useParallax": true,
"useParentElement": true,
"usePerformanceObserver": true,
"usePermission": true,
"usePointer": true,
"usePointerLock": true,
"usePointerSwipe": true,
"usePreferredColorScheme": true,
"usePreferredContrast": true,
"usePreferredDark": true,
"usePreferredLanguages": true,
"usePreferredReducedMotion": true,
"usePrevious": true,
"useRafFn": true,
"useRefHistory": true,
"useResizeObserver": true,
"useScreenOrientation": true,
"useScreenSafeArea": true,
"useScriptTag": true,
"useScroll": true,
"useScrollLock": true,
"useSessionStorage": true,
"useShare": true,
"useSlots": true,
"useSorted": true,
"useSpeechRecognition": true,
"useSpeechSynthesis": true,
"useStepper": true,
"useStorage": true,
"useStorageAsync": true,
"useStyleTag": true,
"useSupported": true,
"useSwipe": true,
"useTemplateRefsList": true,
"useTextDirection": true,
"useTextSelection": true,
"useTextareaAutosize": true,
"useThrottle": true,
"useThrottleFn": true,
"useThrottledRefHistory": true,
"useTimeAgo": true,
"useTimeout": true,
"useTimeoutFn": true,
"useTimeoutPoll": true,
"useTimestamp": true,
"useTitle": true,
"useToNumber": true,
"useToString": true,
"useToggle": true,
"useTransition": true,
"useUrlSearchParams": true,
"useUserMedia": true,
"useVModel": true,
"useVModels": true,
"useVibrate": true,
"useVirtualList": true,
"useWakeLock": true,
"useWebNotification": true,
"useWebSocket": true,
"useWebWorker": true,
"useWebWorkerFn": true,
"useWindowFocus": true,
"useWindowScroll": true,
"useWindowSize": true,
"watch": true,
"watchArray": true,
"watchAtMost": true,
"watchDebounced": true,
"watchDeep": true,
"watchEffect": true,
"watchIgnorable": true,
"watchImmediate": true,
"watchOnce": true,
"watchPausable": true,
"watchPostEffect": true,
"watchSyncEffect": true,
"watchThrottled": true,
"watchTriggerable": true,
"watchWithFilter": true,
"whenever": true
}
}

View File

@@ -1,9 +0,0 @@
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// noinspection JSUnusedGlobalSymbols
// Generated by unplugin-auto-import
export {}
declare global {
}

View File

@@ -37,7 +37,7 @@
"sortablejs": "^1.15.0",
"vue": "^3.4.29",
"vue-i18n": "^9.4.0",
"vue-router": "^4.3.3",
"vue-router": "^4.4.5",
"vuedraggable": "^4.1.0"
},
"devDependencies": {
@@ -66,7 +66,7 @@
"standard-version": "^9.5.0",
"tailwindcss": "^3.4.7",
"typescript": "~5.4.0",
"unplugin-auto-import": "^0.18.2",
"unplugin-auto-import": "^0.18.3",
"unplugin-vue-components": "^0.27.4",
"unplugin-vue-setup-extend-plus": "^1.0.0",
"vite": "^5.3.1",

View File

@@ -13,7 +13,6 @@
defineOptions({
name: "App",
});
import { onMounted, reactive, computed } from "vue";
import { useI18n } from "vue-i18n";
import { getBrowserLang } from "@/utils";
import { useTheme } from "@/hooks/useTheme";

View File

@@ -23,7 +23,6 @@
</el-dialog>
</template>
<script lang="ts" setup>
import { ref, onMounted, defineExpose } from "vue";
const dialogVisible = ref<Boolean>(false);
const dialogTitle = ref<string>("");
const openDialog = (title: string) => {

View File

@@ -333,7 +333,7 @@ defineExpose({
});
</script>
<style lang="scss" scoped>
::v-deep .custom-table-header .el-table__header-wrapper .el-table__header{
:deep(.custom-table-header .el-table__header-wrapper .el-table__header){
background-color: red !important; /* 修改为你想要的颜色 */
}
</style>

View File

@@ -3,14 +3,6 @@
<div class="pie" ref="chartsRef"></div>
</template>
<script lang="ts" setup>
import {
ref,
onMounted,
defineProps,
defineExpose,
watch,
onUnmounted,
} from "vue";
import * as echarts from "echarts";
const chartsRef = ref();
const props = defineProps({

1780
frontend/src/types/auto-imports.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -7,12 +7,12 @@ export {}
/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
403: typeof import('./src/components/ErrorMessage/403.vue')['default']
404: typeof import('./src/components/ErrorMessage/404.vue')['default']
500: typeof import('./src/components/ErrorMessage/500.vue')['default']
ColSetting: typeof import('./src/components/ProTable/components/ColSetting.vue')['default']
Default: typeof import('./src/components/echarts/pie/default.vue')['default']
Dialog: typeof import('./src/components/Dialog/index.vue')['default']
403: typeof import('../components/ErrorMessage/403.vue')['default']
404: typeof import('../components/ErrorMessage/404.vue')['default']
500: typeof import('../components/ErrorMessage/500.vue')['default']
ColSetting: typeof import('../components/ProTable/components/ColSetting.vue')['default']
Default: typeof import('../components/echarts/pie/default.vue')['default']
Dialog: typeof import('../components/Dialog/index.vue')['default']
ElAside: typeof import('element-plus/es')['ElAside']
ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb']
ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem']
@@ -57,18 +57,18 @@ declare module 'vue' {
ElTimePicker: typeof import('element-plus/es')['ElTimePicker']
ElTooltip: typeof import('element-plus/es')['ElTooltip']
ElTree: typeof import('element-plus/es')['ElTree']
Grid: typeof import('./src/components/Grid/index.vue')['default']
GridItem: typeof import('./src/components/Grid/components/GridItem.vue')['default']
ImportExcel: typeof import('./src/components/ImportExcel/index.vue')['default']
Loading: typeof import('./src/components/Loading/index.vue')['default']
Pagination: typeof import('./src/components/ProTable/components/Pagination.vue')['default']
ProTable: typeof import('./src/components/ProTable/index.vue')['default']
Grid: typeof import('../components/Grid/index.vue')['default']
GridItem: typeof import('../components/Grid/components/GridItem.vue')['default']
ImportExcel: typeof import('../components/ImportExcel/index.vue')['default']
Loading: typeof import('../components/Loading/index.vue')['default']
Pagination: typeof import('../components/ProTable/components/Pagination.vue')['default']
ProTable: typeof import('../components/ProTable/index.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
SearchForm: typeof import('./src/components/SearchForm/index.vue')['default']
SearchFormItem: typeof import('./src/components/SearchForm/components/SearchFormItem.vue')['default']
SvgIcon: typeof import('./src/components/staticExtend/SvgIcon/src/SvgIcon.vue')['default']
SwitchDark: typeof import('./src/components/SwitchDark/index.vue')['default']
TableColumn: typeof import('./src/components/ProTable/components/TableColumn.vue')['default']
SearchForm: typeof import('../components/SearchForm/index.vue')['default']
SearchFormItem: typeof import('../components/SearchForm/components/SearchFormItem.vue')['default']
SvgIcon: typeof import('../components/staticExtend/SvgIcon/src/SvgIcon.vue')['default']
SwitchDark: typeof import('../components/SwitchDark/index.vue')['default']
TableColumn: typeof import('../components/ProTable/components/TableColumn.vue')['default']
}
}

View File

@@ -1,41 +1,11 @@
/* Menu */
declare namespace Menu {
interface MenuOptions {
path: string;
name: string;
component?: string | (() => Promise<unknown>);
redirect?: string;
meta: MetaProps;
children?: MenuOptions[];
}
interface MetaProps {
icon: string;
title: string;
activeMenu?: string;
isLink?: string;
isHide: boolean;
isFull: boolean;
isAffix: boolean;
isKeepAlive: boolean;
}
declare module "*.vue" {
import { DefineComponent } from "vue";
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>;
export default component;
}
/* FileType */
declare namespace File {
type ImageMimeType =
| "image/apng"
| "image/bmp"
| "image/gif"
| "image/jpeg"
| "image/pjpeg"
| "image/png"
| "image/svg+xml"
| "image/tiff"
| "image/webp"
| "image/x-icon";
type ExcelMimeType = "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
}
/* Vite */
declare type Recordable<T = any> = Record<string, T>;

39
frontend/src/types/global.d.ts vendored Normal file
View File

@@ -0,0 +1,39 @@
/* Menu */
declare namespace Menu {
interface MenuOptions {
path: string;
name: string;
component?: string | (() => Promise<unknown>);
redirect?: string;
meta: MetaProps;
children?: MenuOptions[];
}
interface MetaProps {
icon: string;
title: string;
activeMenu?: string;
isLink?: string;
isHide: boolean;
isFull: boolean;
isAffix: boolean;
isKeepAlive: boolean;
}
}
/* FileType */
declare namespace File {
type ImageMimeType =
| "image/apng"
| "image/bmp"
| "image/gif"
| "image/jpeg"
| "image/pjpeg"
| "image/png"
| "image/svg+xml"
| "image/tiff"
| "image/webp"
| "image/x-icon";
type ExcelMimeType = "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
}

View File

@@ -127,22 +127,12 @@
</template>
<script setup lang="tsx" name="useProTable">
import { ref, reactive, onMounted } from "vue";
import { useRouter } from "vue-router";
import { User } from "@/api/interface";
import { useHandleData } from "@/hooks/useHandleData";
import { useDownload } from "@/hooks/useDownload";
import { ElMessage, ElMessageBox } from "element-plus";
import ProTable from "@/components/ProTable/index.vue";
import ImportExcel from "@/components/ImportExcel/index.vue";
import {
CirclePlus,
Delete,
EditPen,
Download,
Upload,
View,
Refresh,
Search,
} from "@element-plus/icons-vue";
import { getPlanList } from "@/api/plan/planList";
@@ -544,9 +534,6 @@ defineExpose({ changeActiveTabs });
width: 150px !important;
}
}
// ::v-deep .el-select {
// width: 150px !important;
// }
.el-form {
width: 100%;

View File

@@ -30,7 +30,6 @@
</div>
</template>
<script lang="ts" setup>
import { ref, onMounted, defineExpose, watch } from "vue";
import { Menu,Platform} from "@element-plus/icons-vue";
const emit = defineEmits(["jump"]);
const data: any = ref([]);

View File

@@ -30,10 +30,9 @@
</div> -->
</template>
<script lang="ts" setup>
import { ref, onMounted } from "vue";
import { useRouter } from "vue-router";
import { ElMessage } from "element-plus";
import { useAuthStore } from "@/stores/modules/auth.ts";
import { useAuthStore } from "@/stores/modules/auth";
import model from "./tabs/model.vue";
import dashboard from "./tabs/dashboard.vue";
const authStore = useAuthStore();

View File

@@ -83,14 +83,12 @@
</div>
</template>
<script lang="ts" setup>
import { ref, onMounted, watch } from "vue";
import { getStaticTreeData } from "@/api/plan/static";
import pie from "@/components/echarts/pie/default.vue";
import { useRouter } from "vue-router";
import tree from "../components/tree.vue";
import Table from "../components/table.vue";
import { data } from "@/api/plan/static.json";
import { Refresh, Search } from "@element-plus/icons-vue";
const treeRef = ref();
const form: any = ref({
activeTabs: 0, //功能选择

View File

@@ -33,10 +33,9 @@
</div>
</template>
<script lang="ts" setup>
import { ref, onMounted } from "vue";
import { useRouter } from "vue-router";
import { ElMessage } from "element-plus";
import { useAuthStore } from "@/stores/modules/auth.ts";
import { useAuthStore } from "@/stores/modules/auth";
const authStore = useAuthStore();
const activeIndex = ref("1-1");
const router = useRouter();
@@ -234,7 +233,7 @@ onMounted(() => {
}
}
}
::v-deep .el-sub-menu__title {
:deep(.el-sub-menu__title) {
border-bottom: 0 !important;
outline: none !important;
}

View File

@@ -53,7 +53,6 @@
</template>
<script setup lang="ts">
import { ref, reactive, onMounted } from "vue";
import { useRouter } from "vue-router";
import { HOME_URL } from "@/config";
import { getTimeState } from "@/utils";

View File

@@ -19,7 +19,6 @@
<script setup lang="ts" name="login">
import LoginForm from "./components/LoginForm.vue";
import SwitchDark from "@/components/SwitchDark/index.vue";
const title = import.meta.env.VITE_GLOB_APP_TITLE;
</script>

View File

@@ -2,7 +2,6 @@
<div>检测脚本</div>
</template>
<script lang='ts' setup>
import {ref,onMounted} from 'vue';
onMounted(()=>{
console.log()
})

View File

@@ -2,7 +2,6 @@
<div class="detection"></div>
</template>
<script lang="ts" setup>
import { ref, onMounted } from "vue";
onMounted(() => {
console.log();
});

View File

@@ -105,7 +105,6 @@
</el-dialog>
</template>
<script lang="ts" setup>
import { ref,reactive,onMounted, defineExpose } from "vue";
import type { ComponentSize, FormInstance, FormRules } from 'element-plus'
interface RuleForm {

View File

@@ -148,7 +148,6 @@
</template>
<script setup lang="tsx" name="useProTable">
import { ref, reactive, onMounted } from "vue";
import { useRouter } from "vue-router";
import { User } from "@/api/interface";
import { useHandleData } from "@/hooks/useHandleData";
@@ -452,7 +451,8 @@ onMounted(() => {
width: 100%;
height: calc(100vh - 165px);
}
::v-deep .el-select {
:deep(.el-select) {
width: 150px !important;
}

View File

@@ -38,6 +38,8 @@
"src/**/*.d.ts",
"src/**/*.tsx",
"src/**/*.vue",
"build/**/*.ts",
"build/**/*.d.ts",
"vite.config.ts"
],
"exclude": ["node_modules", "dist", "**/*.js"]

View File

@@ -2,6 +2,7 @@ import { defineConfig, loadEnv, ConfigEnv, UserConfig } from "vite";
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
import vue from "@vitejs/plugin-vue";
import path from "path";
// 处理env环境参数读取
import { wrapperEnv } from "./build/getEnv";
import { createProxy } from "./build/proxy";
// 导入
@@ -23,18 +24,39 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
symbolId: "icon-[dir]-[name]",
}),
AutoImport({
// 自动导入 Vue 相关函数ref, reactive, toRef 等
imports: ["vue", "@vueuse/core", "pinia", "vue-router", "vue-i18n"],
resolvers: [
// 自动导入 Element Plus 相关函数ElMessage, ElMessageBox... (带样式)
ElementPlusResolver({
importStyle: "sass",
}),
],
eslintrc: {
// 是否自动生成 eslint 规则,建议生成之后设置 false
enabled: false,
// 指定自动导入函数 eslint 规则的文件
filepath: "./.eslintrc-auto-import.json",
globalsPropValue: true,
},
// 是否在 vue 模板中自动导入
vueTemplate: true,
// 指定自动导入函数TS类型声明文件路径 (false:关闭自动生成)
dts: false,
// dts: "src/types/auto-imports.d.ts",
}),
Components({
resolvers: [
// 自动导入 Element Plus 组件
ElementPlusResolver({
importStyle: "sass",
}),
],
// 指定自定义组件位置(默认:src/components)
dirs: ["src/components", "src/**/components"],
// 指定自动导入组件TS类型声明文件路径 (false:关闭自动生成)
dts: false,
// dts: "src/types/components.d.ts",
}),
// 增加此行代码
vueJsx(),