feat: add RealIP setting

This commit is contained in:
StarsEnd33A2D17 2024-09-29 21:36:17 +08:00
parent 481ba6bce3
commit adafffd86b
3 changed files with 58 additions and 0 deletions

View file

@ -36,6 +36,8 @@ let localStorage = {
server: '',
port: null,
},
enableRealIP: false,
realIP: null,
shortcuts: shortcuts,
},
data: {

View file

@ -38,8 +38,15 @@ service.interceptors.request.use(function (config) {
config.params.realIP = '211.161.244.70';
}
// Force real_ip
const enableRealIP = JSON.parse(
localStorage.getItem('settings')
).enableRealIP;
const realIP = JSON.parse(localStorage.getItem('settings')).realIP;
if (process.env.VUE_APP_REAL_IP) {
config.params.realIP = process.env.VUE_APP_REAL_IP;
} else if (enableRealIP) {
config.params.realIP = realIP;
}
const proxy = JSON.parse(localStorage.getItem('settings')).proxyConfig;

View file

@ -641,6 +641,33 @@
<button @click="sendProxyConfig">更新代理</button>
</div>
</div>
<div v-if="isElectron">
<h3>Real IP</h3>
<div class="item">
<div class="left">
<div class="title"> Real IP </div>
</div>
<div class="right">
<div class="toggle">
<input
id="enable-real-ip"
v-model="enableRealIP"
type="checkbox"
name="enable-real-ip"
/>
<label for="enable-real-ip"></label>
</div>
</div>
</div>
<div id="real-ip" :class="{ disabled: !enableRealIP }">
<input
v-model="realIP"
class="text-input"
placeholder="IP地址"
:disabled="!enableRealIP"
/>
</div>
</div>
<div v-if="isElectron">
<h3>快捷键</h3>
@ -1124,6 +1151,28 @@ export default {
});
},
},
enableRealIP: {
get() {
return this.settings.enableRealIP || false;
},
set(value) {
this.$store.commit('updateSettings', {
key: 'enableRealIP',
value: value,
});
},
},
realIP: {
get() {
return this.settings.realIP || '';
},
set(value) {
this.$store.commit('updateSettings', {
key: 'realIP',
value: value,
});
},
},
proxyPort: {
get() {
return this.settings.proxyConfig?.port || '';