create-vitex
Advanced tools
Comparing version 0.10.0 to 0.11.0
{ | ||
"name": "create-vitex", | ||
"version": "0.10.0", | ||
"version": "0.11.0", | ||
"description": "Start an opinioned vite project", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -8,3 +8,3 @@ # create-vitex | ||
```sh | ||
npm create vitex | ||
npm create vitex@latest -y | ||
``` | ||
@@ -15,9 +15,13 @@ | ||
```sh | ||
npx -y create-vitex project-name --user=github-username | ||
npx -y create-vitex@latest project-name --user=github-username | ||
``` | ||
# Sync PrimeVue and Ant-Design-Vue | ||
In your project, run: | ||
```sh | ||
npx -y cpgit primefaces/primevue -s=packages/primevue/src template/lib/primevue | ||
npx -y cpgit vueComponent/ant-design-vue -s=components template/lib/ant-design-vue | ||
npx -y cpgit primefaces/primevue -s=packages/primevue/src lib/primevue | ||
npx -y cpgit vueComponent/ant-design-vue -s=components lib/ant-design-vue | ||
``` | ||
# reference | ||
``` | ||
npm create vue@latest xx -- --typescript --jsx --router --vitest --eslint --prettier --force | ||
``` |
{ | ||
"recommendations": [ | ||
"Vue.volar", | ||
"Vue.vscode-typescript-vue-plugin", | ||
"vitest.explorer", | ||
"dbaeumer.vscode-eslint", | ||
"esbenp.prettier-vscode" | ||
"EditorConfig.EditorConfig" | ||
] | ||
} | ||
} |
{ | ||
"explorer.fileNesting.enabled": true, | ||
"explorer.fileNesting.patterns": { | ||
"tsconfig.json": "tsconfig.*.json, env.d.ts", | ||
"vite.config.*": "jsconfig*, vitest.config.*, cypress.config.*, playwright.config.*", | ||
"package.json": "package-lock.json, pnpm*, .yarnrc*, yarn*, .eslint*, eslint*, .prettier*, prettier*, .editorconfig" | ||
}, | ||
"editor.quickSuggestionsDelay": 200, | ||
@@ -17,3 +23,3 @@ "editor.suggest.snippetsPreventQuickSuggestions": true, | ||
"editor.formatOnSave": true, // optional | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint", | ||
"editor.formatOnSaveMode": "file", // required to format on save | ||
@@ -20,0 +26,0 @@ "files.autoSave": "onFocusChange", |
import axios from "axios"; | ||
import useStore from "~/composables/useStore"; | ||
import router from "@/router"; | ||
@@ -45,30 +44,8 @@ const viteEnv = import.meta.env; | ||
loading.value = false; | ||
if (!error.response) { | ||
console.log("no response error:", error); | ||
throw error; | ||
} | ||
const { data, status, request } = error.response; | ||
const currentUrl = router.currentRoute.value.fullPath; | ||
if (status == 403) { | ||
// if (data == process.env.INSUFFICIENT_PERMISSION_TEXT) { | ||
// } | ||
const [_, url] = request.responseURL.match(/https?:\/\/[^/]+(.+)/); | ||
const realUrl = process.env.NODE_ENV === "production" ? url : url.slice(process.env.VITE_PROXY_PREFIX.length); | ||
Notice.error("需要登录"); | ||
return router.push({ | ||
name: realUrl.startsWith("/admin") ? "AdminUserLogin" : "UserLogin", | ||
query: { | ||
redirect: currentUrl, | ||
}, | ||
}); | ||
} else { | ||
throw error; | ||
} | ||
// return Promise.reject(error); | ||
throw error; | ||
}, | ||
); | ||
async function post(url, data, config) { | ||
const resp = await myAxios({ | ||
async function post(url, data, config = {}) { | ||
return await myAxios({ | ||
url, | ||
@@ -82,11 +59,6 @@ data, | ||
}); | ||
// 403 错误时resp是undefined | ||
if (!resp) { | ||
throw new Error(""); | ||
} | ||
return resp; | ||
} | ||
async function get(url, config = {}) { | ||
const resp = await myAxios({ | ||
return await myAxios({ | ||
url, | ||
@@ -99,6 +71,2 @@ method: "GET", | ||
}); | ||
if (!resp) { | ||
throw new Error(""); | ||
} | ||
return resp; | ||
} | ||
@@ -105,0 +73,0 @@ |
@@ -31,17 +31,16 @@ { | ||
"@vueuse/integrations": "^9.11.0", | ||
"@xiangnanscu/docx": "^8.5.1", | ||
"@xnscu/docx": "^9.0.3", | ||
"@xnscu/xlsx-template": "^1.4.5", | ||
"ant-design-vue": "3.2.20", | ||
"@xnscu/tinymce": "^0.7.0", | ||
"@ant-design/icons-vue": "^6.1.0", | ||
"ant-design-vue": "^4.2.5", | ||
"axios": "^1.2.1", | ||
"docx": "^8.6.0", | ||
"docx-templates": "^4.13.0", | ||
"dotenv": "^16.0.3", | ||
"dotenv-expand": "^10.0.0", | ||
"file-saver": "^2.0.5", | ||
"nanoid": "4.0.2", | ||
"primeflex": "^3.3.1", | ||
"primeicons": "^7.0.0", | ||
"primelocale": "^0.0.1", | ||
"primevue": "^3.29.1", | ||
"qrcode": "^1.5.1", | ||
"universal-cookie": "^7.2.0", | ||
"vue": "^3.4.21", | ||
"vue": "3.5.13", | ||
"vue-router": "^4.3.0", | ||
@@ -62,5 +61,4 @@ "xlsx": "https://cdn.sheetjs.com/xlsx-0.19.2/xlsx-0.19.2.tgz" | ||
"@vue/tsconfig": "^0.5.1", | ||
"dotenv": "^16.0.3", | ||
"antdv-component-resolver": "^1.0.7", | ||
"dotenv-cli": "^6.0.0", | ||
"dotenv-expand": "^10.0.0", | ||
"eslint": "^8.57.0", | ||
@@ -67,0 +65,0 @@ "eslint-plugin-vue": "^9.23.0", |
import { createApp } from "vue"; | ||
import PrimeVue from "primevue/config"; | ||
import "primevue/resources/themes/aura-light-cyan/theme.css"; | ||
import "primeicons/primeicons.css"; | ||
import primelocale from "primelocale/zh-CN.json"; | ||
import "primeflex/primeflex.css"; | ||
import router from "./router"; | ||
@@ -12,2 +7,4 @@ import App from "./App.vue"; | ||
import { request } from "~/lib/Http"; | ||
import "@/assets/main.css"; | ||
import "ant-design-vue/dist/reset.css"; | ||
@@ -19,16 +16,32 @@ Model.request = request; | ||
app.use(router); | ||
app.use(PrimeVue, { | ||
inputStyle: "filled", | ||
ripple: true, | ||
locale: primelocale["zh-CN"], | ||
}); | ||
app.mount("#app"); | ||
app.config.errorHandler = (err, instance, info) => { | ||
if (typeof err == "object") { | ||
if (err.message !== "") { | ||
app.config.errorHandler = (error, instance, info) => { | ||
console.error("全局错误捕获:", error.message); | ||
if (typeof error == "object") { | ||
if (error.name == "AxiosError") { | ||
const { data, status, request } = error.response; | ||
// console.log("AxiosError:", { data, status, request }); | ||
if (status == 403) { | ||
const [_, url] = request.responseURL.match(/https?:\/\/[^/]+(.+)/); | ||
const realUrl = | ||
process.env.NODE_ENV === "production" | ||
? url | ||
: url.slice(process.env.VITE_PROXY_PREFIX.length); | ||
Notice.error("需要登录"); | ||
return router.push({ | ||
name: realUrl.startsWith("/admin") ? "AdminUserLogin" : "UserLogin", | ||
query: { | ||
redirect: router.currentRoute.value.fullPath, | ||
}, | ||
}); | ||
} else if (error.response.data) { | ||
return Notice.error(error.response.data); | ||
} | ||
} else if (error.message !== "") { | ||
// Http.post抛出的错误是空字符串,暂时不展示 | ||
console.error(`${err.response?.data || err.message || "未知错误"}`); | ||
return Notice.error(error.message); | ||
} | ||
} | ||
Notice.error(typeof error == "object" ? error.message : error); | ||
}; |
@@ -5,6 +5,3 @@ { | ||
"vite.config.*", | ||
"vitest.config.*", | ||
"cypress.config.*", | ||
"nightwatch.conf.*", | ||
"playwright.config.*" | ||
"vitest.config.*" | ||
], | ||
@@ -11,0 +8,0 @@ "compilerOptions": { |
@@ -10,3 +10,3 @@ import { fileURLToPath, URL } from "node:url"; | ||
import Components from "unplugin-vue-components/vite"; | ||
import { AntDesignVueResolver, PrimeVueResolver } from "unplugin-vue-components/resolvers"; | ||
import AntdvResolver from "antdv-component-resolver"; | ||
import ViteRequireContext from "@originjs/vite-plugin-require-context"; | ||
@@ -60,3 +60,3 @@ import { nodePolyfills } from "vite-plugin-node-polyfills"; | ||
directoryAsNamespace: true, | ||
resolvers: [AntDesignVueResolver({ resolveIcons: true }), PrimeVueResolver()], | ||
resolvers: [AntdvResolver()], | ||
}), | ||
@@ -63,0 +63,0 @@ // https://uvr.esm.is/guide/configuration.html |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
531167
77
10482
25