Skip to content

Commit 22e3c69

Browse files
committed
chore(deps): update dependencies and improve error handling
1 parent e26a4fa commit 22e3c69

File tree

8 files changed

+258
-283
lines changed

8 files changed

+258
-283
lines changed

app/components.d.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,20 @@ declare module 'vue' {
1010
export interface GlobalComponents {
1111
AAlert: typeof import('ant-design-vue/es')['Alert']
1212
AApp: typeof import('ant-design-vue/es')['App']
13-
AAutoComplete: typeof import('ant-design-vue/es')['AutoComplete']
1413
AAvatar: typeof import('ant-design-vue/es')['Avatar']
1514
ABadge: typeof import('ant-design-vue/es')['Badge']
1615
ABreadcrumb: typeof import('ant-design-vue/es')['Breadcrumb']
1716
ABreadcrumbItem: typeof import('ant-design-vue/es')['BreadcrumbItem']
1817
AButton: typeof import('ant-design-vue/es')['Button']
1918
ACard: typeof import('ant-design-vue/es')['Card']
20-
ACheckbox: typeof import('ant-design-vue/es')['Checkbox']
21-
ACheckboxGroup: typeof import('ant-design-vue/es')['CheckboxGroup']
2219
ACol: typeof import('ant-design-vue/es')['Col']
23-
ACollapse: typeof import('ant-design-vue/es')['Collapse']
24-
ACollapsePanel: typeof import('ant-design-vue/es')['CollapsePanel']
2520
AComment: typeof import('ant-design-vue/es')['Comment']
2621
AConfigProvider: typeof import('ant-design-vue/es')['ConfigProvider']
2722
ADivider: typeof import('ant-design-vue/es')['Divider']
2823
ADrawer: typeof import('ant-design-vue/es')['Drawer']
2924
ADropdown: typeof import('ant-design-vue/es')['Dropdown']
30-
AEmpty: typeof import('ant-design-vue/es')['Empty']
31-
AForm: typeof import('ant-design-vue/es')['Form']
32-
AFormItem: typeof import('ant-design-vue/es')['FormItem']
3325
AInput: typeof import('ant-design-vue/es')['Input']
3426
AInputGroup: typeof import('ant-design-vue/es')['InputGroup']
35-
AInputNumber: typeof import('ant-design-vue/es')['InputNumber']
36-
AInputPassword: typeof import('ant-design-vue/es')['InputPassword']
3727
ALayout: typeof import('ant-design-vue/es')['Layout']
3828
ALayoutContent: typeof import('ant-design-vue/es')['LayoutContent']
3929
ALayoutFooter: typeof import('ant-design-vue/es')['LayoutFooter']
@@ -45,7 +35,6 @@ declare module 'vue' {
4535
AMenu: typeof import('ant-design-vue/es')['Menu']
4636
AMenuDivider: typeof import('ant-design-vue/es')['MenuDivider']
4737
AMenuItem: typeof import('ant-design-vue/es')['MenuItem']
48-
AModal: typeof import('ant-design-vue/es')['Modal']
4938
APopconfirm: typeof import('ant-design-vue/es')['Popconfirm']
5039
APopover: typeof import('ant-design-vue/es')['Popover']
5140
AppProvider: typeof import('./src/components/AppProvider.vue')['default']
@@ -54,18 +43,15 @@ declare module 'vue' {
5443
ASelect: typeof import('ant-design-vue/es')['Select']
5544
ASelectOption: typeof import('ant-design-vue/es')['SelectOption']
5645
ASpace: typeof import('ant-design-vue/es')['Space']
57-
ASpin: typeof import('ant-design-vue/es')['Spin']
5846
AStatistic: typeof import('ant-design-vue/es')['Statistic']
5947
ASubMenu: typeof import('ant-design-vue/es')['SubMenu']
60-
ASwitch: typeof import('ant-design-vue/es')['Switch']
6148
ATable: typeof import('ant-design-vue/es')['Table']
6249
ATabPane: typeof import('ant-design-vue/es')['TabPane']
6350
ATabs: typeof import('ant-design-vue/es')['Tabs']
6451
ATag: typeof import('ant-design-vue/es')['Tag']
6552
ATextarea: typeof import('ant-design-vue/es')['Textarea']
6653
ATooltip: typeof import('ant-design-vue/es')['Tooltip']
6754
ATypographyText: typeof import('ant-design-vue/es')['TypographyText']
68-
ATypographyTitle: typeof import('ant-design-vue/es')['TypographyTitle']
6955
AutoCertFormAutoCertForm: typeof import('./src/components/AutoCertForm/AutoCertForm.vue')['default']
7056
AutoCertFormDNSChallenge: typeof import('./src/components/AutoCertForm/DNSChallenge.vue')['default']
7157
BaseEditorBaseEditor: typeof import('./src/components/BaseEditor/BaseEditor.vue')['default']

app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@formkit/auto-animate": "^0.9.0",
2020
"@simplewebauthn/browser": "^13.2.0",
2121
"@uozi-admin/curd": "^4.17.0",
22-
"@uozi-admin/request": "^2.9.0",
22+
"@uozi-admin/request": "^2.9.1",
2323
"@vue/reactivity": "^3.5.22",
2424
"@vue/shared": "^3.5.22",
2525
"@vueuse/components": "^13.9.0",
@@ -87,7 +87,7 @@
8787
"unplugin-auto-import": "^20.2.0",
8888
"unplugin-vue-components": "^29.1.0",
8989
"unplugin-vue-define-options": "^3.1.1",
90-
"vite": "^7.1.7",
90+
"vite": "^7.1.8",
9191
"vite-plugin-inspect": "^11.3.3",
9292
"vite-svg-loader": "^5.1.0",
9393
"vue-tsc": "^3.1.0"

app/pnpm-lock.yaml

Lines changed: 206 additions & 206 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/lib/http/interceptors.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ export function setupResponseInterceptor() {
125125
},
126126

127127
async error => {
128+
// Ignore canceled requests (navigation, component unmount, deduped requests)
129+
if (error?.code === 'ERR_CANCELED' || /canceled/i.test(error?.message || '')) {
130+
return Promise.reject(error)
131+
}
128132
// Setup stores and refs
129133
const user = useUserStore()
130134
const { secureSessionId } = storeToRefs(user)
@@ -155,11 +159,14 @@ export function setupResponseInterceptor() {
155159
console.error('Failed to parse blob error response as JSON', e)
156160
}
157161
}
162+
console.error(error)
163+
const errData = (error.response?.data as CosyError) || {
164+
code: error?.code || 'NETWORK_ERROR',
165+
message: error?.message || 'Network error',
166+
}
167+
await handleApiError(errData, dedupe)
158168

159-
const err = error.response?.data as CosyError
160-
await handleApiError(err, dedupe)
161-
162-
return Promise.reject(error.response?.data)
169+
return Promise.reject(error.response?.data ?? errData)
163170
},
164171
)
165172
}

app/src/main.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { autoAnimatePlugin } from '@formkit/auto-animate/vue'
2-
import { createCurdConfig } from '@uozi-admin/curd'
2+
import { createCosyProConfig } from '@uozi-admin/curd'
33
import { createRequestConfig } from '@uozi-admin/request'
44
import { createPinia } from 'pinia'
55
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
@@ -44,21 +44,7 @@ app.use(pinia)
4444
},
4545
})
4646
.use(setupInterceptors)
47-
.use(createCurdConfig({
48-
listApi: {
49-
paginationMap: {
50-
params: {
51-
current: 'page',
52-
pageSize: 'page_size',
53-
},
54-
response: {
55-
total: 'total',
56-
current: 'current_page',
57-
pageSize: 'per_page',
58-
totalPages: 'total_pages',
59-
},
60-
},
61-
},
47+
.use(createCosyProConfig({
6248
i18n: {
6349
legacy: false,
6450
locale: 'zh-CN',

app/src/views/terminal/components/TerminalStatusBar.vue

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<script setup lang="ts">
22
import type { DiskStat, LoadStat, MemStat } from '@/api/analytic'
33
import analytic from '@/api/analytic'
4-
import upgrade from '@/api/upgrade'
54
import { formatDateTime } from '@/lib/helper'
65
76
interface StatusData {
@@ -38,30 +37,27 @@ function formatUptime(uptime: number) {
3837
// Format memory usage as "used percentage"
3938
function formatMemoryUsage(memory: MemStat | null) {
4039
if (!memory)
41-
return '0B0%'
40+
return '0B 0%'
4241
43-
// Use the pressure value as percentage (since you said we can get it directly)
44-
const percentage = memory.pressure.toFixed(1)
42+
// Use percentage provided by the backend; keep 1 decimal place
43+
const percentage = typeof memory.pressure === 'number' ? memory.pressure.toFixed(1) : '0.0'
4544
46-
// Remove space from used size and combine without space
47-
const usedSize = memory.used.replace(' ', '')
45+
// Preserve space in formatted size and add a space before percentage
46+
const usedSize = memory.used
4847
49-
return `${usedSize}${percentage}%`
48+
return `${usedSize} ${percentage}%`
5049
}
5150
5251
// Format disk usage as "used percentage"
5352
function formatDiskUsage(disk: DiskStat | null) {
5453
if (!disk)
55-
return '0B0%'
54+
return '0B 0%'
5655
57-
// Value is already formatted string like "39 GiB"
58-
// Use the pre-calculated percentage from the API
59-
const percentage = disk.percentage.toFixed(1)
56+
// Already a formatted string like "39 GiB"; percentage comes from API
57+
const percentage = typeof disk.percentage === 'number' ? disk.percentage.toFixed(1) : '0.0'
58+
const usedSize = disk.used
6059
61-
// Remove space from used size and combine without space
62-
const usedSize = disk.used.replace(' ', '')
63-
64-
return `${usedSize}${percentage}%`
60+
return `${usedSize} ${percentage}%`
6561
}
6662
6763
// Format CPU frequency
@@ -75,50 +71,46 @@ function formatCpuFreq(freq: number) {
7571
return `${freq.toFixed(0)}MHz`
7672
}
7773
74+
// Format CPU text as "<count>x<freq>" with graceful fallbacks
75+
function formatCpu(cpuCount: number, freq: number) {
76+
const hasCount = typeof cpuCount === 'number' && cpuCount > 0
77+
const hasFreq = typeof freq === 'number' && freq > 0
78+
79+
if (hasCount && hasFreq)
80+
return `${cpuCount}x${formatCpuFreq(freq)}`
81+
if (hasCount && !hasFreq)
82+
return `${cpuCount}x`
83+
if (!hasCount && hasFreq)
84+
return `${formatCpuFreq(freq)}`
85+
return 'N/A'
86+
}
87+
7888
// Update current timestamp
7989
function updateTimestamp() {
8090
statusData.value.timestamp = formatDateTime(new Date().toISOString())
8191
}
8292
83-
// Initialize data from analytic init API
93+
// Initialize data from analytic init API (no fallbacks)
8494
async function initializeData() {
8595
try {
8696
const analyticData = await analytic.init()
8797
88-
// Set system info with fallbacks
8998
statusData.value.uptime = analyticData?.host?.uptime || 0
9099
statusData.value.loadAvg = analyticData?.loadavg || null
91100
statusData.value.memory = analyticData?.memory || null
92101
statusData.value.disk = analyticData?.disk || null
93102
94-
// Set CPU info with fallbacks
103+
// System version is taken directly from host.platformVersion
104+
statusData.value.version = analyticData?.host?.platformVersion || ''
105+
95106
const cpuInfo = analyticData?.cpu?.info || []
96107
statusData.value.cpuCount = cpuInfo.length || 0
97-
98-
// Get CPU frequency from first CPU info with fallback
99-
if (cpuInfo.length > 0 && cpuInfo[0].mhz) {
100-
statusData.value.cpuFreq = cpuInfo[0].mhz
101-
}
102-
else {
103-
statusData.value.cpuFreq = 0
104-
}
105-
106-
// Try to get version from upgrade API, fallback to host platform version
107-
try {
108-
const versionData = await upgrade.current_version()
109-
statusData.value.version = versionData?.cur_version?.version || analyticData?.host?.platformVersion || 'unknown'
110-
}
111-
catch (versionError) {
112-
console.warn('Failed to get app version, using platform version:', versionError)
113-
statusData.value.version = analyticData?.host?.platformVersion || 'unknown'
114-
}
108+
statusData.value.cpuFreq = (cpuInfo.length > 0 && cpuInfo[0].mhz) ? cpuInfo[0].mhz : 0
115109
116110
updateTimestamp()
117111
}
118112
catch (error) {
119113
console.error('Failed to initialize terminal status bar:', error)
120-
// Set default values on error
121-
statusData.value.version = 'error'
122114
updateTimestamp()
123115
}
124116
}
@@ -200,7 +192,7 @@ onMounted(() => {
200192

201193
<div class="status-item cpu">
202194
<span class="icon i-tabler-cpu" />
203-
<span class="value">{{ statusData.cpuCount || 0 }}x{{ formatCpuFreq(statusData.cpuFreq || 0) }}</span>
195+
<span class="value">{{ formatCpu(statusData.cpuCount || 0, statusData.cpuFreq || 0) }}</span>
204196
</div>
205197

206198
<div class="status-item memory">

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ require (
4646
github.com/stretchr/testify v1.11.1
4747
github.com/tufanbarisyildirim/gonginx v0.0.0-20250620092546-c3e307e36701
4848
github.com/ulikunitz/xz v0.5.15
49-
github.com/uozi-tech/cosy v1.26.15
49+
github.com/uozi-tech/cosy v1.26.16
5050
github.com/uozi-tech/cosy-driver-sqlite v0.2.1
5151
github.com/urfave/cli/v3 v3.4.1
5252
golang.org/x/crypto v0.42.0
@@ -351,7 +351,7 @@ require (
351351
google.golang.org/api v0.250.0 // indirect
352352
google.golang.org/genproto/googleapis/api v0.0.0-20250922171735-9219d122eba9 // indirect
353353
google.golang.org/genproto/googleapis/rpc v0.0.0-20250922171735-9219d122eba9 // indirect
354-
google.golang.org/protobuf v1.36.9 // indirect
354+
google.golang.org/protobuf v1.36.10 // indirect
355355
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
356356
gopkg.in/ns1/ns1-go.v2 v2.15.0 // indirect
357357
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,6 +2012,8 @@ github.com/uozi-tech/cosy v1.26.7 h1:1YkzOHneh5Dc+LWpEOUxNmmZpp7j8T862nZUDjizaMI
20122012
github.com/uozi-tech/cosy v1.26.7/go.mod h1:g6HCFb0uEYHOw0GFLZWM25Qk/C0KgHZSh1BHZhf05v0=
20132013
github.com/uozi-tech/cosy v1.26.15 h1:cHAP77B+whJKWfd6LjaEGX3ivkJwtmDXGm57J+gUMd0=
20142014
github.com/uozi-tech/cosy v1.26.15/go.mod h1:S1b7yc/cvEZDw8cU8X1e6CwLsJ42FCGER4BVs6WcEyg=
2015+
github.com/uozi-tech/cosy v1.26.16 h1:vh9TFdjEr2DB4FV880W2l9dtyATRUR6fxLXs3V4NUj0=
2016+
github.com/uozi-tech/cosy v1.26.16/go.mod h1:S1b7yc/cvEZDw8cU8X1e6CwLsJ42FCGER4BVs6WcEyg=
20152017
github.com/uozi-tech/cosy-driver-mysql v0.2.2 h1:22S/XNIvuaKGqxQPsYPXN8TZ8hHjCQdcJKVQ83Vzxoo=
20162018
github.com/uozi-tech/cosy-driver-mysql v0.2.2/go.mod h1:EZnRIbSj1V5U0gEeTobrXai/d1SV11lkl4zP9NFEmyE=
20172019
github.com/uozi-tech/cosy-driver-postgres v0.2.1 h1:OICakGuT+omva6QOJCxTJ5Lfr7CGXLmk/zD+aS51Z2o=
@@ -2952,6 +2954,8 @@ google.golang.org/protobuf v1.29.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw
29522954
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
29532955
google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw=
29542956
google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
2957+
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
2958+
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
29552959
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
29562960
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
29572961
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

0 commit comments

Comments
 (0)