@@ -39,7 +37,7 @@ export default defineComponent({
};
if (e.type == 0) {
- html = h(
+ return h(
,
{
index: String(e.id),
@@ -56,7 +54,7 @@ export default defineComponent({
}
);
} else {
- html = h(
+ return h(
,
{
index:
@@ -75,7 +73,6 @@ export default defineComponent({
);
}
- return html;
});
}
diff --git a/src/modules/base/pages/main/components/process.vue b/src/modules/base/pages/main/components/process.vue
index ca62900..f505d01 100644
--- a/src/modules/base/pages/main/components/process.vue
+++ b/src/modules/base/pages/main/components/process.vue
@@ -144,7 +144,7 @@ watch(
onMounted(() => {
// 添加滚轮事件监听器
- refs.scroller.wrapRef.addEventListener("wheel", function (event: WheelEvent) {
+ refs.scroller.wrapRef?.addEventListener("wheel", function (event: WheelEvent) {
// 阻止默认滚动行为
event.preventDefault();
diff --git a/src/modules/base/static/css/index.scss b/src/modules/base/static/css/index.scss
index 2c13859..d5831e5 100644
--- a/src/modules/base/static/css/index.scss
+++ b/src/modules/base/static/css/index.scss
@@ -23,5 +23,4 @@ input {
}
}
-@import "./theme.scss";
@import "./animation.scss";
diff --git a/src/modules/base/views/menu/index.vue b/src/modules/base/views/menu/index.vue
index e0c4129..a0839a1 100644
--- a/src/modules/base/views/menu/index.vue
+++ b/src/modules/base/views/menu/index.vue
@@ -71,8 +71,9 @@
and: [service.base.sys.menu.permission.add, scope.row.type != 2]
}"
@click="append(scope.row)"
- >新增
+ 新增
+
@@ -209,7 +210,7 @@ const Table = useTable({
prop: "updateTime",
label: "更新时间",
sortable: "custom",
- width: 160
+ width: 170
},
{
label: "操作",
diff --git a/src/modules/helper/views/ai-code.vue b/src/modules/helper/views/ai-code.vue
index 281f4f4..520c40b 100644
--- a/src/modules/helper/views/ai-code.vue
+++ b/src/modules/helper/views/ai-code.vue
@@ -899,7 +899,7 @@ const desc = reactive({
const val = desc.list[n];
if (val) {
- function next2(n2: number) {
+ const next2 = (n2: number) => {
const v = val[n2];
if (v) {
@@ -921,7 +921,7 @@ const desc = reactive({
}
}, 1500);
}
- }
+ };
next2(0);
} else {
diff --git a/src/modules/helper/views/plugins/serve.vue b/src/modules/helper/views/plugins/serve.vue
index fc7d9c0..278655f 100644
--- a/src/modules/helper/views/plugins/serve.vue
+++ b/src/modules/helper/views/plugins/serve.vue
@@ -127,7 +127,7 @@ const tab = reactive({
if (val == "shop") {
nextTick(() => {
tab.active = "installed";
- window.open("https://cool-js.com/");
+ window.open("https://cool-js.com/plugin");
});
}
}
diff --git a/src/modules/helper/views/plugins/vue.vue b/src/modules/helper/views/plugins/vue.vue
index 4a0cb1f..18f0c2a 100644
--- a/src/modules/helper/views/plugins/vue.vue
+++ b/src/modules/helper/views/plugins/vue.vue
@@ -88,7 +88,7 @@ const tab = reactive({
if (val == "shop") {
nextTick(() => {
tab.active = "installed";
- window.open("https://cool-js.com/");
+ window.open("https://cool-js.com/plugin");
});
}
}
diff --git a/src/modules/user/components/select.vue b/src/modules/user/components/select.vue
index e1324d5..70c5aad 100644
--- a/src/modules/user/components/select.vue
+++ b/src/modules/user/components/select.vue
@@ -152,12 +152,12 @@ const Table = useTable({
type: "selection",
width: 60,
reserveSelection: true
- }
+ }
: {
label: "操作",
prop: "check",
width: 100
- },
+ },
{
prop: "avatarUrl",
label: "头像",
diff --git a/src/plugins/crud/components/select/index.tsx b/src/plugins/crud/components/select/index.tsx
index 9a6890a..af2d461 100644
--- a/src/plugins/crud/components/select/index.tsx
+++ b/src/plugins/crud/components/select/index.tsx
@@ -52,7 +52,7 @@ export default defineComponent({
const ids: any[] = [];
// 获取所有的值
- function deep(arr: Dict.Item[], f: boolean) {
+ const deep = (arr: Dict.Item[], f: boolean) => {
arr.forEach((e) => {
const f2 = e[props.valueKey] == val;
diff --git a/src/plugins/crud/config.ts b/src/plugins/crud/config.ts
index 3ad32c5..c2f3be4 100644
--- a/src/plugins/crud/config.ts
+++ b/src/plugins/crud/config.ts
@@ -10,6 +10,7 @@ import "@cool-vue/crud/dist/index.css";
export default (): Merge
=> {
return {
+ order: 100,
label: "CRUD",
description: "快速增删改查及一系列辅助组件",
author: "COOL",
diff --git a/src/plugins/echarts/config.ts b/src/plugins/echarts/config.ts
new file mode 100644
index 0000000..13ea798
--- /dev/null
+++ b/src/plugins/echarts/config.ts
@@ -0,0 +1,16 @@
+import type { ModuleConfig } from "/@/cool";
+import VueECharts from "vue-echarts";
+
+export default (): ModuleConfig => {
+ return {
+ order: 100,
+ label: "ECharts 图表",
+ description: "echarts、vue-echarts 配置",
+ author: "COOL",
+ version: "1.0.0",
+ updateTime: "2024-07-22",
+ install(app) {
+ app.component("v-chart", VueECharts);
+ }
+ };
+};
diff --git a/src/plugins/editor-monaco/utils/format.ts b/src/plugins/editor-monaco/utils/format.ts
index 352c8fa..f9791c8 100644
--- a/src/plugins/editor-monaco/utils/format.ts
+++ b/src/plugins/editor-monaco/utils/format.ts
@@ -44,7 +44,9 @@ export function useFormat() {
singleQuote: true,
trailingComma: "none"
});
- } catch (err) {}
+ } catch (err) {
+ // ...
+ }
return [
{
diff --git a/src/plugins/element-ui/config.ts b/src/plugins/element-ui/config.ts
new file mode 100644
index 0000000..c7ca379
--- /dev/null
+++ b/src/plugins/element-ui/config.ts
@@ -0,0 +1,17 @@
+import type { ModuleConfig } from "/@/cool";
+import ElementPlus from "element-plus";
+import "./css/index.scss";
+
+export default (): ModuleConfig => {
+ return {
+ order: 100,
+ label: "Element Ui",
+ description: "Element Plus 变量、样式配置",
+ author: "COOL",
+ version: "1.0.0",
+ updateTime: "2024-07-22",
+ install(app) {
+ app.use(ElementPlus);
+ }
+ };
+};
diff --git a/src/modules/base/static/css/theme.scss b/src/plugins/element-ui/css/index.scss
similarity index 77%
rename from src/modules/base/static/css/theme.scss
rename to src/plugins/element-ui/css/index.scss
index fba297d..bc5fd60 100644
--- a/src/modules/base/static/css/theme.scss
+++ b/src/plugins/element-ui/css/index.scss
@@ -1,3 +1,9 @@
+@forward "element-plus/theme-chalk/src/common/var.scss" with (
+ $scrollbar: ()
+);
+
+@use "element-plus/theme-chalk/src/index.scss" as *;
+
// Element-plus
.el-input-number {
&__decrease,
diff --git a/src/plugins/excel/components/import-btn.vue b/src/plugins/excel/components/import-btn.vue
index 4896770..4b9e42e 100644
--- a/src/plugins/excel/components/import-btn.vue
+++ b/src/plugins/excel/components/import-btn.vue
@@ -122,6 +122,7 @@ import { reactive, type PropType, computed } from "vue";
import * as XLSX from "xlsx";
import chardet from "chardet";
import { extname } from "/@/cool/utils";
+import { has } from "lodash-es";
const props = defineProps({
onConfig: Function,
@@ -286,7 +287,7 @@ function onUpload(raw: File, _: any, { next }: any) {
let json: any[] = [];
for (const sheet in workbook.Sheets) {
- if (workbook.Sheets.hasOwnProperty(sheet)) {
+ if (has(workbook.Sheets, sheet)) {
json = json.concat(XLSX.utils.sheet_to_json(workbook.Sheets[sheet]));
}
}
diff --git a/src/modules/theme/components/theme.vue b/src/plugins/theme/components/theme.vue
similarity index 100%
rename from src/modules/theme/components/theme.vue
rename to src/plugins/theme/components/theme.vue
diff --git a/src/modules/theme/config.ts b/src/plugins/theme/config.ts
similarity index 82%
rename from src/modules/theme/config.ts
rename to src/plugins/theme/config.ts
index 22dea33..1f2bc14 100644
--- a/src/modules/theme/config.ts
+++ b/src/plugins/theme/config.ts
@@ -1,12 +1,17 @@
import { setTheme } from "./utils";
import { config } from "/@/config";
import { storage, type ModuleConfig } from "/@/cool";
-
import "element-plus/theme-chalk/dark/css-vars.css";
import "./static/css/index.scss";
export default (): ModuleConfig => {
return {
+ label: "主题",
+ description: "自定义主色、菜单分组、暗黑模式",
+ author: "COOL",
+ version: "1.0.0",
+ updateTime: "2024-07-22",
+
toolbar: {
component: import("./components/theme.vue")
},
diff --git a/src/modules/theme/static/css/index.scss b/src/plugins/theme/static/css/index.scss
similarity index 100%
rename from src/modules/theme/static/css/index.scss
rename to src/plugins/theme/static/css/index.scss
diff --git a/src/modules/theme/types/index.d.ts b/src/plugins/theme/types/index.d.ts
similarity index 100%
rename from src/modules/theme/types/index.d.ts
rename to src/plugins/theme/types/index.d.ts
diff --git a/src/modules/theme/utils/index.ts b/src/plugins/theme/utils/index.ts
similarity index 100%
rename from src/modules/theme/utils/index.ts
rename to src/plugins/theme/utils/index.ts
diff --git a/src/plugins/upload/components/upload-item/index.vue b/src/plugins/upload/components/upload-item/index.vue
index f4b9701..b6a87d6 100644
--- a/src/plugins/upload/components/upload-item/index.vue
+++ b/src/plugins/upload/components/upload-item/index.vue
@@ -49,7 +49,7 @@
diff --git a/src/plugins/upload/hooks/index.ts b/src/plugins/upload/hooks/index.ts
index 0563e07..42dd782 100644
--- a/src/plugins/upload/hooks/index.ts
+++ b/src/plugins/upload/hooks/index.ts
@@ -12,168 +12,156 @@ export function useUpload() {
const { user } = useBase();
// 上传
- async function toUpload(
- file: File,
- opts: Upload.Options = {}
- ): Promise<{
- key: string;
- url: string;
- fileId: string;
- }> {
- return new Promise(async (resolve, reject) => {
- // 合并配置
- const { prefixPath, onProgress } = merge(options, opts);
+ async function toUpload(file: File, opts: Upload.Options = {}): Upload.Respose {
+ return new Promise((resolve, reject) => {
+ const executor = async () => {
+ // 合并配置
+ const { prefixPath, onProgress } = merge(options, opts);
- // 文件id
- const fileId = uuid("");
+ // 文件id
+ const fileId = uuid("");
- try {
- // 上传模式、类型
- const { mode, type } = await service.base.comm.uploadMode();
+ try {
+ // 上传模式、类型
+ const { mode, type } = await service.base.comm.uploadMode();
- // 本地上传
- const isLocal = mode == "local";
+ // 本地上传
+ const isLocal = mode == "local";
- // 文件名
- const fileName = fileId + "_" + file.name;
+ // 文件名
+ const fileName = fileId + "_" + file.name;
- // Key
- let key = isLocal ? fileName : pathJoin(prefixPath!, fileName);
+ // Key
+ let key = isLocal ? fileName : pathJoin(prefixPath!, fileName);
- // 多种上传请求
- // 上传到云端
- async function next({
- host,
- preview,
- data
- }: {
- host: string;
- preview?: string;
- data?: any;
- }) {
- const fd = new FormData();
+ // 多种上传请求
+ const next = async ({ host, preview, data }: Upload.Request) => {
+ const fd = new FormData();
- // key
- fd.append("key", key);
+ // key
+ fd.append("key", key);
- // 签名数据
- for (const i in data) {
- if (!fd.has(i)) {
- fd.append(i, data[i]);
+ // 签名数据
+ for (const i in data) {
+ if (!fd.has(i)) {
+ fd.append(i, data[i]);
+ }
}
- }
- // 文件
- fd.append("file", file);
+ // 文件
+ fd.append("file", file);
- // 上传进度
- let progress = 0;
+ // 上传进度
+ let progress = 0;
- // 上传
- await service
- .request({
- url: host,
- method: "POST",
- headers: {
- "Content-Type": "multipart/form-data",
- Authorization: isLocal ? user.token : null
- },
- timeout: 600000,
- data: fd,
- onUploadProgress(e: AxiosProgressEvent) {
- progress = e.total ? Math.floor((e.loaded / e.total) * 100) : 0;
- onProgress?.(progress);
- },
- proxy: isLocal,
- NProgress: false
- })
- .then((res) => {
- if (progress != 100) {
- onProgress?.(100);
- }
+ // 上传
+ await service
+ .request({
+ url: host,
+ method: "POST",
+ headers: {
+ "Content-Type": "multipart/form-data",
+ Authorization: isLocal ? user.token : null
+ },
+ timeout: 600000,
+ data: fd,
+ onUploadProgress(e: AxiosProgressEvent) {
+ progress = e.total ? Math.floor((e.loaded / e.total) * 100) : 0;
+ onProgress?.(progress);
+ },
+ proxy: isLocal,
+ NProgress: false
+ })
+ .then((res) => {
+ if (progress != 100) {
+ onProgress?.(100);
+ }
- key = encodeURIComponent(key);
+ key = encodeURIComponent(key);
- let url = "";
+ let url = "";
- if (isLocal) {
- url = res;
- } else {
- url = pathJoin(preview || host, key);
- }
+ if (isLocal) {
+ url = res;
+ } else {
+ url = pathJoin(preview || host, key);
+ }
- resolve({
- key,
- url,
- fileId
+ resolve({
+ key,
+ url,
+ fileId
+ });
+ })
+ .catch((err) => {
+ ElMessage.error(err.message);
+ reject(err);
});
- })
- .catch((err) => {
- ElMessage.error(err.message);
- reject(err);
- });
- }
+ };
- if (isLocal) {
- next({
- host: "/admin/base/comm/upload"
- });
- } else {
- service.base.comm
- .upload(
- type == "aws"
- ? {
- key
- }
- : {}
- )
- .then((res) => {
- switch (type) {
- // 腾讯
- case "cos":
- next({
- host: res.url,
- data: res.credentials
- });
- break;
- // 阿里
- case "oss":
- next({
- host: res.host,
- preview: res.publicDomain,
- data: {
- OSSAccessKeyId: res.OSSAccessKeyId,
- policy: res.policy,
- signature: res.signature
+ if (isLocal) {
+ next({
+ host: "/admin/base/comm/upload"
+ });
+ } else {
+ service.base.comm
+ .upload(
+ type == "aws"
+ ? {
+ key
}
- });
- break;
- // 七牛
- case "qiniu":
- next({
- host: res.uploadUrl,
- preview: res.publicDomain,
- data: {
- token: res.token
- }
- });
- break;
- // aws
- case "aws":
- next({
- host: res.url,
- data: res.fields
- });
- break;
- }
- })
- .catch(reject);
+ : {}
+ )
+ .then((res) => {
+ switch (type) {
+ // 腾讯
+ case "cos":
+ next({
+ host: res.url,
+ data: res.credentials
+ });
+ break;
+ // 阿里
+ case "oss":
+ next({
+ host: res.host,
+ preview: res.publicDomain,
+ data: {
+ OSSAccessKeyId: res.OSSAccessKeyId,
+ policy: res.policy,
+ signature: res.signature
+ }
+ });
+ break;
+ // 七牛
+ case "qiniu":
+ next({
+ host: res.uploadUrl,
+ preview: res.publicDomain,
+ data: {
+ token: res.token
+ }
+ });
+ break;
+ // aws
+ case "aws":
+ next({
+ host: res.url,
+ data: res.fields
+ });
+ break;
+ }
+ })
+ .catch(reject);
+ }
+ } catch (err) {
+ ElMessage.error("文件上传失败");
+ console.error("[upload]", err);
+ reject(err);
}
- } catch (err) {
- ElMessage.error("文件上传失败");
- console.error("[upload]", err);
- reject(err);
- }
+ };
+
+ executor();
});
}
diff --git a/src/plugins/upload/types/index.d.ts b/src/plugins/upload/types/index.d.ts
index 43e98b1..434c5b7 100644
--- a/src/plugins/upload/types/index.d.ts
+++ b/src/plugins/upload/types/index.d.ts
@@ -8,8 +8,8 @@ export declare namespace Upload {
interface Item {
url?: string;
- uid: string;
- progress: number;
+ uid?: string;
+ progress?: number;
preload?: string;
error?: string;
isPlay?: boolean;
@@ -21,4 +21,16 @@ export declare namespace Upload {
onProgress?(progress: number): void;
[key: string]: any;
}
+
+ type Respose = Promise<{
+ key: string;
+ url: string;
+ fileId: string;
+ }>;
+
+ interface Request {
+ host: string;
+ preview?: string;
+ data?: any;
+ }
}
diff --git a/vite.config.mts b/vite.config.mts
index ae6824f..1457718 100644
--- a/vite.config.mts
+++ b/vite.config.mts
@@ -1,27 +1,27 @@
-import path from "path";
+import { fileURLToPath, URL } from "node:url";
import { ConfigEnv, UserConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
+import vueDevTools from "vite-plugin-vue-devtools";
import compression from "vite-plugin-compression";
import { visualizer } from "rollup-plugin-visualizer";
import { proxy } from "./src/config/proxy";
import { cool } from "@cool-vue/vite-plugin";
-function resolve(dir: string) {
- return path.resolve(__dirname, ".", dir);
-}
-
-function isDev(mode: string | undefined): boolean {
- return mode === "development";
+function toPath(dir: string) {
+ return fileURLToPath(new URL(dir, import.meta.url));
}
// https://vitejs.dev/config
export default ({ mode }: ConfigEnv): UserConfig => {
+ const isDev = mode === "development";
+
return {
plugins: [
vue(),
compression(),
vueJsx(),
+ // vueDevTools(),
cool({
type: "admin",
proxy
@@ -49,14 +49,14 @@ export default ({ mode }: ConfigEnv): UserConfig => {
},
resolve: {
alias: {
- "/@": resolve("src"),
- "/$": resolve("src/modules"),
- "/#": resolve("src/plugins"),
- "/~": resolve("packages")
+ "/@": toPath("./src"),
+ "/$": toPath("./src/modules"),
+ "/#": toPath("./src/plugins"),
+ "/~": toPath("./packages")
}
},
esbuild: {
- drop: isDev(mode) ? [] : ["console", "debugger"]
+ drop: isDev ? [] : ["console", "debugger"]
},
build: {
@@ -67,7 +67,7 @@ export default ({ mode }: ConfigEnv): UserConfig => {
// drop_debugger: true
// }
// },
- sourcemap: isDev(mode),
+ sourcemap: isDev,
rollupOptions: {
output: {
chunkFileNames: "static/js/[name]-[hash].js",