Commit 6dadb1ac by haojie

更新配置项

parent 2d3238d5
import { Web_name, SiteConfig } from '../constants/token'; import { Web_name, SiteConfig } from '../constants/token';
import { ListSort } from '../utils/tool';
import homeRouters from '../router/modules/home';
// 获取网站标题 // 获取网站标题
export const getSiteTitle = () => { export const getSiteTitle = () => {
...@@ -12,21 +10,6 @@ export const getSiteRouter = () => { ...@@ -12,21 +10,6 @@ export const getSiteRouter = () => {
if (SiteConfig[Web_name] && SiteConfig[Web_name].router) { if (SiteConfig[Web_name] && SiteConfig[Web_name].router) {
return SiteConfig[Web_name].router; return SiteConfig[Web_name].router;
} }
// 默认路由
return homeRouters;
};
// 获取导航栏列表
export const getNavList = (list: any[]) => {
let nav_list = SiteConfig[Web_name].nav;
nav_list.forEach((item: any) => {
list.forEach((it: any) => {
if (item.name === it.name && item.is_hidden) {
it.is_hidden = true;
}
});
});
return list;
}; };
// 获取网站logo // 获取网站logo
...@@ -35,53 +18,14 @@ export const getSiteLogo = () => { ...@@ -35,53 +18,14 @@ export const getSiteLogo = () => {
}; };
// 获取打包名称 // 获取打包名称
export const getBuildOutName = () => { export const getBuildOutName = (need_time: boolean = true) => {
// 获取打包时间 if (need_time) {
let date = new Date(); // 获取打包时间
let newDate = `${date.getFullYear()}-${ let date = new Date();
date.getMonth() + 1 let newDate = `${date.getFullYear()}-${
}-${date.getDate()}--${date.getHours()}.${date.getMinutes()}`; date.getMonth() + 1
return `${SiteConfig[Web_name].build_file_name}-${newDate}`; }-${date.getDate()}--${date.getHours()}.${date.getMinutes()}`;
}; return `${SiteConfig[Web_name].build_file_name}-${newDate}`;
// 手机号列表版本
export const phone_type = '7';
// 手机号置顶列表
export const phoneTopList = () => {
return SiteConfig[Web_name].top_phone_list;
};
// 获取手机号列表--排序的
export const gePhoneList = (need: boolean) => {
if (need) {
let type = localStorage.getItem('phoneCodes_type');
if (type !== phone_type) {
// 版本不一致时,更新数据
return [];
}
}
let data = localStorage.getItem('phoneCodes');
if (data) {
let list = phoneTopList();
// 修改顺序
let testList = ListSort(JSON.parse(data), list);
return testList;
} else {
return [];
} }
}; return `${SiteConfig[Web_name].build_file_name}`;
// 获取Footer的各种链接
export const getFooterLinks = () => {
return SiteConfig[Web_name].footer_links;
};
// 获取whatsapp链接
export const getWhatsAppLink = () => {
return SiteConfig[Web_name].whatsapp_link;
};
// 是否显示签到弹窗
export const showSignInDialog = () => {
return SiteConfig[Web_name].sign_in_dialog;
}; };
// 网站可选项 // 网站可选项
export const webNameList = { export const webNameList = {
SILKR: 'SILKR', SILKR: 'SILKR',
TIDRK: 'TIDRK',
test: 'test',
// 测试平台
}; };
// 网站名称---标识-不用做实际标题 // 网站名称---标识-不用做实际标题
export const Web_name: 'SILKR' | 'TIDRK' | any = webNameList.SILKR; export const Web_name: 'SILKR' | 'TIDRK' | any = webNameList.SILKR;
...@@ -18,9 +15,7 @@ export const SiteConfig = { ...@@ -18,9 +15,7 @@ export const SiteConfig = {
// 浏览器的logo // 浏览器的logo
site_logo: '<link rel="icon" href="/logo.svg" id="browser-icon" />', site_logo: '<link rel="icon" href="/logo.svg" id="browser-icon" />',
// 打包目录名 // 打包目录名
build_file_name: 'silkr-web', build_file_name: 'live_stream',
// 手机号置顶列表
top_phone_list: ['52', '51', '58', '57', '593'],
router: [ router: [
{ {
path: '/', path: '/',
...@@ -41,63 +36,5 @@ export const SiteConfig = { ...@@ -41,63 +36,5 @@ export const SiteConfig = {
], ],
}, },
], ],
// 首页是否显示签到弹窗
sign_in_dialog: true,
// 导航栏列表
nav: [
{
name: 'Snow',
},
{
name: 'marketConditions',
},
{
name: 'Trading',
},
{
name: 'EarnCoins',
},
{
name: 'upComing',
},
// {
// name: 'cloudminer',
// disabled: false,
// },
],
// 底部联系我们
footer_links: {
twitter: 'https://twitter.com/KentBetty7',
youtube: 'https://www.youtube.com/@silkdvip0115',
tg: 'https://t.me/silkdvip0115',
facebook: 'https://www.facebook.com/iveco.iveco.3110?mibextid=LQQJ4d',
},
whatsapp_link: 'https://api.whatsapp.com/send/?phone=639054988009&text&type=phone_number&app_absent=0',
}, },
}; };
/**
* 各个页面的手续费接口type参数
*/
//提现
export const config_type_withDrawal = 1;
// 现货
export const config_type_shop_trading = 2;
// 合约
export const config_type_contract_trading = 3;
// 预售
export const config_type_sale_trading = 4;
// 赚币宝
export const config_type_pledge_trading = 5;
// 矿机
export const config_type_mining_trading = 6;
// trading-name
export const default_trading_info = {
token: 'BTC',
name: 'btcusdt',
price: '16600.01',
};
// 点击充值按钮是否显示维护弹窗
export const InMaintenance = false;
...@@ -44,7 +44,6 @@ import SwitchLanguage from '@/components/SwitchLanguage/index'; ...@@ -44,7 +44,6 @@ import SwitchLanguage from '@/components/SwitchLanguage/index';
import ChangeTheme from '@/components/changeTheme.vue'; import ChangeTheme from '@/components/changeTheme.vue';
import LoginDropdown from './LoginDropdown.vue'; import LoginDropdown from './LoginDropdown.vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { getNavList } from '@/config/site';
const router = useRouter(); const router = useRouter();
const store = useStore(); const store = useStore();
const route = useRoute(); const route = useRoute();
...@@ -83,7 +82,7 @@ const buttons = computed(() => { ...@@ -83,7 +82,7 @@ const buttons = computed(() => {
disabled: false, disabled: false,
}, },
]; ];
return getNavList(list); return list;
}); });
const ChangeRouter = (item: any) => { const ChangeRouter = (item: any) => {
CurRouter.value = item.name; CurRouter.value = item.name;
......
export default [
{
path: '/',
component: () => import('@/layouts'),
children: [
{
path: '/',
name: 'Snow',
component: () => import('@/pages/home/index.vue'),
meta: { title: 'snowhome' },
},
{
path: '/live',
name: 'live',
component: () => import('@/pages/liveManagement/index.vue'),
meta: { title: 'snowhome' },
},
],
},
];
// 统一管理路由 // 统一管理路由名称和路径
export default {
home: {
path: '/',
name: 'liveStream',
},
};
...@@ -2,8 +2,6 @@ import { createStore } from 'vuex'; ...@@ -2,8 +2,6 @@ import { createStore } from 'vuex';
import user from './modules/user'; import user from './modules/user';
import setting from './modules/setting'; import setting from './modules/setting';
import theme from './modules/theme'; import theme from './modules/theme';
import reload from './modules/reload';
import token from './modules/token';
import language from './modules/language'; import language from './modules/language';
export const store = createStore({ export const store = createStore({
...@@ -11,8 +9,6 @@ export const store = createStore({ ...@@ -11,8 +9,6 @@ export const store = createStore({
user, user,
setting, setting,
theme, theme,
reload,
token,
language, language,
}, },
}); });
......
const state = {
load: 0,
};
type StateType = typeof state;
const mutations = {
setLoad(state: StateType, info: number) {
state.load += info;
},
};
const getters = {
getLoad: (state: StateType) => {
return state.load;
},
};
const actions = {};
export default {
namespaced: true,
state,
mutations,
actions,
getters,
};
const state = {
// k线页面当前币的id
token_id: null,
// 最新价格
new_price: {},
subscribers: {
tbname: '',
ts: null,
list: [],
PriceNum: null,
},
};
type StateType = typeof state;
const mutations = {
setTokenID(state: StateType, info: number) {
state.token_id = info;
},
// 更新k线页面的最新价格
setTradePrice(state: StateType, info: any) {
state.new_price[info.key] = info.value;
},
// 提交k线更新的线
setTradingNewList(state: StateType, info: any) {
if ('tbname' in info) {
state.subscribers.tbname = info.tbname;
}
if ('ts' in info) {
state.subscribers.ts = info.ts;
}
if ('list' in info) {
state.subscribers.list = info.list;
}
if ('PriceNum' in info) {
state.subscribers.PriceNum = info.PriceNum;
}
},
// 清空newlist数据
deleteTradingNewList(state: StateType) {
state.subscribers.tbname = '';
state.subscribers.ts = null;
state.subscribers.list = [];
state.subscribers.PriceNum = null;
},
};
const getters = {
getTokenID: (state: StateType) => {
return state.token_id;
},
// 获取price
getTradePrice: (state: StateType) => {
return state.new_price;
},
getTradingNewList: (state: StateType) => {
return state.subscribers;
},
};
const actions = {
async computerPrice({ commit }) {
if (state.subscribers.tbname && state.subscribers.list.length) {
// 先获取小数位
let str = state.subscribers.PriceNum + '';
let count = (str.match(/0/g) || []).length;
if (!state.subscribers.ts) {
// 定时任务还没有取到数据--直接取最后一条
commit('setTradePrice', {
key: state.subscribers.tbname,
value: state.subscribers.list[state.subscribers.list.length - 1].close.toFixed(count),
});
} else {
// 最后的时间戳存在--找到时间戳对应的close
let obj = state.subscribers.list.find((item: any) => item.ts == state.subscribers.ts);
if (obj) {
commit('setTradePrice', {
key: state.subscribers.tbname,
value: obj.close.toFixed(count),
});
}
}
}
},
};
export default {
namespaced: true,
state,
mutations,
actions,
getters,
};
import router from '@/router';
export const ToTradePage = (name: string, price: string | number, type: string) => {
let path = `/Trading/${name}`;
router[type]({
path: path,
query: {
price: price,
},
});
};
export const WatchupDownColor = (value: any) => {
try {
if (value) {
if (value[0] === '-') {
// 跌
return 'var(--theme-color-12)';
} else {
return 'var(--theme-color-11)';
}
}
} catch (e) {
console.log(e);
}
};
/*
* @Author: walker.liu
* @Date: 2022-05-24 10:51:56
* @Copyright(C): 2019-2020 ZP Inc. All rights reserved.
*/
import store from '@/store';
import request from '@/utils/request';
import { PriceAccuracy, computedTime } from './tool';
import { TradingviewLanguage } from '@/language/options';
declare const TradingView: any;
/**
* @key Server ding字段 supported_resolutions
*/
// 1min, 5min, 15min, 30min, 60min, 4hour, 1day, 1mon, 1week, 1year
export const intervalMap = {
'1min': '1',
'5min': '5',
'15min': '15',
'30min': '30',
'60min': '60',
'4hour': '240',
'1day': 'D',
'1week': 'W',
'1mon': 'M',
};
/** trading-view 的時間區間 */
export const supportedResolutions = ['1', '5', '15', '30', '60', '240', 'D', 'W', 'M'];
export class DataFeed {
private symbolInfo: any;
private subscribers: any[] = [];
private interval = null;
private TradingList: any[] = [];
private resolution = '1';
// 每个时间段都要给5次重试次数
private RetryTime = {
r1: 0,
r5: 0,
r15: 0,
r60: 0,
r240: 0,
r1D: 0,
};
private KPirce = null;
constructor(symbolInfo: any, timeInterval = 1000) {
this.KPirce = symbolInfo.KPirce;
// 将传过来的多余参数剔除
delete symbolInfo.KPirce;
this.symbolInfo = symbolInfo;
this.intervalGetBars(symbolInfo.ticker, timeInterval);
}
public onReady(onGameLoad) {
new Promise((resolve) => {
resolve(void 0);
}).then(() => {
onGameLoad({
supported_resolutions: supportedResolutions,
});
});
}
public searchSymbols() {}
public resolveSymbol(symbolName, onSymbolResolvedCallback, onResolveErrorCallback) {
new Promise((resolve) => {
resolve(void 0);
}).then(() => {
let PriceNum = 10000000000;
PriceNum = PriceAccuracy(this.KPirce);
store.commit('token/setTradingNewList', {
PriceNum: PriceNum,
});
onSymbolResolvedCallback({
session: '24x7',
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
supported_resolutions: supportedResolutions,
has_intraday: true,
has_daily: true,
// has_no_volume: true,
minmov: 1,
// minmove2:0,
// 最多支持16位小数
pricescale: PriceNum,
...this.symbolInfo,
});
});
}
/**
* 订阅K线数据。图表库将调用onRealtimeCallback方法以更新实时数据
*/
public subscribeBars(
symbolInfo,
resolution: string,
onRealtimeCallback,
subscriberUID: string,
onResetCacheNeededCallback: () => void,
) {
if (this.subscribers[subscriberUID]) {
return;
}
this.resolution = resolution;
this.subscribers[subscriberUID] = {
lastBarTime: null,
listener: onRealtimeCallback,
resolution: resolution,
symbolInfo: symbolInfo,
};
}
/**
* 取消订阅K线数据
*/
public unsubscribeBars(subscriberUID: string) {
if (!this.subscribers[subscriberUID]) {
return;
}
delete this.subscribers[subscriberUID];
}
public updateKLine(bar) {
for (const listenerGuid in this.subscribers) {
const subscriptionRecord = this.subscribers[listenerGuid];
if (subscriptionRecord.lastBarTime !== null && bar.time < subscriptionRecord.lastBarTime) {
continue;
}
subscriptionRecord.lastBarTime = bar.time;
subscriptionRecord.listener(bar);
store.commit('token/setTradingNewList', {
tbname: this.symbolInfo.name,
ts: subscriptionRecord.lastBarTime,
});
store.dispatch('token/computerPrice');
}
}
public async getBars(symbolInfo, resolution, periodParams, onHistoryCallback, onErrorCallback) {
try {
const token = store.getters['user/token'];
let params = {
...periodParams,
resolution,
symbol: symbolInfo.ticker,
};
params.from = params.from * 1000;
params.to = params.to * 1000;
// 是否第一次請求歷史數據
if (periodParams.firstDataRequest) {
// params.to = Date.now();
params.is_first = true;
// 添加limit
params.limit = params.countBack + 50;
delete params.firstDataRequest;
delete params.countBack;
} else {
params.is_first = false;
delete params.firstDataRequest;
// 添加limit
params.limit = params.countBack;
delete params.countBack;
}
request
.get(`/api/currencies/kline`, {
params: params,
headers: {
authorization: `Bearer ${token}`,
},
})
.then((res: any) => {
let result = {
bars: [],
meta: { noData: false },
};
if (res.data.list && res.data.list.length > 0 && this.RetryTime[`r${resolution}`] < 5) {
result.meta.noData = false;
result.bars = res.data.list.map((item) => {
return {
time: item.ts,
open: item.open,
high: item.high,
low: item.low,
close: item.close,
volume: item.volume,
};
});
} else {
if (this.RetryTime[`r${resolution}`] < 5) {
this.RetryTime[`r${resolution}`] += 1;
} else {
result.meta.noData = true;
}
}
this.TradingList = this.TradingList.concat(result.bars);
store.commit('token/setTradingNewList', {
tbname: this.symbolInfo.name,
list: this.TradingList,
});
store.dispatch('token/computerPrice');
onHistoryCallback(result.bars, result.meta);
});
} catch (error) {
onHistoryCallback({
bars: [],
meta: { noData: true },
});
}
}
public intervalGetBars(symbol, timeInterval) {
this.interval = setInterval(() => {
const token = store.getters['user/token'];
let from = computedTime(this.resolution);
let current = new Date().getTime();
let params = {
resolution: this.resolution,
to: current,
// from: current - timeInterval,
from: from ? from : current - timeInterval,
// from: current - 5000,
symbol: symbol,
is_first: false,
limit: 2,
};
request
.get(`/api/currencies/kline`, {
params: params,
headers: {
authorization: `Bearer ${token}`,
},
})
.then((res: any) => {
if (res && res.data.list.length) {
res.data.list.forEach((item) => {
this.updateKLine({
time: item.ts,
open: item.open,
high: item.high,
low: item.low,
close: item.close,
volume: item.volume,
});
});
this.TradingList = this.TradingList.concat(res.data.list);
store.commit('token/setTradingNewList', {
list: this.TradingList,
});
store.dispatch('token/computerPrice');
}
});
}, 5000);
}
public clearIntervalGetBars() {
clearInterval(this.interval);
}
}
export class Widget {
private options: any;
public widget = null;
constructor(options = {}) {
// 主题
const mode = store.getters['setting/mode'];
var d1 = new Date(2009, 0, 1);
var d2 = new Date(2009, 6, 1);
// Asia/Baghdad--(+3)
if (d1.getTimezoneOffset() != d2.getTimezoneOffset()) {
// console.log('夏令时');
} else {
// console.log('非夏令时');
}
this.options = {
// debug: true,
library_path: '/charting_library/',
// 主题
// theme: 'light',
theme: mode,
locale: TradingviewLanguage(),
autosize: !0,
container: 'tv_chart_container',
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
interval: '1',
favorites: {
intervals: ['1', '5', '15', '60', '240', 'D', 'W', 'M'],
chartTypes: ['Candles', 'Line'],
},
// enabled_features: ['study_templates'],
disabled_features: [
'header_symbol_search',
'header_compare',
'header_saveload',
'header_fullscreen_button',
// 禁用本地存储功能
// 'use_localstorage_for_settings',
'save_chart_properties_to_local_storage',
],
overrides: {
// 默认展示的图表
'mainSeriesProperties.style': 1,
// 'mainSeriesProperties.highLowAvgPrice.highLowPriceLinesVisible': true, //高低线值
// 'mainSeriesProperties.highLowAvgPrice.highLowPriceLabelsVisible': true, //高低线名称
// 'mainSeriesProperties.highLowAvgPrice.averageClosePriceLineVisible': true, //均线
// 'mainSeriesProperties.highLowAvgPrice.averageClosePriceLabelVisible': true, //均线
},
// custom_css_url: '/src/style/tradingview.less',
...options,
};
this.initWidget();
}
public initWidget() {
this.widget = window.tvWidget = new TradingView.widget(this.options);
}
}
...@@ -70,7 +70,7 @@ export default defineConfig(({ command, mode }) => { ...@@ -70,7 +70,7 @@ export default defineConfig(({ command, mode }) => {
}, },
build: { build: {
minify: 'terser', // 混淆器,terser构建后文件体积更小 minify: 'terser', // 混淆器,terser构建后文件体积更小
outDir: getBuildOutName(), //指定输出路径 outDir: getBuildOutName(false), //指定输出路径
cssCodeSplit: false, // 如果设置为false,整个项目中的所有 CSS 将被提取到一个 CSS 文件中 cssCodeSplit: false, // 如果设置为false,整个项目中的所有 CSS 将被提取到一个 CSS 文件中
terserOptions: { terserOptions: {
compress: { compress: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment