Kaynağa Gözat

update .gitignor

bzkf30 2 yıl önce
ebeveyn
işleme
e3460c44f7

+ 1 - 1
.gitignore

@@ -1,3 +1,3 @@
 /node_modules/
 .idea/
-src/*.d.ts
+src/*.d.ts

+ 0 - 12
.idea/tyyx_manager.iml

@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module type="WEB_MODULE" version="4">
-  <component name="NewModuleRootManager">
-    <content url="file://$MODULE_DIR$">
-      <excludeFolder url="file://$MODULE_DIR$/temp" />
-      <excludeFolder url="file://$MODULE_DIR$/.tmp" />
-      <excludeFolder url="file://$MODULE_DIR$/tmp" />
-    </content>
-    <orderEntry type="inheritedJdk" />
-    <orderEntry type="sourceFolder" forTests="false" />
-  </component>
-</module>

+ 20 - 20
src/components/AppLink/index.vue

@@ -1,20 +1,20 @@
-<script setup lang="ts">
-import { isExternal } from '~/utils/validate';
-import { useRouter } from 'vue-router';
-const router = useRouter()
-const props = defineProps<{ to: string }>()
-
-const linkTo = () => {
-  router.push({ name: props.to })
-}
-</script>
-
-
-<template>
-  <a v-if="isExternal(props.to)" :href="props.to" target='_blank'>
-    <slot></slot>
-  </a>
-  <div v-else @click="linkTo">
-    <slot></slot>
-  </div>
-</template>
+<script setup lang="ts">
+import { isExternal } from '~/utils/validate';
+import { useRouter } from 'vue-router';
+const router = useRouter()
+const props = defineProps<{ to: string }>()
+
+const linkTo = () => {
+  router.push({ name: props.to })
+}
+</script>
+
+
+<template>
+  <a v-if="isExternal(props.to)" :href="props.to" target='_blank'>
+    <slot></slot>
+  </a>
+  <div v-else @click="linkTo">
+    <slot></slot>
+  </div>
+</template>

+ 28 - 28
src/components/FileLink/index.vue

@@ -1,28 +1,28 @@
-<script setup lang="ts">
-
-import { ref } from 'vue';
-
-
-
-const props = defineProps<{
-    file: string,
-}>()
-
-const files = ref(props.file.split(";").map(str => {
-    const [part, name] = str.split("|")
-    return {
-        url: window.GLOBAL_CONFIG.oss + part,
-        name: name ?? part
-    }
-}))
-
-</script>
-
-<template>
-    <div class="flex flex-col">
-        <div v-for="({ name, url }) in files" class="w-full">
-            <el-link type="primary" :href="url">{{ name }}</el-link>
-        </div>
-    </div>
-</template>
-
+<script setup lang="ts">
+
+import { ref } from 'vue';
+
+
+
+const props = defineProps<{
+    file: string,
+}>()
+
+const files = ref(props.file.split(";").map(str => {
+    const [part, name] = str.split("|")
+    return {
+        url: window.GLOBAL_CONFIG.oss + part,
+        name: name ?? part
+    }
+}))
+
+</script>
+
+<template>
+    <div class="flex flex-col">
+        <div v-for="({ name, url }) in files" class="w-full">
+            <el-link type="primary" :href="url">{{ name }}</el-link>
+        </div>
+    </div>
+</template>
+

+ 161 - 161
src/components/FileUpload/index.vue

@@ -1,161 +1,161 @@
-<script setup lang="ts">
-import { ElMessage } from 'element-plus';
-import { ref, useAttrs, watch } from 'vue';
-import request from '~/utils/request';
-import type { AxiosRequestConfig } from 'axios';
-import dayjs from 'dayjs'
-
-const emit = defineEmits(['update:part', 'update:full', 'update:size', 'update:time'])
-
-const props = defineProps<{
-    part?: string,
-    full?: string,
-    sizeLimit?: number,
-    size?: string,
-    time?: string,
-}>()
-
-const attrs = useAttrs()
-
-const List_part = ref(props.part)
-const List_full = ref(props.full)
-// const List_size = ref(props.size ? parseFloat(props.size) : 0)
-const List_size = ref(0)
-const List_time = ref(props.time ?? dayjs().format('YYYY-MM-DD HH:mm:ss'))
-
-type File_Item = {
-    part_url: string,
-    url: string,
-    _status: number,
-    uid: number,
-    name?: string,
-    size?: number
-}
-const FILE_LIST = ref<File_Item[]>([])
-
-if (List_part.value !== undefined && List_part.value !== '' && List_part.value !== null) {
-    FILE_LIST.value = List_part.value.split(';').map((part_url, idx) => ({
-        part_url,
-        url: window.GLOBAL_CONFIG.oss + part_url,
-        _status: 1,
-        uid: Date.now() - idx,
-        name: part_url.split('/').pop()
-    }))
-}
-if (List_full.value !== undefined && List_full.value !== '' && List_full.value !== null) {
-    FILE_LIST.value = List_full.value.split(';').map((item, idx) => {
-        const [part_url, name] = item.split('|')
-        return ({
-            part_url,
-            url: window.GLOBAL_CONFIG.oss + part_url,
-            _status: 1,
-            name,
-            uid: Date.now() - idx
-        })
-    })
-}
-
-/**
-    * const STATUS_MAP = {
-    *   0: 'READY',
-    *   1: 'SUCCESS',
-    *   2: 'FAIL'
-    * }
-*/
-
-function beforeUpload(file: File) {
-    if (props.sizeLimit) {
-        const isLtSize = file.size / 1024 / 1024 < props.sizeLimit;
-        if (!isLtSize) {
-            ElMessage.warning(`上传文件大小不能超过 ${props.sizeLimit}MB!`);
-        }
-        return isLtSize;
-    }
-}
-
-const httpRequest = ({ file }: { file: File & { uid: number } }) => {
-    return request({
-        $type: 'upload',
-        url: 'upload/main/file',
-        data: {
-            filedata: file
-        },
-        timeout: 1000 * 60
-    } as AxiosRequestConfig)
-        .then(({ code, data }) => {
-            if (code === '1') {
-                const { url: part_url, file_name } = data
-                const target = FILE_LIST.value.find(({ uid }) => uid === file.uid);
-                if (target === undefined) {
-                    throw new Error("file is not exist");
-                } else {
-                    target._status = 1
-                    target.url = window.GLOBAL_CONFIG.oss + part_url
-                    target.part_url = part_url
-                    target.name = file_name
-                    handleSuccess()
-                }
-            } else {
-                return Promise.reject()
-            }
-        })
-}
-
-function handleSuccess() {
-    if (FILE_LIST.value.every(item => item._status === 1)) {
-        let part: string[] = [];
-        let full: string[] = [];
-        FILE_LIST.value.forEach(item => {
-            part.push(item.part_url);
-            full.push(`${item.part_url}|${item.name}`);
-            List_size.value += item.size ?? 0
-        })
-        List_full.value = full.join(';')
-        List_part.value = part.join(';')
-        List_time.value = dayjs().format('YYYY-MM-DD HH:mm:ss')
-    }
-}
-
-function onRemove(file: unknown, fileList: File_Item[]) {
-    FILE_LIST.value = fileList
-    handleSuccess()
-}
-function onExceed() {
-    ElMessage.warning(`最多允许上传${attrs.limit}个文件`)
-}
-
-/// <summary>
-/// 格式化文件大小的JS方法
-/// </summary>
-/// <param name="filesize">文件的大小,传入的是一个bytes为单位的参数</param>
-/// <returns>格式化后的值</returns>
-function renderSize(filesize: number): string {
-    // const unitArr = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
-    // const index = Math.floor(Math.log(filesize) / Math.log(1024));
-    // const size = (filesize / Math.pow(1024, index)).toFixed(2);
-    // return size + unitArr[index];
-    return (filesize / 1024).toString()
-}
-
-watch(() => List_part.value, () => {
-    emit('update:part', List_part.value)
-    emit('update:full', List_full.value)
-    emit('update:size', renderSize(List_size.value))
-    emit('update:time', List_time.value)
-})
-</script>
-
-<template>
-    <el-upload action="#" :http-request="httpRequest" :on-remove="onRemove" :on-exceed="onExceed"
-        :before-upload="beforeUpload" :file-list="FILE_LIST" v-bind="attrs" class="w-100">
-        <template #default>
-            <slot>
-                <el-button type="primary">点击上传</el-button>
-            </slot>
-        </template>
-        <template #tip>
-            <slot name="tip"></slot>
-        </template>
-    </el-upload>
-</template>
-
+<script setup lang="ts">
+import { ElMessage } from 'element-plus';
+import { ref, useAttrs, watch } from 'vue';
+import request from '~/utils/request';
+import type { AxiosRequestConfig } from 'axios';
+import dayjs from 'dayjs'
+
+const emit = defineEmits(['update:part', 'update:full', 'update:size', 'update:time'])
+
+const props = defineProps<{
+    part?: string,
+    full?: string,
+    sizeLimit?: number,
+    size?: string,
+    time?: string,
+}>()
+
+const attrs = useAttrs()
+
+const List_part = ref(props.part)
+const List_full = ref(props.full)
+// const List_size = ref(props.size ? parseFloat(props.size) : 0)
+const List_size = ref(0)
+const List_time = ref(props.time ?? dayjs().format('YYYY-MM-DD HH:mm:ss'))
+
+type File_Item = {
+    part_url: string,
+    url: string,
+    _status: number,
+    uid: number,
+    name?: string,
+    size?: number
+}
+const FILE_LIST = ref<File_Item[]>([])
+
+if (List_part.value !== undefined && List_part.value !== '' && List_part.value !== null) {
+    FILE_LIST.value = List_part.value.split(';').map((part_url, idx) => ({
+        part_url,
+        url: window.GLOBAL_CONFIG.oss + part_url,
+        _status: 1,
+        uid: Date.now() - idx,
+        name: part_url.split('/').pop()
+    }))
+}
+if (List_full.value !== undefined && List_full.value !== '' && List_full.value !== null) {
+    FILE_LIST.value = List_full.value.split(';').map((item, idx) => {
+        const [part_url, name] = item.split('|')
+        return ({
+            part_url,
+            url: window.GLOBAL_CONFIG.oss + part_url,
+            _status: 1,
+            name,
+            uid: Date.now() - idx
+        })
+    })
+}
+
+/**
+    * const STATUS_MAP = {
+    *   0: 'READY',
+    *   1: 'SUCCESS',
+    *   2: 'FAIL'
+    * }
+*/
+
+function beforeUpload(file: File) {
+    if (props.sizeLimit) {
+        const isLtSize = file.size / 1024 / 1024 < props.sizeLimit;
+        if (!isLtSize) {
+            ElMessage.warning(`上传文件大小不能超过 ${props.sizeLimit}MB!`);
+        }
+        return isLtSize;
+    }
+}
+
+const httpRequest = ({ file }: { file: File & { uid: number } }) => {
+    return request({
+        $type: 'upload',
+        url: 'upload/main/file',
+        data: {
+            filedata: file
+        },
+        timeout: 1000 * 60
+    } as AxiosRequestConfig)
+        .then(({ code, data }) => {
+            if (code === '1') {
+                const { url: part_url, file_name } = data
+                const target = FILE_LIST.value.find(({ uid }) => uid === file.uid);
+                if (target === undefined) {
+                    throw new Error("file is not exist");
+                } else {
+                    target._status = 1
+                    target.url = window.GLOBAL_CONFIG.oss + part_url
+                    target.part_url = part_url
+                    target.name = file_name
+                    handleSuccess()
+                }
+            } else {
+                return Promise.reject()
+            }
+        })
+}
+
+function handleSuccess() {
+    if (FILE_LIST.value.every(item => item._status === 1)) {
+        let part: string[] = [];
+        let full: string[] = [];
+        FILE_LIST.value.forEach(item => {
+            part.push(item.part_url);
+            full.push(`${item.part_url}|${item.name}`);
+            List_size.value += item.size ?? 0
+        })
+        List_full.value = full.join(';')
+        List_part.value = part.join(';')
+        List_time.value = dayjs().format('YYYY-MM-DD HH:mm:ss')
+    }
+}
+
+function onRemove(file: unknown, fileList: File_Item[]) {
+    FILE_LIST.value = fileList
+    handleSuccess()
+}
+function onExceed() {
+    ElMessage.warning(`最多允许上传${attrs.limit}个文件`)
+}
+
+/// <summary>
+/// 格式化文件大小的JS方法
+/// </summary>
+/// <param name="filesize">文件的大小,传入的是一个bytes为单位的参数</param>
+/// <returns>格式化后的值</returns>
+function renderSize(filesize: number): string {
+    // const unitArr = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
+    // const index = Math.floor(Math.log(filesize) / Math.log(1024));
+    // const size = (filesize / Math.pow(1024, index)).toFixed(2);
+    // return size + unitArr[index];
+    return (filesize / 1024).toString()
+}
+
+watch(() => List_part.value, () => {
+    emit('update:part', List_part.value)
+    emit('update:full', List_full.value)
+    emit('update:size', renderSize(List_size.value))
+    emit('update:time', List_time.value)
+})
+</script>
+
+<template>
+    <el-upload action="#" :http-request="httpRequest" :on-remove="onRemove" :on-exceed="onExceed"
+        :before-upload="beforeUpload" :file-list="FILE_LIST" v-bind="attrs" class="w-100">
+        <template #default>
+            <slot>
+                <el-button type="primary">点击上传</el-button>
+            </slot>
+        </template>
+        <template #tip>
+            <slot name="tip"></slot>
+        </template>
+    </el-upload>
+</template>
+

