Skip to content

Commit 78aadca

Browse files
author
Taois
committed
feat: 增加默认打包,适配影图打包
1 parent 9ff47c0 commit 78aadca

9 files changed

Lines changed: 190 additions & 79 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,5 @@ dist
130130
.pnp.*
131131
/dashboard/apps/drplayer/
132132
/.playwright-mcp/
133+
/dashboard/apps/
134+
/dashboard/apps-yt/

dashboard/.env.production.apps

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
11
# .env.production.apps
22
# 子目录部署配置 - 部署到 /apps/drplayer/ 目录
3-
VITE_BASE_PATH=/apps/drplayer/
3+
VITE_BASE_PATH=/apps/drplayer/
4+
VITE_OUT_DIR=apps/drplayer
5+
6+
VITE_DEFAULT_VOD_CONFIG=http://127.0.0.1:5757/config/1?healthy=1&pwd=dzyyds
7+
VITE_DEFAULT_LIVE_CONFIG=
8+
VITE_DEFAULT_PROXY_ACCESS=http://127.0.0.1:5757/req/${url}
9+
VITE_DEFAULT_PROXY_ACCESS_ENABLED=true
10+
VITE_DEFAULT_PROXY_PLAY=http://localhost:5757/unified-proxy/proxy?form=base64&auth=drpys&url=${url}&headers=${headers}&type=${type}#DS
11+
VITE_DEFAULT_PROXY_PLAY_ENABLED=false
12+
VITE_DEFAULT_PROXY_SNIFF=http://localhost:57573/sniffer
13+
VITE_DEFAULT_PROXY_SNIFF_ENABLED=false
14+
VITE_DEFAULT_SNIFFER_TIMEOUT=10
15+
VITE_DEFAULT_API_TIMEOUT=30
16+
17+
VITE_DEFAULT_AD_FILTER=true
18+
VITE_DEFAULT_AUTO_LIVE=false
19+
VITE_DEFAULT_CSP_BYPASS=true
20+
VITE_DEFAULT_DATASOURCE_DISPLAY=true
21+
VITE_DEFAULT_IJK_CACHE=false
22+
VITE_DEFAULT_PLAYER_TYPE=ijk
23+
VITE_DEFAULT_REFERRER_POLICY=no-referrer
24+
VITE_DEFAULT_SEARCH_AGGREGATION=false
25+
VITE_DEFAULT_SECURE_DNS=false
26+
VITE_DEFAULT_WINDOW_PREVIEW=true
27+
VITE_DEFAULT_THEME_MODE=light
28+
VITE_DEFAULT_PREFERRED_PLAYER_TYPE=artplayer
29+
VITE_DEFAULT_AUTO_NEXT_ENABLED=true
30+
VITE_DEFAULT_LOOP_ENABLED=false

dashboard/.env.production.apps-yt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# .env.production.apps-yt
2+
# 影图子目录部署配置 - 部署到 /apps-yt/drplayer/ 目录
3+
VITE_BASE_PATH=/apps-yt/drplayer/
4+
VITE_OUT_DIR=apps-yt/drplayer
5+
6+
VITE_DEFAULT_VOD_CONFIG=${locationHost}/api/t4.json
7+
VITE_DEFAULT_LIVE_CONFIG=
8+
VITE_DEFAULT_PROXY_ACCESS=
9+
VITE_DEFAULT_PROXY_ACCESS_ENABLED=false
10+
VITE_DEFAULT_PROXY_PLAY=${locationHost}/api/proxy?url=${url}&headers=${headers}&type=${type}#影图
11+
VITE_DEFAULT_PROXY_PLAY_ENABLED=true
12+
VITE_DEFAULT_PROXY_SNIFF=${locationHost}/sniffer
13+
VITE_DEFAULT_PROXY_SNIFF_ENABLED=true
14+
VITE_DEFAULT_SNIFFER_TIMEOUT=20
15+
VITE_DEFAULT_API_TIMEOUT=30
16+
17+
VITE_DEFAULT_AD_FILTER=true
18+
VITE_DEFAULT_AUTO_LIVE=false
19+
VITE_DEFAULT_CSP_BYPASS=true
20+
VITE_DEFAULT_DATASOURCE_DISPLAY=true
21+
VITE_DEFAULT_IJK_CACHE=false
22+
VITE_DEFAULT_PLAYER_TYPE=ijk
23+
VITE_DEFAULT_REFERRER_POLICY=no-referrer
24+
VITE_DEFAULT_SEARCH_AGGREGATION=true
25+
VITE_DEFAULT_SECURE_DNS=false
26+
VITE_DEFAULT_WINDOW_PREVIEW=true
27+
VITE_DEFAULT_PREFERRED_PLAYER_TYPE=artplayer
28+
VITE_DEFAULT_AUTO_NEXT_ENABLED=true
29+
VITE_DEFAULT_LOOP_ENABLED=false

