feat: 升级依赖版本

master
luoer 2023-09-13 19:44:13 +08:00
parent 4eab238712
commit 3fede86baa
12 changed files with 7076 additions and 1204 deletions

View File

@ -12,37 +12,40 @@
"release": "release-it --config ./scripts/release/index.cjs" "release": "release-it --config ./scripts/release/index.cjs"
}, },
"devDependencies": { "devDependencies": {
"@arco-design/web-vue": "^2.44.4", "@apidevtools/swagger-parser": "^10.1.0",
"@iconify-json/icon-park-outline": "^1.1.10", "@arco-design/web-vue": "^2.51.1",
"@iconify-json/icon-park-outline": "^1.1.12",
"@release-it/conventional-changelog": "^5.1.1", "@release-it/conventional-changelog": "^5.1.1",
"@types/lodash-es": "^4.17.7", "@types/ejs": "^3.1.2",
"@types/lodash-es": "^4.17.9",
"@types/nprogress": "^0.2.0", "@types/nprogress": "^0.2.0",
"@vitejs/plugin-vue": "^4.0.0", "@vitejs/plugin-vue": "^4.3.4",
"@vitejs/plugin-vue-jsx": "^3.0.0", "@vitejs/plugin-vue-jsx": "^3.0.2",
"@vueuse/core": "^9.13.0", "@vueuse/core": "^9.13.0",
"axios": "^1.3.6", "axios": "^1.5.0",
"dayjs": "^1.11.7", "dayjs": "^1.11.9",
"less": "^4.1.3", "ejs": "^3.1.9",
"less": "^4.2.0",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"numeral": "^2.0.6", "numeral": "^2.0.6",
"pinia": "^2.1.6", "pinia": "^2.1.6",
"pinia-plugin-persistedstate": "^3.2.0", "pinia-plugin-persistedstate": "^3.2.0",
"plop": "^3.1.2", "plop": "^3.1.2",
"release-it": "^15.10.1", "release-it": "^15.11.0",
"swagger-typescript-api": "^12.0.4", "swagger-typescript-api": "^12.0.4",
"tsx": "^3.12.6", "tsx": "^3.12.9",
"typescript": "^4.6.4", "typescript": "^4.9.5",
"unocss": "^0.49.4", "unocss": "^0.49.8",
"unplugin-auto-import": "^0.13.0", "unplugin-auto-import": "^0.13.0",
"unplugin-vue-components": "^0.23.0", "unplugin-vue-components": "^0.23.0",
"vite": "^4.3.9", "vite": "^4.4.9",
"vite-plugin-mock": "^3.0.0", "vite-plugin-mock": "^3.0.0",
"vite-plugin-pages": "^0.28.0", "vite-plugin-pages": "^0.28.0",
"vite-plugin-style-import": "^2.0.0", "vite-plugin-style-import": "^2.0.0",
"vitepress": "1.0.0-beta.1", "vitepress": "1.0.0-beta.1",
"vue": "^3.3.4", "vue": "^3.3.4",
"vue-router": "^4.1.6", "vue-router": "^4.2.4",
"vue-tsc": "^1.0.9" "vue-tsc": "^1.8.11"
} }
} }

File diff suppressed because it is too large Load Diff

3437
scripts/openapi/api.json Normal file

File diff suppressed because it is too large Load Diff

68
scripts/openapi/from.ejs Normal file
View File

@ -0,0 +1,68 @@
import { useTable } from '@/components/table';
import { api } from '/api';
const table = useTable({
data: async (data, paging) => {
return <%= select.api %>({ ...data, ...paging });
},
columns: [
<%_ select.columns.forEach(column => { _%>
{
title: '<%= column.title %>',
dataIndex: '<%= column.dataIndex %>',
},
<%_ }) _%>
],
<%_ if (select.items?.length) { _%>
search: {
items: [
<%_ select.items.forEach(column => { _%>
{
field: '<%= column.field %>',
label: '<%= column.label %>',
type: '<%= column.type %>',
},
<%_ }) _%>
]
},
<%_ } _%>
create: {
title: '<%= create.title %>',
modalProps: {
width: 772,
maskClosable: false,
},
formProps: {
layout: "vertical",
class: "!grid grid-cols-2 gap-x-6",
},
items: [
<%_ create.items.forEach(column => { _%>
{
field: '<%= column.field %>',
label: '<%= column.label %>',
type: '<%= column.type %>',
},
<%_ }) _%>
],
submit: async (data) => {
return <%= create.api %>(data);
}
},
modify: {
extend: true,
title: '<%= modify.title %>',
items: [
<%_ modify.items.forEach(column => { _%>
{
field: '<%= column.field %>',
label: '<%= column.label %>',
type: '<%= column.type %>',
},
<%_ }) _%>
],
submit: async (data) => {
return <%= modify.api %>(data);
}
}
})

View File