+ 0 - 19
src/env.d.ts

@@ -1,19 +0,0 @@
-/// <reference types="vite/client" />
-
-declare module '*.vue' {
-  import type { DefineComponent } from 'vue'
-  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
-  const component: DefineComponent<{}, {}, any>
-  export default component
-}
-
-
-
-interface Window {
-  GLOBAL_CONFIG: {
-    api: string;
-    oss: string
-  },
-  cpm_id: string
-}
-

+ 10 - 10
src/layout/app/components/AppHeader/index.vue

@@ -1,10 +1,10 @@
-<script setup lang="ts">
-import {ref} from 'vue';
-const APP_TITLE = ref(document.title)
-</script>
-
-<template>
-  <div class="header w-full h-50px leading-50px line px-8 text-xl text-white tracking-wider">{{ APP_TITLE }}</div>
-</template>
-
-
+<script setup lang="ts">
+import {ref} from 'vue';
+const APP_TITLE = ref(document.title)
+</script>
+
+<template>
+  <div class="header w-full h-50px leading-50px line px-8 text-xl text-white tracking-wider">{{ APP_TITLE }}</div>
+</template>
+
+

+ 66 - 66
src/layout/app/components/AppSider/MenuItem.vue

@@ -1,66 +1,66 @@
-<script setup lang="ts">
-import Item from './Item.vue'
-import MenuItem from './MenuItem.vue';
-import type { RouteRecordDetailRaw } from '~/router/routes.d'
-import { ref } from 'vue';
-
-
-const props = defineProps<{
-  item: RouteRecordDetailRaw
-}>()
-
-const currentRoute: RouteRecordDetailRaw = props.item
-const showRoute = ref<RouteRecordDetailRaw>(currentRoute)
-
-const showMode = ref<number>(0)
-
-function filterShowChild(children?: RouteRecordDetailRaw[]): RouteRecordDetailRaw[] {
-  if (Array.isArray(children)) {
-    const temp = children.filter(child => !child.meta.hidden).sort((a, b) => a.meta.sort - b.meta.sort)
-    if (temp.length === 1 && Array.isArray(temp[0].children)) {
-      return filterShowChild(temp[0].children)
-    }
-    return temp
-  }
-  else {
-    return []
-  }
-}
-const currentRouteShowChildren = filterShowChild(currentRoute.children)
-
-if (currentRouteShowChildren.length === 0) {
-  showMode.value = 1
-}
-else if (currentRouteShowChildren.length === 1) {
-  showRoute.value = currentRouteShowChildren[0]
-  showMode.value = 1
-}
-else {
-  showMode.value = 2
-}
-
-</script>
-
-<template>
-  <template v-if="!item?.meta?.hidden">
-    <template v-if="showMode === 1">
-      <AppLink :to="showRoute.name">
-        <el-menu-item :index="showRoute.name">
-          <Item :icon="showRoute?.meta?.icon" :title="showRoute?.meta?.title"></Item>
-        </el-menu-item>
-      </AppLink>
-    </template>
-
-    <template v-if="showMode === 2">
-      <el-sub-menu :index="showRoute.name">
-        <template #title>
-          <Item :icon="showRoute?.meta?.icon" :title="showRoute.meta.title"></Item>
-        </template>
-
-        <MenuItem v-for="route in showRoute.children" :item="route" />
-
-      </el-sub-menu>
-    </template>
-  </template>
-
-</template>
+<script setup lang="ts">
+import Item from './Item.vue'
+import MenuItem from './MenuItem.vue';
+import type { RouteRecordDetailRaw } from '~/router/routes.d'
+import { ref } from 'vue';
+
+
+const props = defineProps<{
+  item: RouteRecordDetailRaw
+}>()
+
+const currentRoute: RouteRecordDetailRaw = props.item
+const showRoute = ref<RouteRecordDetailRaw>(currentRoute)
+
+const showMode = ref<number>(0)
+
+function filterShowChild(children?: RouteRecordDetailRaw[]): RouteRecordDetailRaw[] {
+  if (Array.isArray(children)) {
+    const temp = children.filter(child => !child.meta.hidden).sort((a, b) => a.meta.sort - b.meta.sort)
+    if (temp.length === 1 && Array.isArray(temp[0].children)) {
+      return filterShowChild(temp[0].children)
+    }
+    return temp
+  }
+  else {
+    return []
+  }
+}
+const currentRouteShowChildren = filterShowChild(currentRoute.children)
+
+if (currentRouteShowChildren.length === 0) {
+  showMode.value = 1
+}
+else if (currentRouteShowChildren.length === 1) {
+  showRoute.value = currentRouteShowChildren[0]
+  showMode.value = 1
+}
+else {
+  showMode.value = 2
+}
+
+</script>
+
+<template>
+  <template v-if="!item?.meta?.hidden">
+    <template v-if="showMode === 1">
+      <AppLink :to="showRoute.name">
+        <el-menu-item :index="showRoute.name">
+          <Item :icon="showRoute?.meta?.icon" :title="showRoute?.meta?.title"></Item>
+        </el-menu-item>
+      </AppLink>
+    </template>
+
+    <template v-if="showMode === 2">
+      <el-sub-menu :index="showRoute.name">
+        <template #title>
+          <Item :icon="showRoute?.meta?.icon" :title="showRoute.meta.title"></Item>
+        </template>
+
+        <MenuItem v-for="route in showRoute.children" :item="route" />
+
+      </el-sub-menu>
+    </template>
+  </template>
+
+</template>

