This commit is contained in:
bwcx_jzy 2023-04-09 17:44:47 +08:00
parent 3737bdc922
commit f83f321b0e
No known key found for this signature in database
GPG Key ID: 5E48E9372088B9E5
11 changed files with 339 additions and 242 deletions

View File

@ -3,5 +3,6 @@
"singleQuote": true,
"endOfLine": "lf",
"proseWrap": "never",
"printWidth": 120
"printWidth": 120,
"trailingComma": "none"
}

View File

@ -42,6 +42,8 @@
"eslint": "^8.36.0",
"https": "^1.0.0",
"typescript": "^5.0.2",
"unplugin-auto-import": "^0.15.2",
"unplugin-vue-components": "^0.24.1",
"vite": "^4.1.0",
"vite-plugin-html": "^3.2.0"
}

View File

@ -9,33 +9,30 @@
</a-config-provider>
</template>
<script lang="ts">
<script setup lang="ts">
import zhCN from 'ant-design-vue/es/locale/zh_CN'
import { notification, message } from 'ant-design-vue'
import { onMounted, provide, computed } from 'vue'
import { onMounted, provide } from 'vue'
import { useMenuStore } from '@/stores/menu'
const { proxy }: any = getCurrentInstance()
onMounted(() => {
notification.config({
proxy.$notification.config({
top: '100px',
duration: 4,
duration: 4
})
message.config({ duration: 4 })
proxy.$message.config({ duration: 4 })
})
const reload = () => {
const menuStore = useMenuStore()
//
menuStore.restLoadSystemMenus();
menuStore.restLoadSystemMenus()
}
provide('app', {
reload,
reload
})
</script>
<style lang="less">

View File

@ -1,34 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Code Technology Studio
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// base library
import type { Component } from 'vue'
import { message, notification } from 'ant-design-vue'
const components: {
[propName: string]: Component //字面量类型,每个属性值类型为组件的类型
} = {
message,
notification,
}
export default components

68
web-vue3/src/d.ts/auto-import.d.ts vendored Normal file
View File

@ -0,0 +1,68 @@
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-auto-import
export {}
declare global {
const EffectScope: typeof import('vue')['EffectScope']
const computed: typeof import('vue')['computed']
const createApp: typeof import('vue')['createApp']
const customRef: typeof import('vue')['customRef']
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
const defineComponent: typeof import('vue')['defineComponent']
const effectScope: typeof import('vue')['effectScope']
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 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 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 shallowReactive: typeof import('vue')['shallowReactive']
const shallowReadonly: typeof import('vue')['shallowReadonly']
const shallowRef: typeof import('vue')['shallowRef']
const toRaw: typeof import('vue')['toRaw']
const toRef: typeof import('vue')['toRef']
const toRefs: typeof import('vue')['toRefs']
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 useLink: typeof import('vue-router')['useLink']
const useRoute: typeof import('vue-router')['useRoute']
const useRouter: typeof import('vue-router')['useRouter']
const useSlots: typeof import('vue')['useSlots']
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, InjectionKey, PropType, Ref, VNode } from 'vue'
}

43
web-vue3/src/d.ts/components.d.ts vendored Normal file
View File

@ -0,0 +1,43 @@
/* 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' {
export interface GlobalComponents {
AAlert: typeof import('ant-design-vue/es')['Alert']
ABackTop: typeof import('ant-design-vue/es')['BackTop']
AButton: typeof import('ant-design-vue/es')['Button']
ACard: typeof import('ant-design-vue/es')['Card']
ACardMeta: typeof import('ant-design-vue/es')['CardMeta']
ACol: typeof import('ant-design-vue/es')['Col']
AConfigProvider: typeof import('ant-design-vue/es')['ConfigProvider']
ADivider: typeof import('ant-design-vue/es')['Divider']
AForm: typeof import('ant-design-vue/es')['Form']
AFormItem: typeof import('ant-design-vue/es')['FormItem']
AInput: typeof import('ant-design-vue/es')['Input']
AInputGroup: typeof import('ant-design-vue/es')['InputGroup']
AInputPassword: typeof import('ant-design-vue/es')['InputPassword']
AResult: typeof import('ant-design-vue/es')['Result']
ARow: typeof import('ant-design-vue/es')['Row']
ASpace: typeof import('ant-design-vue/es')['Space']
AStep: typeof import('ant-design-vue/es')['Step']
ASteps: typeof import('ant-design-vue/es')['Steps']
ATypographyParagraph: typeof import('ant-design-vue/es')['TypographyParagraph']
CodeEditor: typeof import('./../components/codeEditor/index.vue')['default']
CompositionTransfer: typeof import('./../components/compositionTransfer/composition-transfer.vue')['default']
CustomSelect: typeof import('./../components/customSelect/index.vue')['default']
LogView: typeof import('./../components/logView/index.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
SolutionOutlined: typeof import('@ant-design/icons-vue')['SolutionOutlined']
Terminal: typeof import('./../components/terminal/index.vue')['default']
Upgrade: typeof import('./../components/upgrade/index.vue')['default']
UserOutlined: typeof import('@ant-design/icons-vue')['UserOutlined']
ViewPre: typeof import('./../components/logView/view-pre.vue')['default']
}
}

View File

@ -1,23 +1,25 @@
import { createApp } from 'vue'
import '@/assets/style.css'
import '@/assets/reset.less'
import App from './App.vue'
import Antd from 'ant-design-vue'
import router from './router'
import globalComponent from '@/components/lazy_antd'
import { createPinia } from 'pinia'
const pinia = createPinia()
import { message, notification, Modal } from 'ant-design-vue'
import 'ant-design-vue/dist/antd.css'
const pinia = createPinia()
const app = createApp(App)
app.use(Antd).use(router).use(pinia)
// 注册全局的组件 (对所有需要注册的组件进行遍历并注册)
for (const componentItme in globalComponent) {
app.component(componentItme, globalComponent[componentItme])
}
// 注册全局的组件
app.config.globalProperties.$message = message
app.config.globalProperties.$notification = notification
//
app.config.globalProperties.$confirm = Modal.confirm
app.config.globalProperties.$info = Modal.info
app.config.globalProperties.$error = Modal.error
app.config.globalProperties.$warning = Modal.warning
app.config.globalProperties.$success = Modal.success
app.mount('#app')

View File

@ -80,8 +80,8 @@
{ required: true, message: '请输入密码' },
{
pattern: /^(?![\d]+$)(?![a-zA-Z]+$)(?![^\da-zA-Z]+$).{6,18}$/,
message: '密码必须包含数字字母字符且大于6位',
},
message: '密码必须包含数字字母字符且大于6位'
}
]"
>
<a-input-password v-model:value="loginForm.userPwd" placeholder="密码6-18位数字、字母、符号组合" />
@ -137,7 +137,7 @@
name="twoCode"
:rules="[
{ required: true, message: '请输入两步验证码' },
{ pattern: /^\d{6}$/, message: '验证码 6 为纯数字' },
{ pattern: /^\d{6}$/, message: '验证码 6 为纯数字' }
]"
>
<a-input v-model:value="mfaForm.twoCode" placeholder="两步验证码" />
@ -174,23 +174,22 @@ import { MFA_APP_TIP_ARRAY } from '@/utils/const'
import sha1 from 'js-sha1'
import { checkSystem } from '@/api/install'
import { initInstall } from '@/api/install'
import { onMounted, reactive, ref } from 'vue'
import { UserOutlined, SolutionOutlined } from '@ant-design/icons-vue'
// import { onMounted, reactive, ref } from 'vue'
import QrcodeVue from 'qrcode.vue'
import { Modal, notification } from 'ant-design-vue'
import { useUserStore } from '@/stores/user'
import { useAppStore } from '@/stores/app'
import { useRouter } from 'vue-router'
const { proxy }: any = getCurrentInstance()
const router = useRouter()
const loginForm = reactive({
userName: '',
userPwd: '',
userPwd: ''
})
const mfaForm = reactive({
twoCode: '',
mfa: '',
mfa: ''
})
const setpCurrent = ref(0)
@ -198,22 +197,22 @@ const canInstall = ref(true)
const qrCode = reactive({
value: '',
size: 120,
size: 120
})
// login
const handleLogin = (values: any) => {
const params = {
...values,
userPwd: sha1(values.userPwd),
userPwd: sha1(values.userPwd)
}
initInstall(params).then((res) => {
const userStore = useUserStore()
const appStore = useAppStore()
//
if (res.code === 200) {
notification.success({
message: res.msg,
proxy.$notification.success({
message: res.msg
})
const tokenData = res.data.tokenData
mfaForm.mfa = res.data.mfaKey
@ -230,8 +229,8 @@ const handleLogin = (values: any) => {
const handleMfaSure = () => {
bindMfa(mfaForm).then((res) => {
if (res.code === 200) {
notification.success({
message: res.msg,
proxy.$notification.success({
message: res.msg
})
// ;
router.push({ path: '/' })
@ -241,14 +240,14 @@ const handleMfaSure = () => {
// mfa
const handleIgnoreBindMfa = () => {
Modal.confirm({
proxy.$confirm({
title: '系统提示',
content: '确定要忽略绑定两步验证吗?强烈建议超级管理员开启两步验证来保证账号安全性',
okText: '确认',
cancelText: '取消',
onOk: () => {
router.push({ path: '/' })
},
}
})
}

View File

@ -23,170 +23,170 @@
// https://github.com/hua1995116/ansi-color-parse
const ansiparse = function (str) {
//
// I'm terrible at writing parsers.
//
var matchingControl = null,
matchingData = null,
matchingText = "",
ansiState = [],
result = [],
state = {},
eraseChar;
//
// I'm terrible at writing parsers.
//
var matchingControl = null,
matchingData = null,
matchingText = '',
ansiState = [],
result = [],
state = {},
eraseChar
//
// General workflow for this thing is:
// \033\[33mText
// | | |
// | | matchingText
// | matchingData
// matchingControl
//
// In further steps we hope it's all going to be fine. It usually is.
//
//
// General workflow for this thing is:
// \033\[33mText
// | | |
// | | matchingText
// | matchingData
// matchingControl
//
// In further steps we hope it's all going to be fine. It usually is.
//
//
// Erases a char from the output
//
eraseChar = function () {
var index, text;
if (matchingText.length) {
matchingText = matchingText.substr(0, matchingText.length - 1);
} else if (result.length) {
index = result.length - 1;
text = result[index].text;
if (text.length === 1) {
//
// A result bit was fully deleted, pop it out to simplify the final output
//
result.pop();
} else {
result[index].text = text.substr(0, text.length - 1);
}
}
};
//
// Erases a char from the output
//
eraseChar = function () {
var index, text
if (matchingText.length) {
matchingText = matchingText.substr(0, matchingText.length - 1)
} else if (result.length) {
index = result.length - 1
text = result[index].text
if (text.length === 1) {
//
// A result bit was fully deleted, pop it out to simplify the final output
//
result.pop()
} else {
result[index].text = text.substr(0, text.length - 1)
}
}
}
for (var i = 0; i < str.length; i++) {
if (matchingControl != null) {
if (matchingControl == "\x1b" && str[i] == "[") {
//
// We've matched full control code. Lets start matching formating data.
//
for (var i = 0; i < str.length; i++) {
if (matchingControl != null) {
if (matchingControl == '\x1b' && str[i] == '[') {
//
// We've matched full control code. Lets start matching formating data.
//
//
// "emit" matched text with correct state
//
if (matchingText) {
state.text = matchingText;
result.push(state);
state = {};
matchingText = "";
}
//
// "emit" matched text with correct state
//
if (matchingText) {
state.text = matchingText
result.push(state)
state = {}
matchingText = ''
}
matchingControl = null;
matchingData = "";
} else {
//
// We failed to match anything - most likely a bad control code. We
// go back to matching regular strings.
//
matchingText += matchingControl + str[i];
matchingControl = null;
}
continue;
} else if (matchingData != null) {
if (str[i] == ";") {
//
// `;` separates many formatting codes, for example: `\033[33;43m`
// means that both `33` and `43` should be applied.
//
// TODO: this can be simplified by modifying state here.
//
ansiState.push(matchingData);
matchingData = "";
} else if (str[i] == "m") {
//
// `m` finished whole formatting code. We can proceed to matching
// formatted text.
//
ansiState.push(matchingData);
matchingData = null;
matchingText = "";
matchingControl = null
matchingData = ''
} else {
//
// We failed to match anything - most likely a bad control code. We
// go back to matching regular strings.
//
matchingText += matchingControl + str[i]
matchingControl = null
}
continue
} else if (matchingData != null) {
if (str[i] == ';') {
//
// `;` separates many formatting codes, for example: `\033[33;43m`
// means that both `33` and `43` should be applied.
//
// TODO: this can be simplified by modifying state here.
//
ansiState.push(matchingData)
matchingData = ''
} else if (str[i] == 'm') {
//
// `m` finished whole formatting code. We can proceed to matching
// formatted text.
//
ansiState.push(matchingData)
matchingData = null
matchingText = ''
//
// Convert matched formatting data into user-friendly state object.
//
// TODO: DRY.
//
ansiState.forEach(function (ansiCode) {
if (ansiparse.foregroundColors[ansiCode]) {
state.foreground = ansiparse.foregroundColors[ansiCode];
} else if (ansiparse.backgroundColors[ansiCode]) {
state.background = ansiparse.backgroundColors[ansiCode];
} else if (ansiCode == 39) {
delete state.foreground;
} else if (ansiCode == 49) {
delete state.background;
} else if (ansiparse.styles[ansiCode]) {
state[ansiparse.styles[ansiCode]] = true;
} else if (ansiCode == 22) {
state.bold = false;
} else if (ansiCode == 23) {
state.italic = false;
} else if (ansiCode == 24) {
state.underline = false;
}
});
ansiState = [];
} else {
matchingData += str[i];
}
continue;
}
//
// Convert matched formatting data into user-friendly state object.
//
// TODO: DRY.
//
ansiState.forEach(function (ansiCode) {
if (ansiparse.foregroundColors[ansiCode]) {
state.foreground = ansiparse.foregroundColors[ansiCode]
} else if (ansiparse.backgroundColors[ansiCode]) {
state.background = ansiparse.backgroundColors[ansiCode]
} else if (ansiCode == 39) {
delete state.foreground
} else if (ansiCode == 49) {
delete state.background
} else if (ansiparse.styles[ansiCode]) {
state[ansiparse.styles[ansiCode]] = true
} else if (ansiCode == 22) {
state.bold = false
} else if (ansiCode == 23) {
state.italic = false
} else if (ansiCode == 24) {
state.underline = false
}
})
ansiState = []
} else {
matchingData += str[i]
}
continue
}
if (str[i] == "\x1b") {
matchingControl = str[i];
} else if (str[i] == "\u0008") {
eraseChar();
} else {
matchingText += str[i];
}
}
if (str[i] == '\x1b') {
matchingControl = str[i]
} else if (str[i] == '\u0008') {
eraseChar()
} else {
matchingText += str[i]
}
}
if (matchingText) {
state.text = matchingText + (matchingControl ? matchingControl : "");
result.push(state);
}
return result;
};
if (matchingText) {
state.text = matchingText + (matchingControl ? matchingControl : '')
result.push(state)
}
return result
}
ansiparse.foregroundColors = {
30: "black",
31: "red",
32: "green",
33: "yellow",
34: "blue",
35: "magenta",
36: "cyan",
37: "white",
90: "grey",
};
30: 'black',
31: 'red',
32: 'green',
33: 'yellow',
34: 'blue',
35: 'magenta',
36: 'cyan',
37: 'white',
90: 'grey',
}
ansiparse.backgroundColors = {
40: "black",
41: "red",
42: "green",
43: "yellow",
44: "blue",
45: "magenta",
46: "cyan",
47: "white",
};
40: 'black',
41: 'red',
42: 'green',
43: 'yellow',
44: 'blue',
45: 'magenta',
46: 'cyan',
47: 'white',
}
ansiparse.styles = {
1: "bold",
3: "italic",
4: "underline",
};
1: 'bold',
3: 'italic',
4: 'underline',
}
export default ansiparse;
export default ansiparse

View File

@ -24,7 +24,6 @@
/// <reference types="vite/client" />
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<{}, {}, any>
export default component
const component: DefineComponent<{}, {}, any>
export default component
}

View File

@ -26,6 +26,13 @@ import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { createHtmlPlugin } from 'vite-plugin-html'
//自动导入vue中hook reactive ref等
import AutoImport from 'unplugin-auto-import/vite'
//自动导入ui-组件 比如说ant-design-vue element-plus等
import Components from 'unplugin-vue-components/vite'
//ant-design-vue
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
// 加载环境配置
@ -39,14 +46,14 @@ export default defineConfig(({ mode }) => {
resolve: {
alias: {
'@/': `${path.resolve(__dirname, 'src')}/`,
'@/': `${path.resolve(__dirname, 'src')}/`
},
// 忽略后缀名的配置选项
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
},
build: {
sourcemap: mode !== 'production', // 非生产环境都生成sourcemap
outDir: '../modules/server/src/main/resources/dist2',
outDir: '../modules/server/src/main/resources/dist2'
},
server: {
port: JPOM_PORT,
@ -56,38 +63,51 @@ export default defineConfig(({ mode }) => {
target: `wss://${HOST}`,
// true/false: if you want to proxy websockets
ws: false,
secure: false,
secure: false
},
'/tomcat_log': {
target: `wss://${HOST}`,
// true/false: if you want to proxy websockets
ws: false,
secure: false,
secure: false
},
'/console': {
target: `wss://${HOST}`,
// true/false: if you want to proxy websockets
ws: false,
secure: false,
secure: false
},
'/script_run': {
target: `wss://${HOST}`,
// true/false: if you want to proxy websockets
ws: false,
secure: false,
secure: false
},
// http
'/api': {
target: `http://${HOST}`,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
timeout: 10 * 60 * 1000,
},
},
timeout: 10 * 60 * 1000
}
}
},
plugins: [
vue(),
vueJsx(),
AutoImport({
//安装两行后你会发现在组件中不用再导入refreactive等
imports: ['vue', 'vue-router'],
dts: 'src/d.ts/auto-import.d.ts',
//ant-design-vue
resolvers: [AntDesignVueResolver()]
}),
Components({
dts: 'src/d.ts/components.d.ts',
//ant-design-vue importStyle = false 样式就没了
resolvers: [AntDesignVueResolver({ importStyle: true, resolveIcons: true })]
}),
createHtmlPlugin({
minify: true,
inject: {
@ -96,10 +116,10 @@ export default defineConfig(({ mode }) => {
base_url: env.JPOM_BASE_URL,
build: new Date().getTime(),
env: process.env.NODE_ENV,
buildVersion: process.env.npm_package_version,
},
},
}),
],
buildVersion: process.env.npm_package_version
}
}
})
]
}
})