feat: 更新升级vite 6
This commit is contained in:
1 parent
ac0d3b2f7d
commit
f6ad3ae221
52 files changed
+7641
-495
No files matched your search
@@ -1,4 +0,0 @@
|
||||
build
|
||||
dist
|
||||
node_modules
|
||||
.vscode
|
||||
@@ -0,0 +1,94 @@
|
||||
{
|
||||
"globals": {
|
||||
"Component": true,
|
||||
"ComponentPublicInstance": true,
|
||||
"ComputedRef": true,
|
||||
"EffectScope": true,
|
||||
"ExtractDefaultPropTypes": true,
|
||||
"ExtractPropTypes": true,
|
||||
"ExtractPublicPropTypes": true,
|
||||
"InjectionKey": true,
|
||||
"PropType": true,
|
||||
"Ref": true,
|
||||
"VNode": true,
|
||||
"WritableComputedRef": true,
|
||||
"acceptHMRUpdate": true,
|
||||
"computed": true,
|
||||
"createApp": true,
|
||||
"createPinia": true,
|
||||
"createRouter": true,
|
||||
"createWebHashHistory": true,
|
||||
"createWebHistory": true,
|
||||
"customRef": true,
|
||||
"defineAsyncComponent": true,
|
||||
"defineComponent": true,
|
||||
"defineStore": true,
|
||||
"effectScope": true,
|
||||
"getActivePinia": true,
|
||||
"getCurrentInstance": true,
|
||||
"getCurrentScope": true,
|
||||
"h": true,
|
||||
"inject": true,
|
||||
"isProxy": true,
|
||||
"isReactive": true,
|
||||
"isReadonly": true,
|
||||
"isRef": true,
|
||||
"mapActions": true,
|
||||
"mapGetters": true,
|
||||
"mapState": true,
|
||||
"mapStores": true,
|
||||
"mapWritableState": true,
|
||||
"markRaw": true,
|
||||
"nextTick": true,
|
||||
"onActivated": true,
|
||||
"onBeforeMount": true,
|
||||
"onBeforeRouteLeave": true,
|
||||
"onBeforeRouteUpdate": true,
|
||||
"onBeforeUnmount": true,
|
||||
"onBeforeUpdate": true,
|
||||
"onDeactivated": true,
|
||||
"onErrorCaptured": true,
|
||||
"onMounted": true,
|
||||
"onRenderTracked": true,
|
||||
"onRenderTriggered": true,
|
||||
"onScopeDispose": true,
|
||||
"onServerPrefetch": true,
|
||||
"onUnmounted": true,
|
||||
"onUpdated": true,
|
||||
"provide": true,
|
||||
"reactive": true,
|
||||
"readonly": true,
|
||||
"ref": true,
|
||||
"resolveComponent": true,
|
||||
"setActivePinia": true,
|
||||
"setMapStoreSuffix": true,
|
||||
"shallowReactive": true,
|
||||
"shallowReadonly": true,
|
||||
"shallowRef": true,
|
||||
"storeToRefs": true,
|
||||
"toRaw": true,
|
||||
"toRef": true,
|
||||
"toRefs": true,
|
||||
"toValue": true,
|
||||
"triggerRef": true,
|
||||
"unref": true,
|
||||
"useAttrs": true,
|
||||
"useCssModule": true,
|
||||
"useCssVars": true,
|
||||
"useLink": true,
|
||||
"useRoute": true,
|
||||
"useRouter": true,
|
||||
"useSlots": true,
|
||||
"watch": true,
|
||||
"watchEffect": true,
|
||||
"watchPostEffect": true,
|
||||
"watchSyncEffect": true,
|
||||
"DirectiveBinding": true,
|
||||
"MaybeRef": true,
|
||||
"MaybeRefOrGetter": true,
|
||||
"onWatcherCleanup": true,
|
||||
"useId": true,
|
||||
"useModel": true,
|
||||
"useTemplateRef": true
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
"browser": true,
|
||||
"es2021": true,
|
||||
"node": true,
|
||||
"vue/setup-compiler-macros": true
|
||||
},
|
||||
extends: ["eslint:recommended", "plugin:vue/vue3-recommended", "@vue/typescript/recommended", "prettier"],
|
||||
parser: "vue-eslint-parser",
|
||||
parserOptions: {
|
||||
ecmaVersion: "latest",
|
||||
parser: "@typescript-eslint/parser",
|
||||
sourceType: "module"
|
||||
},
|
||||
plugins: ["vue", "html", "@typescript-eslint"],
|
||||
rules: {
|
||||
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
|
||||
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
|
||||
"semi": [2, "always"],
|
||||
"comma-dangle": [2, "never"],
|
||||
"eqeqeq": "warn",
|
||||
"quotes": ["warn", "double"],
|
||||
"@typescript-eslint/ban-types": [
|
||||
"warn",
|
||||
{
|
||||
types: {
|
||||
"{}": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"@typescript-eslint/no-explicit-any": "off",
|
||||
"vue/no-unused-vars": "warn",
|
||||
"vue/multi-word-component-names": "off",
|
||||
"vue/no-mutating-props": "off",
|
||||
"@typescript-eslint/ban-ts-comment": "off",
|
||||
"vue/html-closing-bracket-newline": [
|
||||
"error",
|
||||
{
|
||||
singleline: "never",
|
||||
multiline: "always"
|
||||
}
|
||||
],
|
||||
"vue/html-indent": [
|
||||
"error",
|
||||
2,
|
||||
{
|
||||
attribute: 1,
|
||||
baseIndent: 1,
|
||||
closeBracket: 0,
|
||||
alignAttributesVertically: true,
|
||||
ignores: []
|
||||
}
|
||||
],
|
||||
"vue/max-attributes-per-line": [
|
||||
"error",
|
||||
{
|
||||
singleline: {
|
||||
max: 2
|
||||
},
|
||||
multiline: {
|
||||
max: 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
+17
-11
@@ -1,20 +1,26 @@
|
||||
.DS_Store
|
||||
node_modules
|
||||
/dist
|
||||
package-lock.json
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# Log files
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
.DS_Store
|
||||
dist
|
||||
dist-ssr
|
||||
coverage
|
||||
*.local
|
||||
|
||||
/cypress/videos/
|
||||
/cypress/screenshots/
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.vscode
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
module.exports = {
|
||||
semi: false,
|
||||
singleQuote: false,
|
||||
tabWidth: 2,
|
||||
useTabs: false,
|
||||
printWidth: 120,
|
||||
proseWrap: 'preserve',
|
||||
trailingComma: 'es5',
|
||||
bracketSpacing: true,
|
||||
quoteProps: "consistent",
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/prettierrc",
|
||||
"semi": false,
|
||||
"tabWidth": 2,
|
||||
"singleQuote": false,
|
||||
"printWidth": 100,
|
||||
"trailingComma": "none"
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"Vue.volar",
|
||||
"Vue.vscode-typescript-vue-plugin",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode"
|
||||
]
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
# vue3-template-h5
|
||||
# mytest
|
||||
|
||||
一个h5项目
|
||||
vue3-template-h5
|
||||
|
||||
## 安装
|
||||
|
||||
@@ -11,10 +11,9 @@ npm install
|
||||
## 运行
|
||||
|
||||
```
|
||||
npm run serve:dev //本地运行,并且代理到开发环境
|
||||
npm run serve:test //本地运行,并且代理到测试环境
|
||||
npm run serve:uat //本地运行,并且代理到预发布环境
|
||||
npm run serve:prod //本地运行,并且代理到生产环境
|
||||
npm run serve //本地运行,并且代理到生产环境
|
||||
```
|
||||
|
||||
## 打包
|
||||
@@ -27,7 +26,7 @@ npm run build:test
|
||||
npm run build:uat
|
||||
|
||||
// 生产环境
|
||||
npm run build:prod
|
||||
npm run build
|
||||
```
|
||||
|
||||
## 说明
|
||||
@@ -37,6 +36,10 @@ npm run build:prod
|
||||
|
||||
## 常见问题
|
||||
|
||||
### 环境变量
|
||||
|
||||
环境变量放在env目录下,.env文件必定会加载,mode=test时,.env.test会加载,变量优先级,.env.test > .env ,因此,相同变量名,.env里的会被忽略。
|
||||
|
||||
### 按需引入组件
|
||||
|
||||
项目使用 unplugin-vue-components 插件,它可以自动引入组件,并按需引入组件的样式,无需手动引入样式。
|
||||
@@ -49,37 +52,37 @@ import {
|
||||
|
||||
### 引入函数组件的样式
|
||||
|
||||
Vant 中有个别组件是以函数的形式提供的,包括 Toast,Dialog,Notify 和 ImagePreview 组件。在使用函数组件时,unplugin-vue-components 无法自动引入对应的样式,因此需要手动引入样式。
|
||||
Vant 中有个别组件是以函数的形式提供的,包括 Toast,Dialog,Notify 和 ImagePreview 等组件。在使用函数组件时,unplugin-vue-components 无法自动引入对应的样式,因此需要手动引入样式。
|
||||
|
||||
```JS
|
||||
// Toast
|
||||
import {
|
||||
Toast
|
||||
showToast
|
||||
} from 'vant';
|
||||
import 'vant/es/toast/style';
|
||||
|
||||
// Dialog
|
||||
import {
|
||||
Dialog
|
||||
showDialog
|
||||
} from 'vant';
|
||||
import 'vant/es/dialog/style';
|
||||
|
||||
// Notify
|
||||
import {
|
||||
Notify
|
||||
showNotify
|
||||
} from 'vant';
|
||||
import 'vant/es/notify/style';
|
||||
|
||||
// ImagePreview
|
||||
import {
|
||||
ImagePreview
|
||||
showImagePreview
|
||||
} from 'vant';
|
||||
import 'vant/es/image-preview/style';
|
||||
```
|
||||
|
||||
### 本地代理
|
||||
|
||||
运行项目时的接口代理,可在 proxy.config.ts 中配置。
|
||||
运行项目时的接口代理,可在 vite.util.ts 的 proxyConfig 方法中配置。
|
||||
|
||||
## 相关文档
|
||||
|
||||
|
||||
Vendored
+90
@@ -0,0 +1,90 @@
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
// @ts-nocheck
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
// Generated by unplugin-auto-import
|
||||
export {}
|
||||
declare global {
|
||||
const EffectScope: typeof import('vue')['EffectScope']
|
||||
const acceptHMRUpdate: typeof import('pinia')['acceptHMRUpdate']
|
||||
const computed: typeof import('vue')['computed']
|
||||
const createApp: typeof import('vue')['createApp']
|
||||
const createPinia: typeof import('pinia')['createPinia']
|
||||
const createRouter: typeof import('vue-router')['createRouter']
|
||||
const createWebHashHistory: typeof import('vue-router')['createWebHashHistory']
|
||||
const createWebHistory: typeof import('vue-router')['createWebHistory']
|
||||
const customRef: typeof import('vue')['customRef']
|
||||
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
|
||||
const defineComponent: typeof import('vue')['defineComponent']
|
||||
const defineStore: typeof import('pinia')['defineStore']
|
||||
const effectScope: typeof import('vue')['effectScope']
|
||||
const getActivePinia: typeof import('pinia')['getActivePinia']
|
||||
const getCurrentInstance: typeof import('vue')['getCurrentInstance']
|
||||
const getCurrentScope: typeof import('vue')['getCurrentScope']
|
||||
const h: typeof import('vue')['h']
|
||||
const inject: typeof import('vue')['inject']
|
||||
const isProxy: typeof import('vue')['isProxy']
|
||||
const isReactive: typeof import('vue')['isReactive']
|
||||
const isReadonly: typeof import('vue')['isReadonly']
|
||||
const isRef: typeof import('vue')['isRef']
|
||||
const mapActions: typeof import('pinia')['mapActions']
|
||||
const mapGetters: typeof import('pinia')['mapGetters']
|
||||
const mapState: typeof import('pinia')['mapState']
|
||||
const mapStores: typeof import('pinia')['mapStores']
|
||||
const mapWritableState: typeof import('pinia')['mapWritableState']
|
||||
const markRaw: typeof import('vue')['markRaw']
|
||||
const nextTick: typeof import('vue')['nextTick']
|
||||
const onActivated: typeof import('vue')['onActivated']
|
||||
const onBeforeMount: typeof import('vue')['onBeforeMount']
|
||||
const onBeforeRouteLeave: typeof import('vue-router')['onBeforeRouteLeave']
|
||||
const onBeforeRouteUpdate: typeof import('vue-router')['onBeforeRouteUpdate']
|
||||
const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']
|
||||
const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
|
||||
const onDeactivated: typeof import('vue')['onDeactivated']
|
||||
const onErrorCaptured: typeof import('vue')['onErrorCaptured']
|
||||
const onMounted: typeof import('vue')['onMounted']
|
||||
const onRenderTracked: typeof import('vue')['onRenderTracked']
|
||||
const onRenderTriggered: typeof import('vue')['onRenderTriggered']
|
||||
const onScopeDispose: typeof import('vue')['onScopeDispose']
|
||||
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
|
||||
const onUnmounted: typeof import('vue')['onUnmounted']
|
||||
const onUpdated: typeof import('vue')['onUpdated']
|
||||
const onWatcherCleanup: typeof import('vue')['onWatcherCleanup']
|
||||
const provide: typeof import('vue')['provide']
|
||||
const reactive: typeof import('vue')['reactive']
|
||||
const readonly: typeof import('vue')['readonly']
|
||||
const ref: typeof import('vue')['ref']
|
||||
const resolveComponent: typeof import('vue')['resolveComponent']
|
||||
const setActivePinia: typeof import('pinia')['setActivePinia']
|
||||
const setMapStoreSuffix: typeof import('pinia')['setMapStoreSuffix']
|
||||
const shallowReactive: typeof import('vue')['shallowReactive']
|
||||
const shallowReadonly: typeof import('vue')['shallowReadonly']
|
||||
const shallowRef: typeof import('vue')['shallowRef']
|
||||
const storeToRefs: typeof import('pinia')['storeToRefs']
|
||||
const toRaw: typeof import('vue')['toRaw']
|
||||
const toRef: typeof import('vue')['toRef']
|
||||
const toRefs: typeof import('vue')['toRefs']
|
||||
const toValue: typeof import('vue')['toValue']
|
||||
const triggerRef: typeof import('vue')['triggerRef']
|
||||
const unref: typeof import('vue')['unref']
|
||||
const useAttrs: typeof import('vue')['useAttrs']
|
||||
const useCssModule: typeof import('vue')['useCssModule']
|
||||
const useCssVars: typeof import('vue')['useCssVars']
|
||||
const useId: typeof import('vue')['useId']
|
||||
const useLink: typeof import('vue-router')['useLink']
|
||||
const useModel: typeof import('vue')['useModel']
|
||||
const useRoute: typeof import('vue-router')['useRoute']
|
||||
const useRouter: typeof import('vue-router')['useRouter']
|
||||
const useSlots: typeof import('vue')['useSlots']
|
||||
const useTemplateRef: typeof import('vue')['useTemplateRef']
|
||||
const watch: typeof import('vue')['watch']
|
||||
const watchEffect: typeof import('vue')['watchEffect']
|
||||
const watchPostEffect: typeof import('vue')['watchPostEffect']
|
||||
const watchSyncEffect: typeof import('vue')['watchSyncEffect']
|
||||
}
|
||||
// for type re-export
|
||||
declare global {
|
||||
// @ts-ignore
|
||||
export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
|
||||
import('vue')
|
||||
}
|
||||
Vendored
+5
-6
@@ -1,13 +1,12 @@
|
||||
// generated by unplugin-vue-components
|
||||
// We suggest you to commit this file into source control
|
||||
/* eslint-disable */
|
||||
/* prettier-ignore */
|
||||
// @ts-nocheck
|
||||
// Generated by unplugin-vue-components
|
||||
// Read more: https://github.com/vuejs/core/pull/3399
|
||||
import '@vue/runtime-core'
|
||||
|
||||
export {}
|
||||
|
||||
declare module '@vue/runtime-core' {
|
||||
declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
_index: typeof import('./src/components/abnormal/_index.vue')['default']
|
||||
Abnormal: typeof import('./src/components/abnormal/index.vue')['default']
|
||||
HelloWorld: typeof import('./src/components/HelloWorld.vue')['default']
|
||||
IconAndText: typeof import('./src/components/abnormal/iconAndText.vue')['default']
|
||||
|
||||
Vendored
-15
@@ -1,15 +0,0 @@
|
||||
export declare const appName: string;
|
||||
|
||||
export declare const passid: string;
|
||||
|
||||
export declare const VITE_APP_ENV: string;
|
||||
|
||||
export declare let proxyTarget: string;
|
||||
|
||||
export declare const vconsoleDebug: boolean;
|
||||
|
||||
export declare const scriptSrcStr: string;
|
||||
|
||||
export declare let temp: string;
|
||||
|
||||
export declare const injectScriptStr: string;
|
||||
@@ -1,39 +0,0 @@
|
||||
const appName = "协同办公XX管理后台";
|
||||
|
||||
const passid = "paasid";
|
||||
|
||||
const ENV: any = import.meta.env || process.env;
|
||||
const VITE_APP_ENV: string = ENV.VITE_APP_ENV;
|
||||
|
||||
let proxyTarget = "";
|
||||
switch (VITE_APP_ENV) {
|
||||
case "test":
|
||||
proxyTarget = "https://xxxxxx.com";
|
||||
break;
|
||||
case "uat":
|
||||
proxyTarget = "https://xxxxxx.com";
|
||||
break;
|
||||
case "prod":
|
||||
proxyTarget = "https://xxxxxx.com";
|
||||
break;
|
||||
default:
|
||||
proxyTarget = "https://xxxxxx.com";
|
||||
break;
|
||||
}
|
||||
|
||||
const vconsoleDebug = true;
|
||||
const scriptSrcStr = "var src = '/midjs/mjs/vconsole/v3.14.6/vconsole.min.js';document.write('<scr' + 'ipt src=\"' + src + '\"></scr' + 'ipt>');document.write('<scr' + 'ipt>new window.VConsole();</scr' + 'ipt>');";
|
||||
let temp = "";
|
||||
if (vconsoleDebug && (VITE_APP_ENV === "test" || VITE_APP_ENV === "uat")) {
|
||||
temp = scriptSrcStr;
|
||||
} else {
|
||||
temp = `if (/vconsole=true/.test(window.location)) {${scriptSrcStr}};`;
|
||||
}
|
||||
const injectScriptStr = `<script>;(function () {${temp}})();</script>`;
|
||||
|
||||
export {
|
||||
appName,
|
||||
proxyTarget,
|
||||
passid,
|
||||
injectScriptStr
|
||||
};
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference types="vite/client" />
|
||||
declare interface ImportMetaEnv {
|
||||
readonly VITE_APP_ENV: string
|
||||
readonly VITE_APP_NAME: string
|
||||
readonly VITE_APP_SYSTEMCODE: string
|
||||
// 更多环境变量...
|
||||
}
|
||||
|
||||
@@ -9,5 +10,12 @@ declare interface ImportMeta {
|
||||
}
|
||||
|
||||
declare interface Window {
|
||||
wx: any;
|
||||
wx: any
|
||||
printLog: boolean | undefined | null
|
||||
}
|
||||
|
||||
declare module "*.vue" {
|
||||
import type { DefineComponent } from "vue";
|
||||
const component: DefineComponent<{}, {}, any>;
|
||||
export default component;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# VITE_APP_ 开头的变量可在浏览器环境使用:import.meta.env.VITE_APP_XXXX
|
||||
VITE_APP_NAME=vue3-template-h5
|
||||
VITE_APP_SYSTEMCODE=paasid
|
||||
|
||||
# NODE_ 开头的变量可在serve和build环境使用:process.env.NODE_XXXX
|
||||
NODE_PROXY_TARGET=https://xtbg.gdzwfw.gov.cn
|
||||
NODE_VCONSOLE_SCRIPST=<script>printLog=/vconsole=true/.test(window.location);if(!printLog){console.log=function(){}}</script><script>;(function () {if (printLog) {var src = '/midjs/mjs/vconsole/v3.14.6/vconsole.min.js';document.write('<scr' + 'ipt src=\"' + src + '\"></scr' + 'ipt>');document.write('<scr' + 'ipt>new window.VConsole();</scr' + 'ipt>');};})();</script>
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
NODE_PROXY_TARGET=https://xtbgtest.digitalgd.com.cn
|
||||
NODE_VCONSOLE_SCRIPST=<script src="/midjs/mjs/vconsole/v3.14.6/vconsole.min.js"></script><script>new window.VConsole();</script>
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
NODE_PROXY_TARGET=https://xtbg.digitalgd.com.cn
|
||||
NODE_VCONSOLE_SCRIPST=<script src="/midjs/mjs/vconsole/v3.14.6/vconsole.min.js"></script><script>new window.VConsole();</script>
|
||||
@@ -0,0 +1,83 @@
|
||||
import { globalIgnores } from 'eslint/config'
|
||||
import globals from 'globals'
|
||||
import js from '@eslint/js'
|
||||
import pluginVue from 'eslint-plugin-vue'
|
||||
import {
|
||||
defineConfigWithVueTs,
|
||||
vueTsConfigs,
|
||||
} from '@vue/eslint-config-typescript'
|
||||
import pluginOxlint from 'eslint-plugin-oxlint'
|
||||
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
|
||||
|
||||
export default defineConfigWithVueTs([
|
||||
{
|
||||
name: 'app/files-to-lint',
|
||||
files: ['**/*.{ts,js,mjs,jsx,vue}'],
|
||||
},
|
||||
|
||||
globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),
|
||||
|
||||
{
|
||||
languageOptions: {
|
||||
globals: {...globals.browser},
|
||||
},
|
||||
|
||||
rules: {
|
||||
'no-console': 'warn',
|
||||
'no-debugger': 'warn',
|
||||
"quotes": ["warn", "double"],
|
||||
"semi": [2, "always"],
|
||||
"comma-dangle": [2, "never"],
|
||||
"eqeqeq": "warn",
|
||||
"no-var": "warn",
|
||||
"no-multi-spaces": "warn",
|
||||
"no-trailing-spaces": "warn",
|
||||
"camelcase": "warn",
|
||||
"indent": ["warn", 2],
|
||||
"space-infix-ops": "warn",
|
||||
"space-unary-ops": "warn",
|
||||
"switch-colon-spacing": "warn",
|
||||
"arrow-spacing": "warn",
|
||||
"array-bracket-spacing": "warn",
|
||||
"vue/no-unused-vars": "warn",
|
||||
"vue/multi-word-component-names": "off",
|
||||
'vue/html-indent': [
|
||||
'error',
|
||||
2,
|
||||
{
|
||||
attribute: 1,
|
||||
baseIndent: 1,
|
||||
closeBracket: 0,
|
||||
alignAttributesVertically: true,
|
||||
ignores: []
|
||||
}
|
||||
],
|
||||
'vue/max-attributes-per-line': [
|
||||
'error',
|
||||
{
|
||||
singleline: {
|
||||
max: 3
|
||||
}
|
||||
}
|
||||
],
|
||||
'vue/html-closing-bracket-newline': [
|
||||
'error',
|
||||
{
|
||||
singleline: 'never',
|
||||
multiline: 'always'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
js.configs.recommended,
|
||||
...pluginVue.configs['flat/essential'],
|
||||
vueTsConfigs.recommended,
|
||||
...pluginOxlint.configs['flat/recommended'],
|
||||
skipFormatting,
|
||||
{
|
||||
rules: {
|
||||
"@typescript-eslint/no-explicit-any": "warn"
|
||||
}
|
||||
}
|
||||
])
|
||||
+3
-3
@@ -1,20 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-Hans">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg"/>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0"/>
|
||||
<title><%- title %></title>
|
||||
<title>%VITE_APP_NAME%</title>
|
||||
<style>.xtbg-loading {display:inline-block;width:80px;height:80px;background-image:url("/favicon.svg");background-size:40px auto;background-repeat:no-repeat;background-position:center;position:fixed;margin-left:-40px;margin-top:-40px;left:50%;top:50%;}
|
||||
.xtbg-loading:after {content:" ";display:block;width:80px;height:80px;box-sizing:border-box;border-radius:50%;border:4px solid #99bff3;border-color:#99bff3 transparent #99bff3 transparent;animation:xtbg-loading 1.3s linear infinite;}
|
||||
@keyframes xtbg-loading {0% {transform:rotate(0deg);}
|
||||
100% {transform:rotate(360deg);}
|
||||
}</style>
|
||||
%NODE_VCONSOLE_SCRIPST%
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"><div class="xtbg-loading"></div></div>
|
||||
<%- injectScript %>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
Generated
+6873
File diff suppressed because it is too large.
Load diff
+43
-36
@@ -1,48 +1,55 @@
|
||||
{
|
||||
"name": "vue3-template-h5",
|
||||
"description": "一个h5项目",
|
||||
"name": "mytest",
|
||||
"description": "vue3-template-h5",
|
||||
"author": "dengtongyu",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"serve:test": "cross-env VITE_APP_ENV=test vite",
|
||||
"serve:uat": "cross-env VITE_APP_ENV=uat vite",
|
||||
"serve:prod": "cross-env VITE_APP_ENV=prod vite",
|
||||
"build:test": "vue-tsc --noEmit && cross-env VITE_APP_ENV=test vite build",
|
||||
"build:uat": "vue-tsc --noEmit && cross-env VITE_APP_ENV=uat vite build",
|
||||
"build:prod": "vue-tsc --noEmit && cross-env VITE_APP_ENV=prod vite build",
|
||||
"serve:test": "vite --mode test",
|
||||
"serve:uat": "vite --mode uat",
|
||||
"serve": "vite",
|
||||
"build:test": "run-p type-check \"build-only {@}\" -- -- --mode test",
|
||||
"build:uat": "run-p type-check \"build-only {@}\" -- -- --mode uat",
|
||||
"build": "run-p type-check \"build-only {@}\" --",
|
||||
"preview": "vite preview",
|
||||
"lint": "eslint --fix config/*.{ts} && eslint --fix src/*.{ts,vue} && eslint --fix src/**/*.{ts,vue}"
|
||||
"build-only": "vite build",
|
||||
"type-check": "vue-tsc --noEmit -p tsconfig.app.json --composite false",
|
||||
"lint:oxlint": "oxlint . --fix -D correctness --ignore-path .gitignore",
|
||||
"lint:eslint": "eslint . --fix",
|
||||
"lint": "run-s lint:*",
|
||||
"format": "prettier --write src/"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.27.2",
|
||||
"pinia": "^2.0.19",
|
||||
"vant": "^3.5.4",
|
||||
"vue": "^3.2.37",
|
||||
"vue-router": "^4.1.3"
|
||||
"axios": "^1.6.2",
|
||||
"pinia": "^2.1.7",
|
||||
"vant": "^4.8.0",
|
||||
"vue": "^3.3.4",
|
||||
"vue-router": "^4.2.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.11.18",
|
||||
"@typescript-eslint/eslint-plugin": "^5.40.1",
|
||||
"@typescript-eslint/parser": "^5.40.1",
|
||||
"@vitejs/plugin-legacy": "^2.0.1",
|
||||
"@vitejs/plugin-vue": "^3.0.0",
|
||||
"@vue/eslint-config-prettier": "^7.0.0",
|
||||
"@vue/eslint-config-typescript": "^11.0.2",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^8.25.0",
|
||||
"eslint-plugin-html": "^7.1.0",
|
||||
"eslint-plugin-vue": "^9.6.0",
|
||||
"less": "^4.1.3",
|
||||
"postcss-px-to-viewport": "^1.1.1",
|
||||
"prettier": "^2.7.1",
|
||||
"typescript": "^4.6.4",
|
||||
"unplugin-vue-components": "^0.22.4",
|
||||
"vite": "^3.0.9",
|
||||
"vite-plugin-html": "^3.2.0",
|
||||
"vite-plugin-vue-setup-extend": "^0.4.0",
|
||||
"vue-tsc": "^0.38.4"
|
||||
"@oxlint/darwin-x64": "^0.16.9",
|
||||
"@rushstack/eslint-patch": "^1.11.0",
|
||||
"@tsconfig/node18": "^18.2.2",
|
||||
"@types/node": "^18.18.5",
|
||||
"@vitejs/plugin-legacy": "^6.1.1",
|
||||
"@vitejs/plugin-vue": "^5.2.3",
|
||||
"@vitejs/plugin-vue-jsx": "^4.1.2",
|
||||
"@vue/eslint-config-prettier": "^10.2.0",
|
||||
"@vue/eslint-config-typescript": "^14.5.0",
|
||||
"@vue/tsconfig": "^0.4.0",
|
||||
"eslint": "^9.26.0",
|
||||
"eslint-plugin-oxlint": "^0.16.10",
|
||||
"eslint-plugin-vue": "^10.1.0",
|
||||
"less": "^4.2.0",
|
||||
"npm-run-all2": "^6.1.1",
|
||||
"postcss-px-conversion": "^0.0.4",
|
||||
"prettier": "^3.0.3",
|
||||
"terser": "^5.26.0",
|
||||
"typescript": "~5.2.0",
|
||||
"unplugin-auto-import": "^0.17.3",
|
||||
"unplugin-vue-components": "^0.26.0",
|
||||
"vite": "^6.3.5",
|
||||
"vue-tsc": "^1.8.19"
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
import { proxyTarget } from "./config"
|
||||
|
||||
let proxyTable = {
|
||||
"/zuul": {
|
||||
target: proxyTarget,
|
||||
changeOrigin: true
|
||||
},
|
||||
"/media/": {
|
||||
target: proxyTarget,
|
||||
changeOrigin: true
|
||||
},
|
||||
"/zwwxgzt": {
|
||||
target: proxyTarget,
|
||||
changeOrigin: true
|
||||
},
|
||||
"/midjs": {
|
||||
target: proxyTarget,
|
||||
changeOrigin: true
|
||||
},
|
||||
"/irc": {
|
||||
target: proxyTarget,
|
||||
changeOrigin: true
|
||||
},
|
||||
};
|
||||
|
||||
export default proxyTable;
|
||||
+5
-2
@@ -1,6 +1,9 @@
|
||||
<script setup lang="ts" name="App">
|
||||
<script setup lang="ts">
|
||||
defineOptions({
|
||||
name: "App"
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<router-view />
|
||||
<RouterView />
|
||||
</template>
|
||||
@@ -1,6 +1,4 @@
|
||||
import ajax from "../lib/ajax";
|
||||
// import { passid } from "../../config";
|
||||
|
||||
|
||||
const HOST = "/zwwxgzt/workstation";
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import ajax from "../lib/ajax";
|
||||
|
||||
// 获取用户信息
|
||||
const getJsApi = function () {
|
||||
return ajax.get(`/${import.meta.env.VITE_APP_SYSTEMCODE}/jsapi`);
|
||||
};
|
||||
|
||||
const getJSApiTicket = () => {
|
||||
return ajax.get(
|
||||
`/sgbackend/api/r/bc/zwwxapiagent/JSApiTicket?url=${location.href}`
|
||||
);
|
||||
};
|
||||
|
||||
export {
|
||||
getJsApi,
|
||||
getJSApiTicket
|
||||
};
|
||||
@@ -1,12 +1,12 @@
|
||||
<script setup lang="ts" name="HelloWorld">
|
||||
<script setup lang="ts">
|
||||
defineOptions({
|
||||
name: "HelloWorld"
|
||||
});
|
||||
defineProps<{
|
||||
msg?: string;
|
||||
}>();
|
||||
|
||||
const logo = new URL(
|
||||
"../assets/svg/logo.svg",
|
||||
import.meta.url
|
||||
).href;
|
||||
const logo = new URL("../assets/svg/logo.svg",import.meta.url).href;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts" name="IconAndText">
|
||||
import { computed } from "vue";
|
||||
|
||||
<script setup lang="ts">
|
||||
defineOptions({
|
||||
name: "IconAndText"
|
||||
});
|
||||
const props = defineProps<{
|
||||
icon?: string;
|
||||
text?: string;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<script setup lang="ts" name="Abnormal">
|
||||
import { computed } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { ButtonType } from "vant/es/button/types";
|
||||
<script setup lang="ts">
|
||||
import type { LocationQueryValue } from "vue-router";
|
||||
import type { ButtonType } from "vant/es/button/types";
|
||||
import IconAndText from "./iconAndText.vue";
|
||||
|
||||
defineOptions({
|
||||
name: "Abnormal"
|
||||
});
|
||||
interface buttonItem {
|
||||
text: string;
|
||||
code: string;
|
||||
@@ -20,7 +21,7 @@ interface buttonInfo {
|
||||
const props = defineProps<{
|
||||
icon?: string;
|
||||
text?: string;
|
||||
from?: string;
|
||||
from?: LocationQueryValue;
|
||||
buttonHidden?: boolean;
|
||||
buttonList?: Array<string>;
|
||||
}>();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { App } from "vue";
|
||||
import { Button, Empty } from "vant";
|
||||
|
||||
const install = function (app: any) {
|
||||
const install = function (app: App) {
|
||||
app.use(Button);
|
||||
app.use(Empty);
|
||||
};
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ const browser = {
|
||||
android: u.indexOf("Android") > -1 || u.indexOf("Adr") > -1, //android终端
|
||||
iPad: u.indexOf("iPad") > -1, //是否iPad
|
||||
webApp: u.indexOf("Safari") === -1, //是否web应该程序,没有头部与底部
|
||||
zwwx: u.indexOf("zwwx-customized") > -1 //是否政务微信
|
||||
yzy: u.indexOf("zwwx-customized") > -1 //是否粤政易
|
||||
};
|
||||
})()
|
||||
};
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import { getJsApi } from "@/api/wx";
|
||||
import { browser } from "@/lib/util";
|
||||
|
||||
const wxConfig = function (config: any, cb?: Function) {
|
||||
//注入权限配置,获取经纬度
|
||||
window["wx"].config({
|
||||
beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
|
||||
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
||||
appId: config.appid, // 必填,企业微信的corpID
|
||||
timestamp: config.timestamp, // 必填,生成签名的时间戳
|
||||
nonceStr: config.nonce, // 必填,生成签名的随机串
|
||||
signature: config.signature, // 必填,签名,见附录1
|
||||
jsApiList: ["openUrl"] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
|
||||
});
|
||||
window["wx"].ready(function () {
|
||||
console.log("wx.ready");
|
||||
// alert("wx.ready");
|
||||
if (cb) cb();
|
||||
// config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
|
||||
//wx.closeWindow();
|
||||
});
|
||||
window["wx"].error(function (res: any) {
|
||||
// alert("wx.error");
|
||||
// config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
|
||||
console.log("wx.error", res);
|
||||
});
|
||||
};
|
||||
|
||||
// 初始化微信js-sdk配置
|
||||
const initConfig = function (cb?: Function) {
|
||||
getJsApi().then((data: any) => {
|
||||
data && wxConfig(data, cb);
|
||||
});
|
||||
};
|
||||
|
||||
const openWebViewUrl = function (url: string) {
|
||||
if (browser.versions.yzy) {
|
||||
window["wx"].invoke(
|
||||
"openUrl",
|
||||
{
|
||||
type: 0, //0或不填表示使用内部浏览器新窗口打开,1表示用系统浏览器打开
|
||||
url: url //url地址
|
||||
},
|
||||
(res: any) => {
|
||||
console.log("打开新窗口回调:", res);
|
||||
if (res.err_msg === "openUrl:ok") {
|
||||
console.log("打开新窗口成功");
|
||||
} else {
|
||||
//错误处理
|
||||
if (res.err_msg === "openUrl:need_real_time_auth") {
|
||||
initConfig(() => {
|
||||
if (url) {
|
||||
openWebViewUrl(url);
|
||||
}
|
||||
});
|
||||
}
|
||||
console.log("打开新窗口出错:", res.err_msg);
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
window.location.href = url;
|
||||
}
|
||||
};
|
||||
|
||||
export {
|
||||
initConfig,
|
||||
openWebViewUrl
|
||||
};
|
||||
+1
-2
@@ -1,9 +1,8 @@
|
||||
import { createApp } from "vue";
|
||||
import "./styles/index.less";
|
||||
import routes from "./routes";
|
||||
import App from "./App.vue";
|
||||
import pinia from "./store/pinia";
|
||||
import { install } from "./installComponents";
|
||||
import "./styles/index.less";
|
||||
|
||||
const app = createApp(App);
|
||||
app.use(pinia);
|
||||
|
||||
+5
-4
@@ -1,8 +1,9 @@
|
||||
<script setup lang="ts" name="Home">
|
||||
import { ref } from "vue";
|
||||
<script setup lang="ts">
|
||||
import HelloWorld from "../components/HelloWorld.vue";
|
||||
import { baseInfo } from "../store";
|
||||
|
||||
defineOptions({
|
||||
name: "Home"
|
||||
});
|
||||
const baseInfoStore = baseInfo();
|
||||
const user = baseInfoStore.userInfo;
|
||||
|
||||
@@ -11,7 +12,7 @@ const count = ref(0);
|
||||
|
||||
<template>
|
||||
<div class="home">
|
||||
<hello-world :msg="user.name" />
|
||||
<HelloWorld :msg="user.name" />
|
||||
<p>{{count}}</p>
|
||||
<van-button type="primary" @click="count++">按钮</van-button>
|
||||
</div>
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
<script setup lang="ts" name="Login">
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
<script setup lang="ts">
|
||||
import type { LocationQueryValue } from "vue-router";
|
||||
import pinia from "../store/pinia";
|
||||
import { baseInfo } from "../store";
|
||||
|
||||
defineOptions({
|
||||
name: "Initing"
|
||||
});
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const baseInfoStore = baseInfo(pinia);
|
||||
const rediret: any = route.query.rediret;
|
||||
const rediret: LocationQueryValue | LocationQueryValue[] = route.query.rediret;
|
||||
|
||||
baseInfoStore
|
||||
.loginUserInfo()
|
||||
@@ -15,7 +17,7 @@ baseInfoStore
|
||||
const { errcode, errmsg } = res;
|
||||
if (errcode === 401) return;
|
||||
if (errcode === 0) {
|
||||
router.replace(rediret);
|
||||
router.replace(rediret as string);
|
||||
}
|
||||
else if (errcode === 400) {
|
||||
router.replace({
|
||||
@@ -1,14 +1,16 @@
|
||||
<script setup lang="ts" name="DeviceAbnormal">
|
||||
import { useRoute } from "vue-router";
|
||||
<script setup lang="ts">
|
||||
import type { LocationQueryValue } from "vue-router";
|
||||
import Abnormal from "@/components/abnormal/index.vue";
|
||||
|
||||
defineOptions({
|
||||
name: "DeviceAbnormal"
|
||||
});
|
||||
defineProps<{
|
||||
text?: string;
|
||||
}>();
|
||||
|
||||
const route = useRoute();
|
||||
const from: any = route.query.from;
|
||||
const msg: any = route.query.text;
|
||||
const from: LocationQueryValue = route.query.from as LocationQueryValue;
|
||||
const msg: LocationQueryValue = route.query.text as LocationQueryValue;
|
||||
|
||||
const icon = new URL("../../assets/svg/device_abnormal.svg", import.meta.url).href;
|
||||
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
<script setup lang="ts" name="404">
|
||||
import { useRoute } from "vue-router";
|
||||
<script setup lang="ts">
|
||||
import type { LocationQueryValue } from "vue-router";
|
||||
import Abnormal from "@/components/abnormal/index.vue";
|
||||
|
||||
defineOptions({
|
||||
name: "Error404"
|
||||
});
|
||||
defineProps<{
|
||||
text?: string;
|
||||
}>();
|
||||
|
||||
const route = useRoute();
|
||||
const from: any = route.query.from;
|
||||
const from: LocationQueryValue = route.query.from as LocationQueryValue;
|
||||
|
||||
|
||||
const icon = new URL("../../assets/svg/404.svg", import.meta.url).href;
|
||||
@@ -1,14 +1,16 @@
|
||||
<script setup lang="ts" name="500">
|
||||
import { useRoute } from "vue-router";
|
||||
<script setup lang="ts">
|
||||
import type { LocationQueryValue } from "vue-router";
|
||||
import Abnormal from "../../components/abnormal/index.vue";
|
||||
|
||||
defineOptions({
|
||||
name: "Error500"
|
||||
});
|
||||
defineProps<{
|
||||
text?: string;
|
||||
}>();
|
||||
|
||||
const route = useRoute();
|
||||
const from: any = route.query.from;
|
||||
const msg: any = route.query.text;
|
||||
const from: LocationQueryValue = route.query.from as LocationQueryValue;
|
||||
const msg: LocationQueryValue = route.query.text as LocationQueryValue;
|
||||
|
||||
const icon = new URL("../../assets/svg/500.svg", import.meta.url).href;
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
<script setup lang="ts" name="Failed">
|
||||
import { useRoute } from "vue-router";
|
||||
<script setup lang="ts">
|
||||
import type { LocationQueryValue } from "vue-router";
|
||||
import Abnormal from "@/components/abnormal/index.vue";
|
||||
|
||||
defineOptions({
|
||||
name: "Failed"
|
||||
});
|
||||
defineProps<{
|
||||
text?: string;
|
||||
}>();
|
||||
|
||||
const route = useRoute();
|
||||
const from: any = route.query.from;
|
||||
const msg: any = route.query.text;
|
||||
const from: LocationQueryValue = route.query.from as LocationQueryValue;
|
||||
const msg: LocationQueryValue = route.query.text as LocationQueryValue;
|
||||
|
||||
const icon = new URL("../../assets/svg/failed.svg", import.meta.url).href;
|
||||
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
<script setup lang="ts" name="NoAccess">
|
||||
import { useRoute } from "vue-router";
|
||||
<script setup lang="ts">
|
||||
import type { LocationQueryValue } from "vue-router";
|
||||
import Abnormal from "@/components/abnormal/index.vue";
|
||||
|
||||
defineOptions({
|
||||
name: "NoAccess"
|
||||
});
|
||||
defineProps<{
|
||||
text?: string;
|
||||
}>();
|
||||
|
||||
const route = useRoute();
|
||||
const from: any = route.query.from;
|
||||
const msg: any = route.query.text;
|
||||
const from: LocationQueryValue = route.query.from as LocationQueryValue;
|
||||
const msg: LocationQueryValue = route.query.text as LocationQueryValue;
|
||||
|
||||
const icon = new URL("../../assets/svg/no_permission.svg", import.meta.url).href;
|
||||
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
<script setup lang="ts" name="NoNetwork">
|
||||
import { useRoute } from "vue-router";
|
||||
<script setup lang="ts">
|
||||
import type { LocationQueryValue } from "vue-router";
|
||||
import Abnormal from "@/components/abnormal/index.vue";
|
||||
|
||||
defineOptions({
|
||||
name: "NoData"
|
||||
});
|
||||
defineProps<{
|
||||
text?: string;
|
||||
}>();
|
||||
|
||||
const route = useRoute();
|
||||
const from: any = route.query.from;
|
||||
const msg: any = route.query.text;
|
||||
const from: LocationQueryValue = route.query.from as LocationQueryValue;
|
||||
const msg: LocationQueryValue = route.query.text as LocationQueryValue;
|
||||
|
||||
const icon = new URL("../../assets/svg/no_data.svg", import.meta.url).href;
|
||||
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
<script setup lang="ts" name="NoNetwork">
|
||||
import { useRoute } from "vue-router";
|
||||
<script setup lang="ts">
|
||||
import type { LocationQueryValue } from "vue-router";
|
||||
import Abnormal from "@/components/abnormal/index.vue";
|
||||
|
||||
defineOptions({
|
||||
name: "NoNetwork"
|
||||
});
|
||||
defineProps<{
|
||||
text?: string;
|
||||
}>();
|
||||
|
||||
const route = useRoute();
|
||||
const from: any = route.query.from;
|
||||
const msg: any = route.query.text;
|
||||
const from: LocationQueryValue = route.query.from as LocationQueryValue;
|
||||
const msg: LocationQueryValue = route.query.text as LocationQueryValue;
|
||||
|
||||
const icon = new URL("../../assets/svg/no_network.svg", import.meta.url).href;
|
||||
|
||||
|
||||
+2
-3
@@ -1,4 +1,3 @@
|
||||
import { createWebHashHistory, createRouter } from "vue-router";
|
||||
import routes from "./routes";
|
||||
import pinia from "../store/pinia";
|
||||
import { baseInfo } from "../store";
|
||||
@@ -14,12 +13,12 @@ const router = createRouter({
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.meta && to.meta.power) {
|
||||
const user = baseInfoStore.userInfo.value;
|
||||
const user = baseInfoStore.userInfo;
|
||||
if (user.uin) {
|
||||
next();
|
||||
} else {
|
||||
next({
|
||||
path: "/loginfo",
|
||||
path: "/initing",
|
||||
query: {
|
||||
rediret: to.fullPath
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
const routes = [
|
||||
{ path: "/", name: "root", redirect: "/home" },
|
||||
{ path: "/home", name: "home", meta: { power: true }, component: () => import("../pages/Home.vue") },
|
||||
{ path: "/loginfo", name: "loginfo", component: () => import("../pages/Login.vue") },
|
||||
{ path: "/initing", name: "initing", component: () => import("../pages/Initing.vue") },
|
||||
{ path: "/nonetwork:text?", name: "nonetwork", props: true, component: () => import("../pages/error/NoNetwork.vue") },
|
||||
{ path: "/noaccess/:text?", name: "noaccess", props: true, component: () => import("../pages/error/NoAccess.vue") },
|
||||
{ path: "/empty/:text?", name: "empty", props: true, component: () => import("../pages/error/NoData.vue") },
|
||||
{ path: "/deviceabnormal/:text?", name: "deviceabnormal", props: true, component: () => import("../pages/error/DeviceAbnormal.vue") },
|
||||
{ path: "/failed/:text?", name: "failed", props: true, component: () => import("../pages/error/Failed.vue") },
|
||||
{ path: "/500/:text?", name: "500", props: true, component: () => import("../pages/error/500.vue") },
|
||||
{ path: "/404", name: "404", component: () => import("../pages/error/404.vue") },
|
||||
{ path: "/500/:text?", name: "error500", props: true, component: () => import("../pages/error/Error500.vue") },
|
||||
{ path: "/404", name: "error404", component: () => import("../pages/error/Error404.vue") },
|
||||
{ path: "/:catchAll(.*)", redirect: "/404", hidden: true }
|
||||
];
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ref, computed } from "vue";
|
||||
import { getUserInfo } from "../api";
|
||||
|
||||
const baseInfo = defineStore("baseInfo", () => {
|
||||
@@ -21,7 +19,7 @@ const baseInfo = defineStore("baseInfo", () => {
|
||||
});
|
||||
};
|
||||
const userInfo = computed(() => {
|
||||
return user;
|
||||
return user.value;
|
||||
});
|
||||
|
||||
return { loginUserInfo, userInfo };
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { createPinia } from "pinia";
|
||||
|
||||
const pinia = createPinia();
|
||||
|
||||
export default pinia;
|
||||
+45
-20
@@ -1,38 +1,58 @@
|
||||
:root {
|
||||
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
|
||||
font-size: 16px;
|
||||
line-height: 24px;
|
||||
font-weight: 400;
|
||||
|
||||
color-scheme: light dark;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
background-color: #242424;
|
||||
|
||||
font-synthesis: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
}
|
||||
|
||||
html,
|
||||
body,
|
||||
#app {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
div,
|
||||
dl,
|
||||
dt,
|
||||
dd,
|
||||
ul,
|
||||
ol,
|
||||
li,
|
||||
p,
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
h6,
|
||||
pre,
|
||||
code,
|
||||
form,
|
||||
fieldset,
|
||||
legend,
|
||||
input,
|
||||
textarea,
|
||||
p,
|
||||
blockquote,
|
||||
th,
|
||||
td,
|
||||
hr,
|
||||
button,
|
||||
article,
|
||||
aside,
|
||||
details,
|
||||
figcaption,
|
||||
figure,
|
||||
footer,
|
||||
header,
|
||||
hgroup,
|
||||
menu,
|
||||
nav,
|
||||
section {
|
||||
margin: 0;
|
||||
padding: 0
|
||||
}
|
||||
|
||||
html,body {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
}
|
||||
#app {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#app {
|
||||
@@ -48,15 +68,18 @@
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
&-image {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
|
||||
&>img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
||||
&-text {
|
||||
margin-top: 10px;
|
||||
padding: 0 16px;
|
||||
@@ -64,11 +87,13 @@
|
||||
color: #888;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
&-btn {
|
||||
margin-top: 20px;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
&-class {
|
||||
min-width: 100px;
|
||||
margin: 0 8px !important;
|
||||
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
declare module "*.vue" {
|
||||
import type { DefineComponent } from "vue";
|
||||
const component: DefineComponent<{}, {}, any>;
|
||||
export default component;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
import axios from "axios";
|
||||
|
||||
// 初始化微信js-sdk配置
|
||||
const initConfig = (config: any) => {
|
||||
function jsdkCB(data: any) {
|
||||
let jsApiList = ["showWatermark"];
|
||||
if (typeof window.wx !== "object") {
|
||||
return;
|
||||
}
|
||||
if (!config) {
|
||||
config = {};
|
||||
}
|
||||
jsApiList = jsApiList.concat(config.jsApiList || []);
|
||||
const wxError = {
|
||||
status: "",
|
||||
errmsg: "配置失败,请退出重试"
|
||||
};
|
||||
if (data.appid) {
|
||||
window.wx.config({
|
||||
beta: true,
|
||||
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
||||
appId: data.appid, // 必填,政务微信的cropID
|
||||
timestamp: data.timestamp, // 必填,生成签名的时间戳
|
||||
nonceStr: data.nonce, // 必填,生成签名的随机串
|
||||
signature: data.signature, // 必填,签名,见附录1
|
||||
jsApiList: jsApiList // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
|
||||
});
|
||||
window.wx.ready(function (e: any) {
|
||||
console.log("config注册成功");
|
||||
// window['_initSuccess'] = true;
|
||||
// 注册政务微信权限API,需要AgentId
|
||||
// wxApi.registerAgentConfig(data, config);
|
||||
typeof config.sucesscb === "function" && config.sucesscb(e);
|
||||
});
|
||||
window.wx.error(function (e: any) {
|
||||
console.log("initConfig wx error:", e);
|
||||
typeof config.errorcb === "function" && config.errorcb(wxError);
|
||||
});
|
||||
}
|
||||
}
|
||||
axios.get("/zwwxgzt/jsapi").then((res) => {
|
||||
res && jsdkCB(res);
|
||||
});
|
||||
};
|
||||
|
||||
export {
|
||||
initConfig
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
},
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
},
|
||||
"include": ["*.d.ts", "src/**/*", "src/**/*.vue", "src/**/*.json"],
|
||||
"exclude": ["src/**/__tests__/*"],
|
||||
}
|
||||
+3
-39
@@ -1,43 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"strict": true,
|
||||
"jsx": "preserve",
|
||||
"sourceMap": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"esModuleInterop": true,
|
||||
"lib": [
|
||||
"ESNext",
|
||||
"DOM"
|
||||
],
|
||||
"skipLibCheck": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"baseUrl": "./",
|
||||
"paths": {
|
||||
"@/*": [
|
||||
"src/*"
|
||||
]
|
||||
},
|
||||
"types": [
|
||||
"vite/client",
|
||||
"node"
|
||||
],
|
||||
},
|
||||
"include": [
|
||||
"./*.d.ts",
|
||||
"src/**/*.ts",
|
||||
"src/**/*.d.ts",
|
||||
"src/**/*.tsx",
|
||||
"src/**/*.vue",
|
||||
"config/**/*.ts"
|
||||
],
|
||||
"files": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.node.json"
|
||||
}
|
||||
{ "path": "./tsconfig.app.json" },
|
||||
{ "path": "./tsconfig.node.json" }
|
||||
]
|
||||
}
|
||||
+24
-4
@@ -1,9 +1,29 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2023"],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"allowSyntheticDefaultImports": true
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
},
|
||||
"include": ["vite.config.ts", "proxy.config.ts", "config/**/*.ts", "./*.d.ts",]
|
||||
"include": [
|
||||
"vite.config.ts",
|
||||
"src/styles/theme.json",
|
||||
"vite.util.ts"
|
||||
],
|
||||
}
|
||||
+44
-70
@@ -1,101 +1,75 @@
|
||||
import { fileURLToPath, URL } from "node:url";
|
||||
import { defineConfig, loadEnv } from "vite";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
import vueJsx from "@vitejs/plugin-vue-jsx";
|
||||
import AutoImport from "unplugin-auto-import/vite";
|
||||
import Components from "unplugin-vue-components/vite";
|
||||
import { VantResolver } from "unplugin-vue-components/resolvers";
|
||||
import postcsspxtoviewport from "postcss-px-to-viewport";
|
||||
import { createHtmlPlugin } from "vite-plugin-html";
|
||||
import VueSetupExtend from "vite-plugin-vue-setup-extend";
|
||||
import postcssPxConversion from "postcss-px-conversion";
|
||||
import legacy from "@vitejs/plugin-legacy";
|
||||
import proxyConfig from "./proxy.config";
|
||||
import { appName, injectScriptStr } from "./config";
|
||||
import path from "path";
|
||||
import {
|
||||
setCrossoriginUseCredentials,
|
||||
injectHtmlVars,
|
||||
proxyConfig
|
||||
} from "./vite.util";
|
||||
|
||||
type enforceType = "post" | "pre";
|
||||
const enforceValue:enforceType = "post";
|
||||
const setCrossoriginUseCredentials = () => {
|
||||
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
const envDir = `${process.cwd()}/env`;
|
||||
const env = loadEnv(mode, envDir, "NODE_");
|
||||
return {
|
||||
name: "set-crossorigin",
|
||||
enforce: enforceValue,
|
||||
transformIndexHtml(html) {
|
||||
return html.replace(/crossorigin/g, "crossorigin=\"use-credentials\"");
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default (opt: any) => {
|
||||
const { mode } = opt;
|
||||
const env: any = loadEnv(mode, process.cwd());
|
||||
|
||||
return defineConfig({
|
||||
base: "./",
|
||||
envDir: "./env",
|
||||
build: {
|
||||
target: "es2015"
|
||||
},
|
||||
plugins: [
|
||||
createHtmlPlugin({
|
||||
inject: {
|
||||
data: {
|
||||
title: appName,
|
||||
injectScript: injectScriptStr
|
||||
}
|
||||
vue(),
|
||||
vueJsx(),
|
||||
AutoImport({
|
||||
imports: ["vue", "pinia", {
|
||||
"vue-router": [
|
||||
"useLink",
|
||||
"useRoute",
|
||||
"useRouter",
|
||||
"onBeforeRouteLeave",
|
||||
"onBeforeRouteUpdate",
|
||||
"createRouter",
|
||||
"createWebHistory",
|
||||
"createWebHashHistory"
|
||||
]
|
||||
}],
|
||||
eslintrc: {
|
||||
// 会在项目根目录自动生成.eslintrc-auto-import.json
|
||||
enabled: true
|
||||
}
|
||||
}),
|
||||
vue(),
|
||||
VueSetupExtend(),
|
||||
Components({
|
||||
resolvers: [VantResolver()]
|
||||
}),
|
||||
legacy({
|
||||
// targets: ['defaults', 'not IE 11'],
|
||||
targets: ["chrome 52"],
|
||||
additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
|
||||
renderLegacyChunks: true,
|
||||
polyfills: [
|
||||
"es.symbol",
|
||||
"es.array.filter",
|
||||
"es.promise",
|
||||
"es.promise.finally",
|
||||
"es/map",
|
||||
"es/set",
|
||||
"es.array.for-each",
|
||||
"es.object.define-properties",
|
||||
"es.object.define-property",
|
||||
"es.object.get-own-property-descriptor",
|
||||
"es.object.get-own-property-descriptors",
|
||||
"es.object.keys",
|
||||
"es.object.to-string",
|
||||
"web.dom-collections.for-each",
|
||||
"esnext.global-this",
|
||||
"esnext.string.match-all"
|
||||
]
|
||||
targets: ["chrome 87"]
|
||||
}),
|
||||
setCrossoriginUseCredentials()
|
||||
setCrossoriginUseCredentials(),
|
||||
injectHtmlVars(env)
|
||||
],
|
||||
css: {
|
||||
preprocessorOptions: {
|
||||
less: {
|
||||
javascriptEnabled: true
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": fileURLToPath(new URL("./src", import.meta.url))
|
||||
}
|
||||
},
|
||||
css: {
|
||||
postcss: {
|
||||
plugins: [
|
||||
postcsspxtoviewport({
|
||||
postcssPxConversion({
|
||||
viewportWidth: 375
|
||||
})
|
||||
]
|
||||
}
|
||||
},
|
||||
server: {
|
||||
proxy: proxyConfig
|
||||
proxy: proxyConfig(env)
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": path.resolve(__dirname, "src")
|
||||
build: {
|
||||
modulePreload: false
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
type enforceType = "post" | "pre";
|
||||
const enforceValue: enforceType = "post";
|
||||
|
||||
const setCrossoriginUseCredentials = () => {
|
||||
return {
|
||||
name: "set-crossorigin",
|
||||
enforce: enforceValue,
|
||||
transformIndexHtml(html: string) {
|
||||
return html.replace(/crossorigin/g, "crossorigin=\"use-credentials\"");
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const injectHtmlVars = (env: Record<string, string>) => {
|
||||
return {
|
||||
name: "inject-html-vars",
|
||||
enforce: enforceValue,
|
||||
transformIndexHtml(html: string) {
|
||||
let str = html;
|
||||
for (const key in env) {
|
||||
if (Object.prototype.hasOwnProperty.call(env, key)) {
|
||||
const element = env[key];
|
||||
const reg = new RegExp(`%${key}%`, "g");
|
||||
str = str.replace(reg, element);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const proxyConfig = (env: Record<string, string>) => {
|
||||
const { NODE_PROXY_TARGET } = env;
|
||||
const proxyTarget = NODE_PROXY_TARGET || "";
|
||||
const proxyTable = {
|
||||
"/zuul": {
|
||||
target: proxyTarget,
|
||||
changeOrigin: true
|
||||
},
|
||||
"/media/": {
|
||||
target: proxyTarget,
|
||||
changeOrigin: true
|
||||
},
|
||||
"/zwwxgzt": {
|
||||
target: proxyTarget,
|
||||
changeOrigin: true
|
||||
},
|
||||
"/midjs": {
|
||||
target: proxyTarget,
|
||||
changeOrigin: true
|
||||
},
|
||||
"/irc": {
|
||||
target: proxyTarget,
|
||||
changeOrigin: true
|
||||
}
|
||||
};
|
||||
return proxyTable;
|
||||
};
|
||||
|
||||
export default {
|
||||
setCrossoriginUseCredentials,
|
||||
injectHtmlVars,
|
||||
proxyConfig
|
||||
};
|
||||
|
||||
export {
|
||||
setCrossoriginUseCredentials,
|
||||
injectHtmlVars,
|
||||
proxyConfig
|
||||
};
|
||||
Reference in new issue
Block a user