+ 33 - 33
src/layout/app/components/AppSider/index.vue

@@ -1,33 +1,33 @@
-<script setup lang="ts">
-import { ref, computed, watch } from 'vue';
-import { useRouter, useRoute } from 'vue-router';
-import type { RouteRecordDetailRaw } from '~/router/routes.d'
-import MenuItem from './MenuItem.vue';
-import { app_routes } from '~/store/app';
-
-const router = useRouter()
-const route = useRoute()
-
-const allRoutes = computed(() => {
-  const routes: RouteRecordDetailRaw[] = JSON.parse(sessionStorage.getItem('routes') as string)
-  return routes.sort((a, b) => a.meta.sort - b.meta.sort)
-})
-const index = computed(() => {
-  const reservedMatched = [...route?.matched].reverse()
-  for (const r of reservedMatched) {
-    if (!r.meta.hidden) {
-      return ((r?.redirect as { name: string })?.name) ?? r.name
-    }
-  }
-})
-
-</script>
-
-<template>
-  <el-menu class="h-full border-none" :default-active="index">
-    <MenuItem v-for="route in allRoutes" :item="route">
-    </MenuItem>
-  </el-menu>
-</template>
-
-
+<script setup lang="ts">
+import { ref, computed, watch } from 'vue';
+import { useRouter, useRoute } from 'vue-router';
+import type { RouteRecordDetailRaw } from '~/router/routes.d'
+import MenuItem from './MenuItem.vue';
+import { app_routes } from '~/store/app';
+
+const router = useRouter()
+const route = useRoute()
+
+const allRoutes = computed(() => {
+  const routes: RouteRecordDetailRaw[] = JSON.parse(sessionStorage.getItem('routes') as string)
+  return routes.sort((a, b) => a.meta.sort - b.meta.sort)
+})
+const index = computed(() => {
+  const reservedMatched = [...route?.matched].reverse()
+  for (const r of reservedMatched) {
+    if (!r.meta.hidden) {
+      return ((r?.redirect as { name: string })?.name) ?? r.name
+    }
+  }
+})
+
+</script>
+
+<template>
+  <el-menu class="h-full border-none" :default-active="index">
+    <MenuItem v-for="route in allRoutes" :item="route">
+    </MenuItem>
+  </el-menu>
+</template>
+
+