dashboard/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"build": "vite build",
99
"build:root": "vite build --mode production.root",
1010
"build:apps": "vite build --mode production.apps",
11+
"build:apps-yt": "vite build --mode production.apps-yt",
1112
"build:binary": "node build-binary.js",
1213
"build:binary:win": "node build-binary.js",
1314
"build:binary:optimized": "node build-binary-optimized.js",

dashboard/src/config/defaults.js

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
const getLocationHost = () => {
2+
if (typeof location === 'undefined') {
3+
return ''
4+
}
5+
6+
return location.href.substring(0, location.href.indexOf('/', 10))
7+
}
8+
9+
const getEnvValue = (key, fallback = '') => {
10+
const value = import.meta.env[key]
11+
return value === undefined || value === null || value === '' ? fallback : value
12+
}
13+
14+
const getEnvBoolean = (key, fallback = false) => {
15+
const value = import.meta.env[key]
16+
if (value === undefined || value === null || value === '') {
17+
return fallback
18+
}
19+
20+
return value === 'true' || value === '1'
21+
}
22+
23+
const getEnvNumber = (key, fallback) => {
24+
const value = Number(import.meta.env[key])
25+
return Number.isFinite(value) ? value : fallback
26+
}
27+
28+
const withLocationHost = (value) => value.replaceAll('${locationHost}', getLocationHost())
29+
30+
export const getDefaultAddressSettings = () => ({
31+
vodConfig: withLocationHost(getEnvValue('VITE_DEFAULT_VOD_CONFIG', 'http://127.0.0.1:5757/config/1?healthy=1&pwd=dzyyds')),
32+
liveConfig: withLocationHost(getEnvValue('VITE_DEFAULT_LIVE_CONFIG', '')),
33+
proxyAccess: withLocationHost(getEnvValue('VITE_DEFAULT_PROXY_ACCESS', 'http://127.0.0.1:5757/req/${url}')),
34+
proxyAccessEnabled: getEnvBoolean('VITE_DEFAULT_PROXY_ACCESS_ENABLED', true),
35+
proxyPlay: withLocationHost(getEnvValue('VITE_DEFAULT_PROXY_PLAY', 'http://localhost:5757/unified-proxy/proxy?form=base64&auth=drpys&url=${url}&headers=${headers}&type=${type}#DS')),
36+
proxyPlayEnabled: getEnvBoolean('VITE_DEFAULT_PROXY_PLAY_ENABLED', false),
37+
proxySniff: withLocationHost(getEnvValue('VITE_DEFAULT_PROXY_SNIFF', 'http://localhost:57573/sniffer')),
38+
proxySniffEnabled: getEnvBoolean('VITE_DEFAULT_PROXY_SNIFF_ENABLED', false),
39+
snifferTimeout: getEnvNumber('VITE_DEFAULT_SNIFFER_TIMEOUT', 10),
40+
apiTimeout: getEnvNumber('VITE_DEFAULT_API_TIMEOUT', 30)
41+
})
42+
43+
export const getDefaultAppSettings = () => ({
44+
datasourceDisplay: getEnvBoolean('VITE_DEFAULT_DATASOURCE_DISPLAY', true),
45+
windowPreview: getEnvBoolean('VITE_DEFAULT_WINDOW_PREVIEW', true),
46+
playerType: getEnvValue('VITE_DEFAULT_PLAYER_TYPE', 'ijk'),
47+
adFilter: getEnvBoolean('VITE_DEFAULT_AD_FILTER', true),
48+
ijkCache: getEnvBoolean('VITE_DEFAULT_IJK_CACHE', false),
49+
autoLive: getEnvBoolean('VITE_DEFAULT_AUTO_LIVE', false),
50+
secureDns: getEnvBoolean('VITE_DEFAULT_SECURE_DNS', false),
51+
cspBypass: getEnvBoolean('VITE_DEFAULT_CSP_BYPASS', true),
52+
referrerPolicy: getEnvValue('VITE_DEFAULT_REFERRER_POLICY', 'no-referrer'),
53+
searchAggregation: getEnvBoolean('VITE_DEFAULT_SEARCH_AGGREGATION', false),
54+
themeMode: getEnvValue('VITE_DEFAULT_THEME_MODE', 'light')
55+
})
56+
57+
export const initDefaultLocalStorage = () => {
58+
const addressSettings = getDefaultAddressSettings()
59+
const appSettings = getDefaultAppSettings()
60+
61+
if (!localStorage.getItem('drplayer_config_url') && addressSettings.vodConfig) {
62+
localStorage.setItem('drplayer_config_url', addressSettings.vodConfig)
63+
}
64+
65+
if (!localStorage.getItem('addressSettings')) {
66+
localStorage.setItem('addressSettings', JSON.stringify(addressSettings, null, 4))
67+
}
68+
69+
if (!localStorage.getItem('appSettings')) {
70+
localStorage.setItem('appSettings', JSON.stringify(appSettings))
71+
}
72+
73+
if (!localStorage.getItem('address-history-vod-config') && addressSettings.vodConfig) {
74+
localStorage.setItem('address-history-vod-config', JSON.stringify([{ timestamp: Date.now(), url: addressSettings.vodConfig }]))
75+
}
76+
77+
if (!localStorage.getItem('address-history-live-config') && addressSettings.liveConfig) {
78+
localStorage.setItem('address-history-live-config', JSON.stringify([{ timestamp: Date.now(), url: addressSettings.liveConfig }]))
79+
}
80+
81+
if (!localStorage.getItem('address-history-proxy-access') && addressSettings.proxyAccess) {
82+
localStorage.setItem('address-history-proxy-access', JSON.stringify([{ timestamp: Date.now(), url: addressSettings.proxyAccess }]))
83+
}
84+
85+
if (!localStorage.getItem('address-history-proxy-play') && addressSettings.proxyPlay) {
86+
localStorage.setItem('address-history-proxy-play', JSON.stringify([{ timestamp: Date.now(), url: addressSettings.proxyPlay }]))
87+
}
88+
89+
if (!localStorage.getItem('address-history-proxy-sniff') && addressSettings.proxySniff) {
90+
localStorage.setItem('address-history-proxy-sniff', JSON.stringify([{ timestamp: Date.now(), url: addressSettings.proxySniff }]))
91+
}
92+
93+
if (!localStorage.getItem('drplayer_preferred_player_type')) {
94+
localStorage.setItem('drplayer_preferred_player_type', getEnvValue('VITE_DEFAULT_PREFERRED_PLAYER_TYPE', 'artplayer'))
95+
}
96+
97+
if (!localStorage.getItem('autoNextEnabled')) {
98+
localStorage.setItem('autoNextEnabled', JSON.stringify(getEnvBoolean('VITE_DEFAULT_AUTO_NEXT_ENABLED', true)))
99+
}
100+
101+
if (!localStorage.getItem('loopEnabled')) {
102+
localStorage.setItem('loopEnabled', JSON.stringify(getEnvBoolean('VITE_DEFAULT_LOOP_ENABLED', false)))
103+
}
104+
}

