Skip to content

Commit f9be5fc

Browse files
committed
fix(appearance): The community version prohibits appearance configuration
1 parent 5a5b2e8 commit f9be5fc

File tree

3 files changed

+58
-86
lines changed

3 files changed

+58
-86
lines changed

frontend/src/stores/appearance.ts

Lines changed: 12 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import { defineStore } from 'pinia'
22
import { store } from '@/stores/index'
33
// import { defaultFont, list } from '@/api/font'
44
import { request } from '@/utils/request'
5-
import colorFunctions from 'less/lib/less/functions/color.js'
6-
import colorTree from 'less/lib/less/tree/color.js'
7-
import { setTitle } from '@/utils/utils'
5+
6+
import { setTitle, setCurrentColor } from '@/utils/utils'
87

98
const basePath = import.meta.env.VITE_API_BASE_URL
109
const baseUrl = basePath + '/system/appearance/picture/'
@@ -32,7 +31,6 @@ interface AppearanceState {
3231
loaded: boolean
3332
showDemoTips?: boolean
3433
demoTipsContent?: string
35-
community: boolean
3634
fontList?: Array<{ name: string; id: string; isDefault: boolean }>
3735
}
3836

@@ -65,7 +63,6 @@ export const useAppearanceStore = defineStore('appearanceStore', {
6563
loaded: false,
6664
showDemoTips: false,
6765
demoTipsContent: '',
68-
community: true,
6966
fontList: [],
7067
}
7168
},
@@ -142,9 +139,6 @@ export const useAppearanceStore = defineStore('appearanceStore', {
142139
getDemoTipsContent(): string {
143140
return this.demoTipsContent!
144141
},
145-
getCommunity(): boolean {
146-
return this.community
147-
},
148142
getShowAi(): boolean {
149143
return isBtnShow(this.showAi!)
150144
},
@@ -208,7 +202,7 @@ export const useAppearanceStore = defineStore('appearanceStore', {
208202
setLoaded(data: boolean) {
209203
this.loaded = data
210204
},
211-
async setAppearance(isDataEaseBi?: boolean) {
205+
async setAppearance() {
212206
// const desktop = wsCache.get('app.desktop')
213207
// if (desktop) {
214208
// this.loaded = true
@@ -252,43 +246,28 @@ export const useAppearanceStore = defineStore('appearanceStore', {
252246
// document.title = ''
253247
// }
254248
const obj = LicenseGenerator.getLicense()
255-
if (obj?.status !== 'valid') return
249+
if (obj?.status !== 'valid') {
250+
setCurrentColor('#1CBA90')
251+
document.title = 'SQLBot'
252+
setLinkIcon()
253+
return
254+
}
256255
const resData = await request.get('/system/appearance')
257256
this.loaded = true
258257
if (!resData?.length) {
259-
if (!isDataEaseBi) {
260-
document.title = 'SQLBot'
261-
setLinkIcon()
262-
}
263258
return
264259
}
265-
const data: AppearanceState = { loaded: false, community: true }
266-
let isCommunity = false
260+
const data: AppearanceState = { loaded: false }
267261
resData.forEach((item: KeyValue) => {
268262
;(
269263
data as {
270264
[key: string]: any
271265
}
272266
)[item.pkey] = item.pval
273-
if (item.pkey === 'community') {
274-
isCommunity = true
275-
}
276267
})
277-
data.community = isCommunity
278-
this.community = data.community
279-
if (this.community) {
280-
this.showDemoTips = data.showDemoTips
281-
this.demoTipsContent = data.demoTipsContent
282-
this.loaded = true
283-
setLinkIcon()
284-
return
285-
}
268+
286269
this.navigate = data.navigate
287-
this.mobileLogin = data.mobileLogin
288-
this.mobileLoginBg = data.mobileLoginBg
289270
this.help = data.help
290-
this.showAi = data.showAi
291-
this.showCopilot = data.showCopilot
292271
this.showDoc = data.showDoc
293272
this.showAbout = data.showAbout
294273
this.navigateBg = data.navigateBg
@@ -300,53 +279,12 @@ export const useAppearanceStore = defineStore('appearanceStore', {
300279
: this.isBlue
301280
? '#3370ff'
302281
: '#1CBA90'
303-
document.documentElement.style.setProperty('--ed-color-primary', currentColor)
304-
document.documentElement.style.setProperty('--van-blue', currentColor)
305-
document.documentElement.style.setProperty(
306-
'--ed-color-primary-light-5',
307-
colorFunctions
308-
.mix(new colorTree('ffffff'), new colorTree(currentColor.substr(1)), { value: 40 })
309-
.toRGB()
310-
)
311-
document.documentElement.style.setProperty(
312-
'--ed-color-primary-light-3',
313-
colorFunctions
314-
.mix(new colorTree('ffffff'), new colorTree(currentColor.substr(1)), { value: 15 })
315-
.toRGB()
316-
)
317-
318-
document.documentElement.style.setProperty(
319-
'--ed-color-primary-60',
320-
colorFunctions
321-
.mix(new colorTree('ffffff'), new colorTree(currentColor.substr(1)), { value: 60 })
322-
.toRGB()
323-
)
324-
325-
document.documentElement.style.setProperty(
326-
'--ed-color-primary-80',
327-
colorFunctions
328-
.mix(new colorTree('ffffff'), new colorTree(currentColor.substr(1)), { value: 80 })
329-
.toRGB()
330-
)
331-
document.documentElement.style.setProperty('--ed-color-primary-1a', `${currentColor}1a`)
332-
document.documentElement.style.setProperty('--ed-color-primary-14', `${currentColor}14`)
333-
document.documentElement.style.setProperty('--ed-color-primary-33', `${currentColor}33`)
334-
document.documentElement.style.setProperty('--ed-color-primary-99', `${currentColor}99`)
335-
document.documentElement.style.setProperty(
336-
'--ed-color-primary-dark-2',
337-
colorFunctions
338-
.mix(new colorTree('000000'), new colorTree(currentColor.substr(1)), { value: 15 })
339-
.toRGB()
340-
)
341-
282+
setCurrentColor(currentColor)
342283
this.bg = data.bg
343284
this.login = data.login
344285
this.slogan = data.slogan
345286
this.web = data.web
346287
this.name = data.name
347-
this.foot = data.foot
348-
this.footContent = data.footContent
349-
if (isDataEaseBi) return
350288
if (this.name) {
351289
document.title = this.name
352290
setTitle(this.name)

frontend/src/utils/utils.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import dayjs from 'dayjs'
22
import { useCache } from '@/utils/useCache'
3+
import colorFunctions from 'less/lib/less/functions/color.js'
4+
import colorTree from 'less/lib/less/tree/color.js'
5+
36
const { wsCache } = useCache()
47
const getCheckDate = (timestamp: any) => {
58
if (!timestamp) return false
@@ -103,3 +106,44 @@ export const isBtnShow = (val: string) => {
103106
export const setTitle = (title?: string) => {
104107
document.title = title || 'SQLBot'
105108
}
109+
110+
export const setCurrentColor = (currentColor: any) => {
111+
document.documentElement.style.setProperty('--ed-color-primary', currentColor)
112+
document.documentElement.style.setProperty('--van-blue', currentColor)
113+
document.documentElement.style.setProperty(
114+
'--ed-color-primary-light-5',
115+
colorFunctions
116+
.mix(new colorTree('ffffff'), new colorTree(currentColor.substr(1)), { value: 40 })
117+
.toRGB()
118+
)
119+
document.documentElement.style.setProperty(
120+
'--ed-color-primary-light-3',
121+
colorFunctions
122+
.mix(new colorTree('ffffff'), new colorTree(currentColor.substr(1)), { value: 15 })
123+
.toRGB()
124+
)
125+
126+
document.documentElement.style.setProperty(
127+
'--ed-color-primary-60',
128+
colorFunctions
129+
.mix(new colorTree('ffffff'), new colorTree(currentColor.substr(1)), { value: 60 })
130+
.toRGB()
131+
)
132+
133+
document.documentElement.style.setProperty(
134+
'--ed-color-primary-80',
135+
colorFunctions
136+
.mix(new colorTree('ffffff'), new colorTree(currentColor.substr(1)), { value: 80 })
137+
.toRGB()
138+
)
139+
document.documentElement.style.setProperty('--ed-color-primary-1a', `${currentColor}1a`)
140+
document.documentElement.style.setProperty('--ed-color-primary-14', `${currentColor}14`)
141+
document.documentElement.style.setProperty('--ed-color-primary-33', `${currentColor}33`)
142+
document.documentElement.style.setProperty('--ed-color-primary-99', `${currentColor}99`)
143+
document.documentElement.style.setProperty(
144+
'--ed-color-primary-dark-2',
145+
colorFunctions
146+
.mix(new colorTree('000000'), new colorTree(currentColor.substr(1)), { value: 15 })
147+
.toRGB()
148+
)
149+
}

frontend/src/views/system/embedded/SetUi.vue

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,7 @@ defineExpose({
307307
</div>
308308
<div class="position-set_input">
309309
<div class="x">
310-
<el-input-number
311-
v-model="sqlBotForm.x_val"
312-
:min="0"
313-
controls-position="right"
314-
@change="handleChange"
315-
>
310+
<el-input-number v-model="sqlBotForm.x_val" :min="0" controls-position="right">
316311
<template #prefix>
317312
<el-select v-model="sqlBotForm.x_type" style="width: 51px">
318313
<el-option
@@ -326,12 +321,7 @@ defineExpose({
326321
>px
327322
</div>
328323
<div class="y">
329-
<el-input-number
330-
v-model="sqlBotForm.y_val"
331-
:min="0"
332-
controls-position="right"
333-
@change="handleChange"
334-
>
324+
<el-input-number v-model="sqlBotForm.y_val" :min="0" controls-position="right">
335325
<template #prefix>
336326
<el-select v-model="sqlBotForm.y_type" style="width: 51px">
337327
<el-option

0 commit comments

Comments
 (0)