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