+ 10 - 10
src/layout/app/components/AppSider/item.vue

@@ -1,10 +1,10 @@
-<script setup lang="ts">
-const props = defineProps<{
-  icon?: string,
-  title?: string
-}>()
-</script>
-
-<template>
-  <span>{{ props.title }}</span>
-</template>
+<script setup lang="ts">
+const props = defineProps<{
+  icon?: string,
+  title?: string
+}>()
+</script>
+
+<template>
+  <span>{{ props.title }}</span>
+</template>

+ 35 - 35
src/layout/app/index.vue

@@ -1,35 +1,35 @@
-<script setup lang="ts">
-import AppHeader from './components/AppHeader/index.vue';
-import AppSider from './components/AppSider/index.vue';
-
-// import Breadcrumb from '~/components/Breadcrumb/index.vue';
-// import AppMain from './components/AppMain/index.vue';
-</script>
-
-<template>
-
-  <div class="flex flex-col w-screen h-screen">
-    <header class="w-full flex-none bg-hex-00A3FF">
-      <AppHeader></AppHeader>
-    </header>
-    <div class="w-full flex-auto flex flex-row overflow-hidden relative">
-      <aside class="w-210px flex-none h-full border">
-        <el-scrollbar view-class="h-full">
-          <AppSider></AppSider>
-        </el-scrollbar>
-      </aside>
-      <div class="divide-x"></div>
-      <main class="flex-auto flex flex-col overflow-hidden">
-        <div class="w-full h-full">
-          <!-- <Breadcrumb class="flex-none mb-4"></Breadcrumb> -->
-
-          <el-scrollbar always wrap-class="w-full h-full box-border" view-class="relative h-full flex flex-col p-4">
-            <router-view></router-view>
-          </el-scrollbar>
-        </div>
-      </main>
-    </div>
-  </div>
-
-</template>
-
+<script setup lang="ts">
+import AppHeader from './components/AppHeader/index.vue';
+import AppSider from './components/AppSider/index.vue';
+
+// import Breadcrumb from '~/components/Breadcrumb/index.vue';
+// import AppMain from './components/AppMain/index.vue';
+</script>
+
+<template>
+
+  <div class="flex flex-col w-screen h-screen">
+    <header class="w-full flex-none bg-hex-00A3FF">
+      <AppHeader></AppHeader>
+    </header>
+    <div class="w-full flex-auto flex flex-row overflow-hidden relative">
+      <aside class="w-210px flex-none h-full border">
+        <el-scrollbar view-class="h-full">
+          <AppSider></AppSider>
+        </el-scrollbar>
+      </aside>
+      <div class="divide-x"></div>
+      <main class="flex-auto flex flex-col overflow-hidden">
+        <div class="w-full h-full">
+          <!-- <Breadcrumb class="flex-none mb-4"></Breadcrumb> -->
+
+          <el-scrollbar always wrap-class="w-full h-full box-border" view-class="relative h-full flex flex-col p-4">
+            <router-view></router-view>
+          </el-scrollbar>
+        </div>
+      </main>
+    </div>
+  </div>
+
+</template>
+

+ 9 - 9
src/utils/validate.ts

@@ -1,9 +1,9 @@
-/**
- * @param {string} path
- * @returns {Boolean}
- */
-export function isExternal(path: string) {
-  return /^(https?:|mailto:|tel:)/.test(path)
-}
-
-
+/**
+ * @param {string} path
+ * @returns {Boolean}
+ */
+export function isExternal(path: string) {
+  return /^(https?:|mailto:|tel:)/.test(path)
+}
+
+