提交 4c1e3a7d 作者: 方治民

Merge branch '3.x' of https://gitlab.yiring.com/basic/basic-vue-admin into electron

......@@ -30,6 +30,7 @@ module.exports = {
'@typescript-eslint/no-empty-function': 'off',
'vue/custom-event-name-casing': 'off',
'no-use-before-define': 'off',
'@typescript-eslint/consistent-type-assertions': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-types': 'off',
......
const fs = require('fs')
const path = require('path')
const { execSync } = require('child_process')
const fs = require('node:fs')
const path = require('node:path')
const { execSync } = require('node:child_process')
const scopes = fs
.readdirSync(path.resolve(__dirname, 'src'), { withFileTypes: true })
......
......@@ -67,15 +67,15 @@
"@electron-toolkit/preload": "^1.0.3",
"@electron-toolkit/utils": "^1.0.2",
"@iconify/iconify": "^3.1.0",
"@logicflow/core": "^1.2.3",
"@logicflow/extension": "^1.2.3",
"@logicflow/core": "^1.2.8",
"@logicflow/extension": "^1.2.8",
"@purge-icons/generated": "^0.9.0",
"@stomp/stompjs": "^7.0.0",
"@vue/runtime-core": "^3.2.47",
"@vue/shared": "^3.2.47",
"@vueuse/core": "^10.1.0",
"@vueuse/electron": "^10.1.0",
"@vueuse/shared": "^10.1.0",
"@vue/runtime-core": "^3.3.4",
"@vue/shared": "^3.3.4",
"@vueuse/core": "^10.1.2",
"@vueuse/electron": "^10.1.2",
"@vueuse/shared": "^10.1.2",
"@zxcvbn-ts/core": "^2.2.1",
"ant-design-vue": "^3.2.20",
"axios": "^0.26.1",
......@@ -94,54 +94,54 @@
"nanoid": "^4.0.2",
"nprogress": "^0.2.0",
"path-to-regexp": "^6.2.1",
"pinia": "^2.0.35",
"pinia": "^2.1.3",
"print-js": "^1.6.0",
"qrcode": "^1.5.3",
"qs": "^6.11.1",
"qs": "^6.11.2",
"resize-observer-polyfill": "^1.5.1",
"showdown": "^2.1.0",
"sockjs-client": "^1.6.1",
"sortablejs": "^1.15.0",
"stompjs": "^2.3.3",
"tinymce": "^5.10.7",
"vditor": "^3.9.2",
"vue": "^3.2.47",
"vditor": "^3.9.3",
"vue": "^3.3.4",
"vue-i18n": "^9.2.2",
"vue-json-pretty": "^2.2.4",
"vue-router": "^4.1.6",
"vue-types": "^5.0.2",
"vue-router": "^4.2.2",
"vue-types": "^5.0.3",
"xlsx": "^0.18.5"
},
"devDependencies": {
"@antfu/eslint-config": "^0.38.5",
"@commitlint/cli": "^17.6.1",
"@commitlint/config-conventional": "^17.6.1",
"@antfu/eslint-config": "^0.38.6",
"@commitlint/cli": "^17.6.5",
"@commitlint/config-conventional": "^17.6.5",
"@electron-toolkit/tsconfig": "^1.0.1",
"@electron/notarize": "^1.2.3",
"@iconify/json": "^2.2.56",
"@iconify/json": "^2.2.72",
"@types/codemirror": "^5.60.7",
"@types/crypto-js": "^4.1.1",
"@types/fs-extra": "^11.0.1",
"@types/inquirer": "^9.0.3",
"@types/intro.js": "^5.1.1",
"@types/lodash": "^4.14.194",
"@types/lodash": "^4.14.195",
"@types/lodash-es": "^4.17.7",
"@types/mockjs": "^1.0.7",
"@types/node": "^18.16.2",
"@types/node": "^18.16.16",
"@types/nprogress": "^0.2.0",
"@types/qrcode": "^1.5.0",
"@types/qs": "^6.9.7",
"@types/showdown": "^2.0.0",
"@types/showdown": "^2.0.1",
"@types/sockjs-client": "^1.5.1",
"@types/sortablejs": "^1.15.1",
"@types/stompjs": "^2.3.5",
"@typescript-eslint/eslint-plugin": "^5.59.1",
"@typescript-eslint/parser": "^5.59.1",
"@vitejs/plugin-legacy": "^4.0.3",
"@vitejs/plugin-vue": "^4.2.1",
"@typescript-eslint/eslint-plugin": "^5.59.8",
"@typescript-eslint/parser": "^5.59.8",
"@vitejs/plugin-legacy": "^4.0.4",
"@vitejs/plugin-vue": "^4.2.3",
"@vitejs/plugin-vue-jsx": "^3.0.1",
"@vue/compiler-dom": "^3.2.47",
"@vue/compiler-sfc": "^3.2.47",
"@vue/compiler-dom": "^3.3.4",
"@vue/compiler-sfc": "^3.3.4",
"@vue/test-utils": "^2.3.2",
"autoprefixer": "^10.4.14",
"commitizen": "^4.3.0",
......@@ -150,55 +150,55 @@
"cz-conventional-changelog": "^3.3.0",
"cz-git": "^1.6.1",
"czg": "^1.6.1",
"dotenv": "^16.0.3",
"electron": "^23.3.0",
"dotenv": "^16.1.3",
"electron": "^23.3.5",
"electron-builder": "^23.6.0",
"electron-vite": "^1.0.22",
"eslint": "^8.39.0",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-vue": "^9.11.0",
"eslint-plugin-vue": "^9.14.1",
"esno": "^0.16.3",
"fs-extra": "^11.1.1",
"husky": "^8.0.3",
"inquirer": "^9.2.0",
"inquirer": "^9.2.6",
"less": "^4.1.3",
"lint-staged": "^13.2.2",
"lodash": "^4.17.21",
"npm-run-all": "^4.1.5",
"picocolors": "^1.0.0",
"pont-engine": "^1.5.7",
"postcss": "^8.4.23",
"pont-engine": "^1.5.10",
"postcss": "^8.4.24",
"postcss-html": "^1.5.0",
"postcss-less": "^6.0.0",
"prettier": "^2.8.8",
"rimraf": "^5.0.0",
"rollup": "^3.21.0",
"rimraf": "^5.0.1",
"rollup": "^3.23.0",
"rollup-plugin-visualizer": "^5.9.0",
"sort-package-json": "^2.4.1",
"stylelint": "^15.6.0",
"stylelint": "^15.6.2",
"stylelint-config-recommended": "^12.0.0",
"stylelint-config-recommended-vue": "^1.4.0",
"stylelint-config-standard": "^33.0.0",
"stylelint-order": "^6.0.3",
"terser": "^5.17.1",
"terser": "^5.17.7",
"ts-node": "^10.9.1",
"typescript": "^5.0.4",
"unplugin-auto-import": "^0.15.3",
"vite": "^4.3.3",
"typescript": "^4.9.5",
"unplugin-auto-import": "^0.16.4",
"vite": "^4.3.9",
"vite-plugin-compression": "^0.5.1",
"vite-plugin-html": "^3.2.0",
"vite-plugin-mkcert": "^1.14.1",
"vite-plugin-mkcert": "^1.15.0",
"vite-plugin-mock": "^2.9.8",
"vite-plugin-purge-icons": "^0.9.2",
"vite-plugin-pwa": "^0.14.7",
"vite-plugin-pwa": "^0.16.1",
"vite-plugin-style-import": "^2.0.0",
"vite-plugin-svg-icons": "^2.0.1",
"vite-plugin-theme": "^0.8.6",
"vite-plugin-vue-setup-extend": "^0.4.0",
"vite-plugin-windicss": "^1.8.10",
"vue-eslint-parser": "^9.1.1",
"vue-tsc": "^1.6.1"
"vite-plugin-windicss": "^1.9.0",
"vue-eslint-parser": "^9.3.0",
"vue-tsc": "^1.6.5"
},
"engines": {
"node": ">=14"
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -8,6 +8,7 @@ const API_URL_PREFIX = '/api'
export default class BasicGenerator extends CodeGenerator {
isRequestBody(inter: Interface, paramsCode: string): boolean {
// eslint-disable-next-line @typescript-eslint/no-require-imports
const prettier = require('prettier')
const requestParams = inter.getRequestParams(this.surrounding)
const code = prettier.format(paramsCode, { parser: 'typescript' })
......@@ -23,6 +24,7 @@ export default class BasicGenerator extends CodeGenerator {
let requestParams = inter.getRequestParams(this.surrounding)
let bodyTypeDef = ''
// eslint-disable-next-line @typescript-eslint/no-require-imports
const prettier = require('prettier')
if (prettier.format(paramsCode, { parser: 'typescript' }).includes('{}')) {
if (!requestParams.includes('form')) {
......
......@@ -7,7 +7,7 @@
import { Skeleton } from 'ant-design-vue'
import { CollapseTransition } from '/@/components/Transition'
import CollapseHeader from './CollapseHeader.vue'
import { triggerWindowResize } from '/@/utils/event'
import { triggerWindowResize as triggerWindowResizeFn } from '/@/utils/event'
// hook
import { useTimeoutFn } from '/@/hooks/core/useTimeout'
......@@ -46,7 +46,7 @@
show.value = isNil(val) ? !show.value : val
if (props.triggerWindowResize) {
// 200 milliseconds here is because the expansion has animation,
useTimeoutFn(triggerWindowResize, 200)
useTimeoutFn(triggerWindowResizeFn, 200)
}
}
defineExpose({
......
......@@ -15,7 +15,7 @@
showBtn: { type: Boolean, default: true },
btnProps: { type: Object as PropType<ButtonProps> },
btnText: { type: String, default: '' },
uploadApi: { type: Function as PropType<({ file: Blob, name: string }) => Promise<void>> },
uploadApi: { type: Function as PropType<(param: { file: Blob; name: string }) => Promise<void>> },
}
export default defineComponent({
name: 'CropperAvatar',
......@@ -30,7 +30,7 @@
const { t } = useI18n()
const getClass = computed(() => [prefixCls])
const getWidth = computed(() => `${`${props.width}`.replace(/px/, '')}px`)
const getIconWidth = computed(() => `${parseInt(`${props.width}`.replace(/px/, '')) / 2}px`)
const getIconWidth = computed(() => `${Number.parseInt(`${props.width}`.replace(/px/, '')) / 2}px`)
const getStyle = computed((): CSSProperties => ({ width: unref(getWidth) }))
const getImageWrapperStyle = computed(
(): CSSProperties => ({ width: unref(getWidth), height: unref(getWidth) }),
......
......@@ -60,15 +60,15 @@ export default function ({ advanceState, emit, getProps, getSchema, formModel, d
const width = unref(realWidthRef)
const mdWidth =
parseInt(itemCol.md as string) ||
parseInt(itemCol.xs as string) ||
parseInt(itemCol.sm as string) ||
Number.parseInt(itemCol.md as string) ||
Number.parseInt(itemCol.xs as string) ||
Number.parseInt(itemCol.sm as string) ||
(itemCol.span as number) ||
BASIC_COL_LEN
const lgWidth = parseInt(itemCol.lg as string) || mdWidth
const xlWidth = parseInt(itemCol.xl as string) || lgWidth
const xxlWidth = parseInt(itemCol.xxl as string) || xlWidth
const lgWidth = Number.parseInt(itemCol.lg as string) || mdWidth
const xlWidth = Number.parseInt(itemCol.xl as string) || lgWidth
const xxlWidth = Number.parseInt(itemCol.xxl as string) || xlWidth
if (width <= screenEnum.LG) {
itemColSum += mdWidth
} else if (width < screenEnum.XL) {
......
......@@ -57,7 +57,7 @@
const { size, color } = props
let fs = size
if (isString(size)) {
fs = parseInt(size, 10)
fs = Number.parseInt(size, 10)
}
return {
......
......@@ -79,7 +79,7 @@
resStr = t('component.time.just')
// Less than or equal to 59 seconds
} else if (diff < ONE_MINUTES) {
resStr = parseInt(diff / ONE_SECONDS) + t('component.time.seconds') + dirStr
resStr = Math.floor(diff / ONE_SECONDS) + t('component.time.seconds') + dirStr
// More than 59 seconds, less than or equal to 59 minutes and 59 seconds
} else if (diff >= ONE_MINUTES && diff < ONE_HOUR) {
resStr = Math.floor(diff / ONE_MINUTES) + t('component.time.minutes') + dirStr
......
......@@ -42,7 +42,7 @@
children: 'children',
title: 'title',
key: 'key',
...fieldNames,
...(fieldNames as Recordable),
}
})
const getBindValues = computed(() => {
......@@ -227,7 +227,7 @@
treeDataRef.value = props.treeData as TreeItem[]
})
onMounted(() => {
const level = parseInt(props.defaultExpandLevel)
const level = Number.parseInt(props.defaultExpandLevel as string)
if (level > 0) {
state.expandedKeys = filterByLevel(level)
} else if (props.defaultExpandAll) {
......
......@@ -38,7 +38,7 @@
const getActionStyleRef = computed(() => {
const { height, actionStyle } = props
const h = `${parseInt(height as string)}px`
const h = `${Number.parseInt(height as string)}px`
return {
left: 0,
width: h,
......@@ -49,8 +49,8 @@
const getWrapStyleRef = computed(() => {
const { height, width, circle, wrapStyle } = props
const h = parseInt(height as string)
const w = `${parseInt(width as string)}px`
const h = Number.parseInt(height as string)
const w = `${Number.parseInt(width as string)}px`
return {
width: w,
height: `${h}px`,
......@@ -62,7 +62,7 @@
const getBarStyleRef = computed(() => {
const { height, circle, barStyle } = props
const h = parseInt(height as string)
const h = Number.parseInt(height as string)
return {
height: `${h}px`,
borderRadius: circle ? `${h / 2}px 0 0 ${h / 2}px` : 0,
......@@ -72,8 +72,8 @@
const getContentStyleRef = computed(() => {
const { height, width, contentStyle } = props
const h = `${parseInt(height as string)}px`
const w = `${parseInt(width as string)}px`
const h = `${Number.parseInt(height as string)}px`
const w = `${Number.parseInt(width as string)}px`
return {
height: h,
......@@ -110,15 +110,15 @@
const actionEl = unref(actionElRef)
if (!actionEl) return
emit('start', e)
state.moveDistance = getEventPageX(e) - parseInt(actionEl.style.left.replace('px', ''), 10)
state.moveDistance = getEventPageX(e) - Number.parseInt(actionEl.style.left.replace('px', ''), 10)
state.startTime = new Date().getTime()
state.isMoving = true
}
function getOffset(el: HTMLDivElement) {
const actionWidth = parseInt(el.style.width)
const actionWidth = Number.parseInt(el.style.width)
const { width } = props
const widthNum = parseInt(width as string)
const widthNum = Number.parseInt(width as string)
const offset = widthNum - actionWidth - 6
return { offset, widthNum, actionWidth }
}
......@@ -169,7 +169,7 @@
} else {
const contentEl = unref(contentElRef)
if (contentEl) {
contentEl.style.width = `${parseInt(barEl.style.width)}px`
contentEl.style.width = `${Number.parseInt(barEl.style.width)}px`
}
}
}, 0)
......
......@@ -65,7 +65,7 @@
const { imgWidth, height, maxDegree } = props
const { moveX } = data
const currentRotate = Math.ceil(
(moveX / (imgWidth! - parseInt(height as string))) * maxDegree! * unref(getFactorRef),
(moveX / (imgWidth! - Number.parseInt(height as string))) * maxDegree! * unref(getFactorRef),
)
state.currentRotate = currentRotate
state.imgStyle = hackCss('transform', `rotateZ(${state.randomRotate - currentRotate}deg)`)
......@@ -130,7 +130,7 @@
<img
src={src}
onLoad={handleImgOnLoad}
width={parseInt(props.width as string)}
width={Number.parseInt(props.width as string)}
class={imgCls}
style={state.imgStyle}
onClick={() => {
......
......@@ -32,7 +32,7 @@
function convertToUnit(str: string | number | null | undefined, unit = 'px'): string | undefined {
if (str == null || str === '') {
return undefined
} else if (isNaN(+str!)) {
} else if (Number.isNaN(+str!)) {
return String(str)
} else {
return `${Number(str)}${unit}`
......@@ -51,11 +51,11 @@
})
const getBenchRef = computed(() => {
return parseInt(props.bench as string, 10)
return Number.parseInt(props.bench as string, 10)
})
const getItemHeightRef = computed(() => {
return parseInt(props.itemHeight as string, 10)
return Number.parseInt(props.itemHeight as string, 10)
})
const getFirstToRenderRef = computed(() => {
......@@ -99,7 +99,8 @@
if (!wrapEl) {
return 0
}
const height = parseInt(props.height || 0, 10) || wrapEl.clientHeight
// @ts-expect-error
const height = Number.parseInt(props.height || 0, 10) || wrapEl.clientHeight
return first + Math.ceil(height / unref(getItemHeightRef))
}
......
......@@ -48,7 +48,7 @@ const RippleDirective: Directive & RippleProto = {
}
function rippler({ event, el, zIndex, background }: { event: EventType; el: HTMLElement } & RippleProto) {
const targetBorder = parseInt(getComputedStyle(el).borderWidth.replace('px', ''))
const targetBorder = Number.parseInt(getComputedStyle(el).borderWidth.replace('px', ''))
const clientX = event.clientX || event.touches[0].clientX
const clientY = event.clientY || event.touches[0].clientY
......@@ -173,7 +173,7 @@ function rippler({ event, el, zIndex, background }: { event: EventType; el: HTML
function setProps(modifiers: Recordable, props: Recordable) {
modifiers.forEach((item: Recordable) => {
if (isNaN(Number(item))) props.event = item
if (Number.isNaN(Number(item))) props.event = item
else props.transition = item
})
}
......
......@@ -242,7 +242,7 @@ export default defineComponent({
event={HandlerEnum.LOCK_TIME}
defaultValue={unref(getLockTime)}
formatter={(value: string) => {
return parseInt(value) === 0
return Number.parseInt(value) === 0
? `0(${t('layout.setting.notAutoScreenLock')})`
: `${value}${t('layout.setting.minute')}`
}}
......@@ -255,7 +255,7 @@ export default defineComponent({
event={HandlerEnum.MENU_WIDTH}
disabled={!unref(getShowMenuRef)}
defaultValue={unref(getMenuWidth)}
formatter={(value: string) => `${parseInt(value)}px`}
formatter={(value: string) => `${Number.parseInt(value)}px`}
/>
</>
)
......
......@@ -83,6 +83,7 @@ export function useDragLine(siderRef: Ref<any>, dragBarRef: Ref<any>, mix = fals
function handleMouseMove(ele: HTMLElement, wrap: HTMLElement, clientX: number) {
document.onmousemove = function (innerE) {
let iT = (ele as any).left + (innerE.clientX - clientX)
// @ts-expect-error
innerE = innerE || window.event
const maxT = 800
const minT = unref(getMiniWidthNumber)
......@@ -101,7 +102,7 @@ export function useDragLine(siderRef: Ref<any>, dragBarRef: Ref<any>, mix = fals
document.onmousemove = null
document.onmouseup = null
wrap.style.transition = 'width 0.2s'
const width = parseInt(wrap.style.width)
const width = Number.parseInt(wrap.style.width)
if (!mix) {
const miniWidth = unref(getMiniWidthNumber)
......
......@@ -42,7 +42,7 @@ export function hexToRGB(hex: string) {
}
const sColorChange: number[] = []
for (let i = 1; i < 7; i += 2) {
sColorChange.push(parseInt(`0x${sHex.slice(i, i + 2)}`))
sColorChange.push(Number.parseInt(`0x${sHex.slice(i, i + 2)}`))
}
return `RGB(${sColorChange.join(',')})`
}
......@@ -96,7 +96,7 @@ export function lighten(color: string, amount: number) {
* @returns {string} The processed part of the color
*/
function addLight(color: string, amount: number) {
const cc = parseInt(color, 16) + amount
const cc = Number.parseInt(color, 16) + amount
const c = cc > 255 ? 255 : cc
return c.toString(16).length > 1 ? c.toString(16) : `0${c.toString(16)}`
}
......@@ -142,7 +142,7 @@ export function calculateBestTextColor(hexColor: string) {
* @returns {string} The processed part of the color
*/
function subtractLight(color: string, amount: number) {
const cc = parseInt(color, 16) - amount
const cc = Number.parseInt(color, 16) - amount
const c = cc < 0 ? 0 : cc
return c.toString(16).length > 1 ? c.toString(16) : `0${c.toString(16)}`
}
......@@ -11,6 +11,16 @@ const PROXY_LIST = [
// ['http://192.168.0.100:18100', `https://oss.app.yiring.com`],
]
// 监测是否为开发环境
// FIXED: 使用 try catch 的方式来判断是否为开发环境,因为在 Webview/RenderJS 中无法使用 import.meta.env
function isDevEnv() {
try {
return import.meta.env.MODE === 'development'
} catch (_) {
return false
}
}
/**
* 将内部地址(内网)转换成代理/预览地址(公网)
* @param url 内网地址
......@@ -28,7 +38,7 @@ export function getExtranetUrl(url: string): string {
/**
* 将代理/预览地址(公网)转换成内部地址(内网)
* eg: 主要用于解决内网文件上传后预览,但是实际上传存储时还是内网地址的问题
* @param url 代理/公网地址
* @param url 包含代理/公网地址的内容
*/
export function getIntranetUrl(url: string): string {
let uri = url
......@@ -46,13 +56,22 @@ export function getIntranetUrl(url: string): string {
* @returns 替换本地链接后的数据结果
*/
export function handleResponseResource<T>(body: T, options: Recordable) {
if (options.apiUrl.includes('proxy.yiring.com') && typeof body === 'object') {
let text = JSON.stringify(body)
for (const [intranet, extranet] of PROXY_LIST) {
// 当需要处理内外网资源地址映射时,进行内容处理
const isIntranet = options.apiUrl.includes(intranet)
const isExtranet = isDevEnv() ? true : options.apiUrl.includes(extranet)
if (isIntranet || isExtranet) {
const isString = typeof body === 'string'
const isObject = typeof body === 'object'
// 处理内网地址的预览问题
text = getExtranetUrl(text)
return JSON.parse(text) as T
// 处理有效数据
if (isString || isObject) {
let text = isString ? body : JSON.stringify(body)
// 说明: 如果接口地址是内网,就需要将外网链接转换成内网链接,如果是外网接口地址,则需要将内网地址转换成外网链接,来保证无论内外网访问平台资源都是正常的
text = isExtranet ? getExtranetUrl(text) : getIntranetUrl(text)
return (isString ? text : JSON.parse(text)) as T
}
}
}
return body
......
......@@ -33,7 +33,7 @@ export interface Indexable<T> {
export type Hash<T> = Indexable<T>
export type TimeoutHandle = ReturnType<typeof global.setTimeout>
export type TimeoutHandle = ReturnType<typeof setTimeout>
export type ComponentSize = 'large' | 'medium' | 'small' | 'mini'
......
......@@ -51,6 +51,7 @@ declare global {
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']
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论