dashboard/src/main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'viewerjs/dist/viewer.css'
1212
import VueViewer from 'v-viewer'
1313
import ECharts from 'vue-echarts'
1414
import ActionComponents from '@/components/actions'
15+
import { initDefaultLocalStorage } from '@/config/defaults'
1516
import { use } from 'echarts/core'
1617
import {
1718
CanvasRenderer
@@ -39,6 +40,7 @@ use([
3940
TitleComponent
4041
])
4142

43+
initDefaultLocalStorage()
4244
initTheme()
4345

4446
const app = createApp(App)

dashboard/src/services/resetService.js

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,11 @@
66
import { Message, Modal } from '@arco-design/web-vue'
77
import { saveCSPConfig, setGlobalReferrerPolicy } from '@/utils/csp'
88
import { applyTheme } from '@/utils/theme'
9+
import { getDefaultAddressSettings, getDefaultAppSettings } from '@/config/defaults'
910

10-
// 默认配置值
11-
const DEFAULT_CONFIGS = {
12-
// 地址设置默认值
13-
addressSettings: {
14-
vodConfig: '',
15-
liveConfig: '',
16-
proxyAccess: '',
17-
proxyAccessEnabled: false,
18-
proxyPlay: 'http://localhost:57572/proxy?form=base64&url=${url}&headers=${headers}&type=${type}#嗷呜',
19-
proxyPlayEnabled: false,
20-
proxySniff: 'http://localhost:57573/sniffer',
21-
proxySniffEnabled: false,
22-
snifferTimeout: 10,
23-
apiTimeout: 30
24-
},
25-
26-
// 应用设置默认值
27-
appSettings: {
28-
datasourceDisplay: true,
29-
windowPreview: true,
30-
playerType: 'ijk',
31-
adFilter: true,
32-
ijkCache: false,
33-
autoLive: false,
34-
secureDns: false,
35-
cspBypass: true,
36-
referrerPolicy: 'no-referrer',
37-
searchAggregation: false, // 聚合搜索功能默认关闭
38-
themeMode: 'light'
39-
},
11+
const getDefaultConfigs = () => ({
12+
addressSettings: getDefaultAddressSettings(),
13+
appSettings: getDefaultAppSettings(),
4014

4115
// CSP配置默认值
4216
cspConfig: {
@@ -67,7 +41,7 @@ const DEFAULT_CONFIGS = {
6741
url: 'http://localhost:5757/apps/websocket',
6842
resetting: false
6943
}
70-
}
44+
})
7145

7246
// 需要完全清空的数据键
7347
const CLEAR_DATA_KEYS = [
@@ -164,18 +138,20 @@ export const performFactoryReset = async () => {
164138
localStorage.removeItem(key)
165139
})
166140

141+
const defaultConfigs = getDefaultConfigs()
142+
167143
// 2. 重置配置为默认值
168-
Object.entries(DEFAULT_CONFIGS).forEach(([key, defaultValue]) => {
144+
Object.entries(defaultConfigs).forEach(([key, defaultValue]) => {
169145
if (defaultValue !== null && defaultValue !== undefined) {
170146
localStorage.setItem(key, JSON.stringify(defaultValue))
171147
}
172148
})
173149

174150
// 3. 重置CSP配置
175151
try {
176-
saveCSPConfig(DEFAULT_CONFIGS.cspConfig)
152+
saveCSPConfig(defaultConfigs.cspConfig)
177153
setGlobalReferrerPolicy('no-referrer')
178-
applyTheme(DEFAULT_CONFIGS.appSettings.themeMode)
154+
applyTheme(defaultConfigs.appSettings.themeMode)
179155
} catch (error) {
180156
console.warn('CSP配置重置失败:', error)
181157
}
@@ -225,5 +201,5 @@ export default {
225201
showResetConfirmation,
226202
performFactoryReset,
227203
factoryResetWithConfirmation,
228-
DEFAULT_CONFIGS
204+
getDefaultConfigs
229205
}

dashboard/src/views/Settings.vue

Lines changed: 12 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,7 @@ import ScrollToBottom from '@/components/ScrollToBottom.vue'
992992
import configService from '@/api/services/config'
993993
import siteService from '@/api/services/site'
994994
import {factoryResetWithConfirmation} from '@/services/resetService'
995+
import { getDefaultAddressSettings, getDefaultAppSettings } from '@/config/defaults'
995996
import { applyTheme, normalizeThemeMode, themeOptions } from '@/utils/theme'
996997
import {
997998
getCSPConfig,
@@ -1009,22 +1010,7 @@ const proxyPlayHistory = ref(null)
10091010
const proxySniffHistory = ref(null)
10101011
10111012
// 地址设置相关
1012-
const addressSettings = reactive({
1013-
vodConfig: '',
1014-
liveConfig: '',
1015-
proxyAccess: '',
1016-
proxyAccessEnabled: false,
1017-
// proxyPlay: 'http://localhost:57572/proxy?form=base64&url=${url}&headers=${headers}&type=${type}#嗷呜',
1018-
// proxyPlay: 'http://localhost:57574/?form=base64&url=${url}&headers=${headers}&type=${type}#GO',
1019-
// proxyPlay: 'http://localhost:5757/file-proxy/proxy?form=base64&auth=drpys&url=${url}&headers=${headers}&type=${type}#DS',
1020-
// proxyPlay: 'http://localhost:5757/m3u8-proxy/proxy?form=base64&auth=drpys&url=${url}&headers=${headers}&type=${type}#MDS',
1021-
proxyPlay: 'http://localhost:5757/unified-proxy/proxy?form=base64&auth=drpys&url=${url}&headers=${headers}&type=${type}#DS',
1022-
proxyPlayEnabled: false,
1023-
proxySniff: 'http://localhost:57573/sniffer',
1024-
proxySniffEnabled: false,
1025-
snifferTimeout: 10,
1026-
apiTimeout: 30
1027-
})
1013+
const addressSettings = reactive(getDefaultAddressSettings())
10281014
10291015
const addressSaving = reactive({
10301016
vodConfig: false,
@@ -1063,19 +1049,7 @@ const playerTypes = [
10631049
]
10641050
10651051
// 设置项状态
1066-
const settings = reactive({
1067-
datasourceDisplay: true,
1068-
windowPreview: true,
1069-
playerType: 'ijk', // 默认播放器类型
1070-
adFilter: true,
1071-
ijkCache: false,
1072-
autoLive: false,
1073-
secureDns: false,
1074-
cspBypass: true, // CSP绕过开关
1075-
referrerPolicy: 'no-referrer', // 默认referrer策略
1076-
searchAggregation: false, // 聚搜功能开关,默认关闭
1077-
themeMode: 'light' // 应用主题模式
1078-
})
1052+
const settings = reactive(getDefaultAppSettings())
10791053
10801054
// 开发者调试设置
10811055
const debugSettings = reactive({
@@ -1318,13 +1292,9 @@ const resetLiveConfig = async () => {
13181292
const resetProxyPlay = async () => {
13191293
addressSaving.proxyPlayReset = true
13201294
try {
1321-
// 重置为默认值
1322-
// addressSettings.proxyPlay = 'http://localhost:57572/proxy?form=base64&url=${url}&headers=${headers}&type=${type}#嗷呜'
1323-
// addressSettings.proxyPlay = 'http://localhost:57574/?form=base64&url=${url}&headers=${headers}&type=${type}#GO'
1324-
// addressSettings.proxyPlay = 'http://localhost:5757/file-proxy/proxy?form=base64&auth=drpys&url=${url}&headers=${headers}&type=${type}#DS'
1325-
// addressSettings.proxyPlay = 'http://localhost:5757/m3u8-proxy/proxy?form=base64&auth=drpys&url=${url}&headers=${headers}&type=${type}#MDS'
1326-
addressSettings.proxyPlay = 'http://localhost:5757/unified-proxy/proxy?form=base64&auth=drpys&url=${url}&headers=${headers}&type=${type}#DS'
1327-
addressSettings.proxyPlayEnabled = false
1295+
const defaults = getDefaultAddressSettings()
1296+
addressSettings.proxyPlay = defaults.proxyPlay
1297+
addressSettings.proxyPlayEnabled = defaults.proxyPlayEnabled
13281298
13291299
// 保存到本地存储
13301300
const savedAddresses = JSON.parse(localStorage.getItem('addressSettings') || '{}')
@@ -1366,9 +1336,9 @@ const resetProxyPlay = async () => {
13661336
const resetProxySniff = async () => {
13671337
addressSaving.proxySniffReset = true
13681338
try {
1369-
// 重置为默认值
1370-
addressSettings.proxySniff = 'http://localhost:57573/sniffer'
1371-
addressSettings.proxySniffEnabled = false
1339+
const defaults = getDefaultAddressSettings()
1340+
addressSettings.proxySniff = defaults.proxySniff
1341+
addressSettings.proxySniffEnabled = defaults.proxySniffEnabled
13721342
13731343
// 保存到本地存储
13741344
const savedAddresses = JSON.parse(localStorage.getItem('addressSettings') || '{}')
@@ -1601,15 +1571,15 @@ const loadConfig = async () => {
16011571
Object.assign(addressSettings, parsed)
16021572
// 确保代理嗅探接口有默认值
16031573
if (!addressSettings.proxySniff) {
1604-
addressSettings.proxySniff = 'http://localhost:57573/sniffer'
1574+
addressSettings.proxySniff = getDefaultAddressSettings().proxySniff
16051575
}
16061576
// 确保嗅探超时有默认值
16071577
if (!addressSettings.snifferTimeout) {
1608-
addressSettings.snifferTimeout = 10
1578+
addressSettings.snifferTimeout = getDefaultAddressSettings().snifferTimeout
16091579
}
16101580
// 确保访问超时有默认值
16111581
if (!addressSettings.apiTimeout) {
1612-
addressSettings.apiTimeout = 30
1582+
addressSettings.apiTimeout = getDefaultAddressSettings().apiTimeout
16131583
}
16141584
} catch (error) {
16151585
console.error('Failed to load address settings:', error)

dashboard/vite.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default defineConfig(({ command, mode }) => {
2929
// 构建配置
3030
build: {
3131
// 输出目录
32-
outDir: 'dist',
32+
outDir: env.VITE_OUT_DIR || 'dist',
3333
// 静态资源目录
3434
assetsDir: 'assets',
3535
// 生成相对路径的资源引用

0 commit comments

Comments
 (0)