This commit is contained in:
lingling 2024-11-28 22:05:04 +08:00
parent 1b2f1e6374
commit a51faba9af
9 changed files with 6156 additions and 461 deletions

5419
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -15,6 +15,7 @@
"@waiting/base64": "^4.2.9", "@waiting/base64": "^4.2.9",
"axios": "^1.2.1", "axios": "^1.2.1",
"js-base64": "^3.7.5", "js-base64": "^3.7.5",
"link-chang": "file:",
"quasar": "^2.6.0", "quasar": "^2.6.0",
"vue": "^3.0.0", "vue": "^3.0.0",
"vue-router": "^4.0.0", "vue-router": "^4.0.0",
@ -22,6 +23,7 @@
}, },
"devDependencies": { "devDependencies": {
"@quasar/app-vite": "^1.0.0", "@quasar/app-vite": "^1.0.0",
"@quasar/quasar-app-extension-testing": "^2.2.0",
"@types/node": "^12.20.21", "@types/node": "^12.20.21",
"@typescript-eslint/eslint-plugin": "^5.10.0", "@typescript-eslint/eslint-plugin": "^5.10.0",
"@typescript-eslint/parser": "^5.10.0", "@typescript-eslint/parser": "^5.10.0",
@ -33,7 +35,7 @@
"typescript": "^4.5.4" "typescript": "^4.5.4"
}, },
"engines": { "engines": {
"node": "^18 || ^16 || ^14.19", "node": "^22 || ^18 || ^16 || ^14.19",
"npm": ">= 6.13.4", "npm": ">= 6.13.4",
"yarn": ">= 1.21.1" "yarn": ">= 1.21.1"
} }

133
src/Util/index.ts Normal file
View File

@ -0,0 +1,133 @@
import { decode, encode } from 'js-base64'
import { getdata } from 'src/api/api';
import { vless, VlessLink, vmess } from 'src/components/models';
const is_ip = (ip: string) => {
const reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
return reg.test(ip);
}
/**
* vmess
* @param ip IP地址
* @returns vmess链接
*/
async function CreatVmessDirect(ip: string): Promise<string> {
let tmp = ''
const api = new getdata;
const def_link = 'ew0KICAidiI6ICIyIiwNCiAgInBzIjogIjAiLA0KICAiYWRkIjogIjE4NS4yMTguNi4xMDgiLA0KICAicG9ydCI6ICI5MDAwIiwNCiAgImlkIjogIjJlZTU3ODA2LWY2ZTQtNDgyYS1lZjA4LTczNjBjMDRjZDNlNSIsDQogICJhaWQiOiAiMCIsDQogICJzY3kiOiAiYXV0byIsDQogICJuZXQiOiAid3MiLA0KICAidHlwZSI6ICJub25lIiwNCiAgImhvc3QiOiAiIiwNCiAgInBhdGgiOiAiLyIsDQogICJ0bHMiOiAiIiwNCiAgInNuaSI6ICIiLA0KICAiYWxwbiI6ICIiDQp9'
const obj = JSON.parse(decode(def_link))
const array = ip.split(/[\s\n]/)
for (let index = 0; index < array.length; index++) {
if (!is_ip(array[index])) {
return ''
}
for (let index = 0; index < array.length; index++) {
const name = await api.get_country(array[index])
obj.ps = name + array[index]
obj.add = array[index]
tmp += 'vmess://' + encode(JSON.stringify(obj)) + '\n'
}
}
return tmp
}
function ChangVmessServer() {
return 0
}
/**
*
* @param type vmess |vless
*/
function CreateLink(type: string, linkinfo: vmess | vless) {
const tmp = ''
switch (type) {
case 'vless':
linkinfo.add
break;
case 'vmess':
break;
default:
break;
}
return tmp
}
// async function CreatVmessDirect(ip: string): Promise<string> {
// }
/**
* vless
* @param link
* @returns
*/
function parseVlessLink(link: string): VlessLink | null {
const regex = /^vless:\/\/([a-f0-9-]+)@([^:]+):(\d+)(\?.*)?(#.*)?$/i;
const match = link.match(regex);
if (!match) {
console.error('Invalid VLESS link format.');
return null;
}
const uuid = match[1];
const host = match[2];
const port = parseInt(match[3], 10);
const params = parseParams(match[4]);
const name = match[5] ? match[5].slice(1) : undefined; // 去掉 # 符号
return {
uuid,
host,
port,
params,
name,
};
}
/**
* vless携带的其他参数
* @param paramString
* @returns
*/
function parseParams(paramString: string | undefined): Record<string, string> {
if (!paramString) return {};
const params: Record<string, string> = {};
const query = paramString.slice(1); // Remove the "?" at the start
const pairs = query.split('&');
pairs.forEach((pair) => {
const [key, value] = pair.split('=');
if (key && value) {
params[key] = decodeURIComponent(value);
}
});
return params;
}
/**
* vless链接
* @param param0
* @returns
*/
function createVlessLink({ uuid, host, port, params, name }: VlessLink): string {
// 基本的 VLESS 链接格式
let link = `vless://${uuid}@${host}:${port}`;
// 如果有查询参数,则拼接它们
if (params && Object.keys(params).length > 0) {
const queryString = new URLSearchParams(params).toString();
link += `?${queryString}`;
}
// 如果有名称字段,将名称放在 # 后面
if (name) {
link += `#${name}`;
}
return link;
}
export { CreatVmessDirect, ChangVmessServer, CreateLink, parseVlessLink }

View File

@ -1,13 +1,20 @@
import { api } from 'src/boot/axios'; import { api } from 'src/boot/axios';
class getdata { class getdata {
async get_server() { async get_server() {
return await api.get('https://api.shagain.club/api.php?type=list'); return await api.get('https://api.giaogiao.uk/api.php?type=list');
} }
async text_server(url: string) { async text_server(url: string) {
return await api.post('https://api.shagain.club/textserver', { url }); return await api.post(
'https://service-7hslob28-1258902677.nj.apigw.tencentcs.com/release/',
{ url }
);
} }
async get_country(ip: string) { async get_country(ip: string) {
return await api.post('https://api.shagain.club/api.php?type=searchip', { ip }); let res = await api.post('https://api.giaogiao.uk/api.php?type=searchip', {
ip,
});
res = res.data.country
return res
} }
} }
export { getdata }; export { getdata };

View File

@ -113,6 +113,31 @@ export default defineComponent({
}) })
}) })
} }
const getColorByBaiFenBi = (bili: number) => {
//var = () / 50; 50%
let one = (255 + 255) / 100;
let r = 0;
let g = 0;
let b = 0;
if (bili < 50) {
// 50,255(+绿).
r = one * bili;
g = 255;
}
if (bili >= 50) {
// 50绿,0
g = 255 - ((bili - 50) * one);
r = 255;
}
r = Math.round(r);//
g = Math.round(g);//
b = Math.round(b);//
return 'rgb(' + r + ',' + g + ',' + b + ')';
}
return { props, outtext, copy, online, time, signal_style }; return { props, outtext, copy, online, time, signal_style };
}, },
}); });

