chore: use relative imports for fileSize to avoid alias issues

This commit is contained in:
24kycj
2025-10-22 17:00:06 +08:00
parent 3f20a6b16a
commit ad9c8025c6
4 changed files with 733 additions and 733 deletions
+1 -1
View File
@@ -1,4 +1,5 @@
// import { getAllList, getChatList, bindId, chatBegin } from '@/api/message' // import { getAllList, getChatList, bindId, chatBegin } from '@/api/message'
import { getCurrentOSDiscTypes } from '@/utils/fileSize'
let timeouter = null let timeouter = null
let websock = null let websock = null
@@ -130,7 +131,6 @@ const CDTypes = {
7: 'BD_QL' 7: 'BD_QL'
} }
// 使用跨平台文件大小计算 // 使用跨平台文件大小计算
const { getCurrentOSDiscTypes } = require('@/utils/fileSize')
const cd_types = getCurrentOSDiscTypes() const cd_types = getCurrentOSDiscTypes()
const defaultData = { const defaultData = {
+8 -8
View File
@@ -12,21 +12,21 @@
### 1. 操作系统检测 ### 1. 操作系统检测
```javascript ```javascript
import { getOS } from '@/utils/fileSize' import { getOS } from '/src/renderer/utils/fileSize'
const currentOS = getOS() // 'windows', 'mac', 'linux', 'unknown' const currentOS = getOS() // 'windows', 'mac', 'linux', 'unknown'
``` ```
### 2. 获取基础单位大小 ### 2. 获取基础单位大小
```javascript ```javascript
import { getBaseSize } from '@/utils/fileSize' import { getBaseSize } from '/src/renderer/utils/fileSize'
const baseSize = getBaseSize() // 1024 (Windows/Linux) 或 1000 (macOS) const baseSize = getBaseSize() // 1024 (Windows/Linux) 或 1000 (macOS)
``` ```
### 3. 光盘类型配置 ### 3. 光盘类型配置
```javascript ```javascript
import { getCurrentOSDiscTypes } from '@/utils/fileSize' import { getCurrentOSDiscTypes } from '/src/renderer/utils/fileSize'
const discTypes = getCurrentOSDiscTypes() const discTypes = getCurrentOSDiscTypes()
// 返回当前系统适配的光盘类型配置 // 返回当前系统适配的光盘类型配置
@@ -34,7 +34,7 @@ const discTypes = getCurrentOSDiscTypes()
### 4. 文件大小格式化 ### 4. 文件大小格式化
```javascript ```javascript
import { formatFileSize } from '@/utils/fileSize' import { formatFileSize } from '/src/renderer/utils/fileSize'
const formatted = formatFileSize(1024*1024*1024) // "1.00 GB" (Windows) 或 "1.00 GB" (macOS) const formatted = formatFileSize(1024*1024*1024) // "1.00 GB" (Windows) 或 "1.00 GB" (macOS)
``` ```
@@ -44,7 +44,7 @@ const formatted = formatFileSize(1024*1024*1024) // "1.00 GB" (Windows) 或 "1.0
### 在组件中使用 ### 在组件中使用
```javascript ```javascript
// dashboard/index.vue // dashboard/index.vue
import { getCurrentOSDiscTypes } from '@/utils/fileSize' import { getCurrentOSDiscTypes } from '/src/renderer/utils/fileSize'
export default { export default {
methods: { methods: {
@@ -59,7 +59,7 @@ export default {
### 在工具函数中使用 ### 在工具函数中使用
```javascript ```javascript
// utils/index.js // utils/index.js
import { formatFileSize } from '@/utils/fileSize' import { formatFileSize } from '/src/renderer/utils/fileSize'
export const filterSize = (size) => { export const filterSize = (size) => {
if (!size || size < 0) return '0 B' if (!size || size < 0) return '0 B'
@@ -80,7 +80,7 @@ export const filterSize = (size) => {
## 调试功能 ## 调试功能
```javascript ```javascript
import { getDebugInfo } from '@/utils/fileSize' import { getDebugInfo } from '/src/renderer/utils/fileSize'
const debug = getDebugInfo() const debug = getDebugInfo()
console.log(debug) console.log(debug)
@@ -92,7 +92,7 @@ console.log(debug)
运行测试文件查看不同系统的差异: 运行测试文件查看不同系统的差异:
```javascript ```javascript
import { testFileSizeCalculation, compareOSDifferences } from '@/utils/fileSizeTest' import { testFileSizeCalculation, compareOSDifferences } from '/src/renderer/utils/fileSizeTest'
testFileSizeCalculation() // 显示当前系统配置 testFileSizeCalculation() // 显示当前系统配置
compareOSDifferences() // 对比不同系统差异 compareOSDifferences() // 对比不同系统差异
+4 -4
View File
@@ -465,14 +465,14 @@ export function accSub(arg1, arg2) {
export const filterSize = (size) => { export const filterSize = (size) => {
if (!size || size < 0) return '0 B'; if (!size || size < 0) return '0 B';
// 使用跨平台文件大小格式化 // 使用跨平台文件大小格式化(相对路径)
const { formatFileSize } = require('@/utils/fileSize') const { formatFileSize } = require('./fileSize')
return formatFileSize(size) return formatFileSize(size)
} }
export const pow1024 = (num) => { export const pow1024 = (num) => {
// 使用跨平台基础大小 // 使用跨平台基础大小(相对路径)
const { getBaseSize } = require('@/utils/fileSize') const { getBaseSize } = require('./fileSize')
const baseSize = getBaseSize() const baseSize = getBaseSize()
return Math.pow(baseSize, num) return Math.pow(baseSize, num)
} }
+2 -2
View File
@@ -341,6 +341,7 @@ import { mapGetters } from 'vuex'
const { app, dialog } = require('@electron/remote') const { app, dialog } = require('@electron/remote')
import UserInfo from '@/components/userInfo/userInfo.vue' import UserInfo from '@/components/userInfo/userInfo.vue'
import WorkAdd from '@/components/workAdd/workAdd.vue' import WorkAdd from '@/components/workAdd/workAdd.vue'
import { getCurrentOSDiscTypes } from '@/utils/fileSize'
const exePath = !app.isPackaged ? process.cwd() : path.dirname(process.execPath) const exePath = !app.isPackaged ? process.cwd() : path.dirname(process.execPath)
const shPath = path.join(exePath, 'CardsoonServer', 'control.sh') const shPath = path.join(exePath, 'CardsoonServer', 'control.sh')
const activePath = path.join(exePath, 'CardsoonServer', 'regist.sh') const activePath = path.join(exePath, 'CardsoonServer', 'regist.sh')
@@ -970,8 +971,7 @@ export default {
clearTimeout(outTimer) clearTimeout(outTimer)
that.currentRunVal = 0 that.currentRunVal = 0
// 使用跨平台文件大小计算 // 使用跨平台文件大小计算(相对路径)
const { getCurrentOSDiscTypes } = require('@/utils/fileSize')
let typeLists = getCurrentOSDiscTypes() let typeLists = getCurrentOSDiscTypes()
let isBD = that.changeCD.req_info.strong_list.findIndex(item => parseInt(item.strong_type) > 3) let isBD = that.changeCD.req_info.strong_list.findIndex(item => parseInt(item.strong_type) > 3)
if (isBD === -1) { if (isBD === -1) {