@ -6,8 +6,6 @@ import { fileURLToPath } from "url";
const __dirname = path.join(fileURLToPath(new URL(import.meta.url)), ".."); const __dirname = path.join(fileURLToPath(new URL(import.meta.url)), "..");
const env = loadEnv("development", process.cwd()); const env = loadEnv("development", process.cwd());
console.log(env.VITE_OPENAPI);
const run = async () => { const run = async () => {
const output = await generateApi({ const output = await generateApi({
url: env.VITE_OPENAPI, url: env.VITE_OPENAPI,

2066
scripts/openapi/openapi.json Normal file

File diff suppressed because it is too large Load Diff

86
scripts/openapi/parse.ts Normal file
View File

@ -0,0 +1,86 @@
import { readFileSync, writeFileSync } from "fs";
import parser from "@apidevtools/swagger-parser";
import ejs from "ejs";
async function run() {
const apiJson = JSON.parse(readFileSync("./openapi.json", "utf-8"));
const parsed = await parser.validate(apiJson);
const list = Object.entries(parsed.paths || {});
const routes: any = [];
for (const [path, pathObj] of list) {
for (const [method, mObj] of Object.entries(pathObj)) {
const { description, operationId, tags = [] } = mObj as any;
const items: any[] = [];
let requestBody = (mObj as any).requestBody?.content?.["application/json"]?.schema;
if (requestBody) {
for (const [field, fieldObj] of Object.entries(requestBody.properties)) {
const { type, description } = fieldObj as any;
items.push({
field,
type,
label: description,
});
}
}
routes.push({
method,
path,
title: description,
id: operationId,
tags,
items,
});
}
}
const template = readFileSync('./from.ejs', 'utf-8');
const r = ejs.render(template, {
create: {
title: '新增用户',
api: 'api.user.addUser',
items: [
{
field: 'username',
type: 'input',
label: '用户名',
}
]
},
select: {
title: '查询用户',
api: 'api.user.getUsers',
items: [
{
field: 'username',
type: 'input',
label: '用户名',
}
],
columns: [
{
title: '用户名',
dataIndex: 'username',
}
]
},
modify: {
title: '修改用户',
api: 'api.user.setUser',
items: [
{
field: 'username',
type: 'input',
label: '用户名',
}
]
},
delete: {
title: '删除用户',
api: 'api.user.delUser',
}
})
writeFileSync('./to.ts', r);
}
run();

49
scripts/openapi/to.ts Normal file
View File

@ -0,0 +1,49 @@
import { useTable } from '@/components/table';
import { api } from '/api';
const table = useTable({
data: async (data, paging) => {
return api.user.getUsers({ ...data, ...paging });
},
columns: [
{
title: '用户名',
dataIndex: 'username',
},
],
search: {
items: [
{
field: 'username',
label: '用户名',
type: 'input',
},
]
},
create: {
title: '新增用户',
items: [
{
field: 'username',
label: '用户名',
type: 'input',
},
],
submit: async (data) => {
return api.user.addUser(data);
}
},
modify: {
title: '修改用户',
items: [
{
field: 'username',
label: '用户名',
type: 'input',
},
],
submit: async (data) => {
return api.user.setUser(data);
}
}
})

View File

@ -56,7 +56,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { api } from "@/api"; import { api } from "@/api";
import { dayjs } from "@/libs/dayjs"; import { dayjs } from "@/libs";
import { useAppStore, useUserStore } from "@/store"; import { useAppStore, useUserStore } from "@/store";
import { FieldRule, Form, Message, Modal } from "@arco-design/web-vue"; import { FieldRule, Form, Message, Modal } from "@arco-design/web-vue";
import { reactive } from "vue"; import { reactive } from "vue";

View File

@ -7,7 +7,7 @@
<script setup lang="tsx"> <script setup lang="tsx">
import { api } from "@/api"; import { api } from "@/api";
import { Table, useTable } from "@/components"; import { Table, useTable } from "@/components";
import { dayjs } from "@/libs/dayjs"; import { dayjs } from "@/libs";
import { Avatar, Button } from "@arco-design/web-vue"; import { Avatar, Button } from "@arco-design/web-vue";
const table = useTable({ const table = useTable({

View File

@ -63,6 +63,8 @@ const table = useTable({
required: false, required: false,
nodeProps: { nodeProps: {
placeholder: '请输入登陆账号', placeholder: '请输入登陆账号',
},
itemProps: {
hideLabel: true, hideLabel: true,
} }
}, },

View File

@ -7,7 +7,7 @@
<script setup lang="tsx"> <script setup lang="tsx">
import { api } from "@/api"; import { api } from "@/api";
import { Table, useTable } from "@/components"; import { Table, useTable } from "@/components";
import { dayjs } from "@/libs/dayjs"; import { dayjs } from "@/libs";
const table = useTable({ const table = useTable({
data: async (model, paging) => { data: async (model, paging) => {