View File

@ -6,6 +6,9 @@ export interface Todo {
export interface Meta { export interface Meta {
totalCount: number; totalCount: number;
} }
/**
*
*/
export interface server { export interface server {
host: string; host: string;
id: number; id: number;
@ -14,7 +17,9 @@ export interface server {
port: number; port: number;
tips: string; tips: string;
} }
/**
* vmess结构体
*/
export interface vmess { export interface vmess {
v: string; v: string;
ps: string; ps: string;
@ -31,3 +36,32 @@ export interface vmess {
sni: string; sni: string;
alpn: string alpn: string
} }
/**
* vless结构体
*/
export interface vless {
add: string;
port: number;
id: string;
encryption: string;
/**传输协议 */
net: string;
/**伪装类型 */
type: string;
/**地址 */
host: string;
/**路径 */
path: string;
/**tls */
tls: string;
/**sni */
sni: string;
name: string
}
export interface VlessLink {
uuid: string;
host: string;
port: number;
params?: Record<string, string>;
name?: string; // 允许传入名称
}

View File

@ -2,9 +2,13 @@ import { MutationTree } from 'vuex';
import { ExampleStateInterface } from './state'; import { ExampleStateInterface } from './state';
const mutation: MutationTree<ExampleStateInterface> = { const mutation: MutationTree<ExampleStateInterface> = {
someMutation (/* state: ExampleStateInterface */) { someMutation(/* state: ExampleStateInterface */) {
// your code // your code
} },
//改动url
set_text_server_url(state, url) {
state.text_server_url = url;
},
}; };
export default mutation; export default mutation;

View File

@ -1,11 +1,13 @@
export interface ExampleStateInterface { export interface ExampleStateInterface {
prop: boolean; prop: boolean;
text_server_url: string;
} }
function state(): ExampleStateInterface { function state(): ExampleStateInterface {
return { return {
prop: false prop: false,
} text_server_url: '',
};
} }
export default state; export default state;

973
yarn.lock

File diff suppressed because it is too large Load Diff