优化自定义服务器
This commit is contained in:
parent
1d20f529a0
commit
e711220a66
1
cmd
1
cmd
@ -160,6 +160,7 @@ run_mysql() {
|
|||||||
fi
|
fi
|
||||||
docker cp $filename $container_name:/
|
docker cp $filename $container_name:/
|
||||||
run_exec mariadb "gunzip < /$inputname | mysql -u$username -p$password $database"
|
run_exec mariadb "gunzip < /$inputname | mysql -u$username -p$password $database"
|
||||||
|
run_exec php "php artisan migrate"
|
||||||
judge "还原数据库"
|
judge "还原数据库"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
2
electron/build.js
vendored
2
electron/build.js
vendored
@ -27,7 +27,7 @@ function startBuild(data, publish) {
|
|||||||
origin: "./",
|
origin: "./",
|
||||||
apiUrl: utils.formatUrl(data.url) + "api/",
|
apiUrl: utils.formatUrl(data.url) + "api/",
|
||||||
}
|
}
|
||||||
fs.writeFileSync(electronDir + "/config.js", "window.systemInformation = " + JSON.stringify(systemInfo, null, 2), 'utf8');
|
fs.writeFileSync(electronDir + "/config.js", "window.systemInfo = " + JSON.stringify(systemInfo, null, 2), 'utf8');
|
||||||
fs.writeFileSync(nativeCachePath, utils.formatUrl(data.url));
|
fs.writeFileSync(nativeCachePath, utils.formatUrl(data.url));
|
||||||
fs.writeFileSync(devloadCachePath, "", 'utf8');
|
fs.writeFileSync(devloadCachePath, "", 'utf8');
|
||||||
// index.html
|
// index.html
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
document.writeln("<script src=\'./js/app.js?v=" + window.systemInformation.version + "\'><\/script>");
|
document.writeln("<script src=\'./js/app.js?v=" + window.systemInfo.version + "\'><\/script>");
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
@ -51,7 +51,8 @@
|
|||||||
"files": [
|
"files": [
|
||||||
"public/**/*",
|
"public/**/*",
|
||||||
"main.js",
|
"main.js",
|
||||||
"preload.js"
|
"preload.js",
|
||||||
|
"utils.js"
|
||||||
],
|
],
|
||||||
"mac": {
|
"mac": {
|
||||||
"icon": "../resources/assets/statics/public/images/logo-app.png",
|
"icon": "../resources/assets/statics/public/images/logo-app.png",
|
||||||
|
2
electron/utils.js
vendored
2
electron/utils.js
vendored
@ -249,7 +249,7 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
getDomain(weburl) {
|
getDomain(weburl) {
|
||||||
let urlReg = /http(s)?:\/\/([^\/]+)/i;
|
let urlReg = /http(s)?:\/\/([^\/]+)/i;
|
||||||
let domain = weburl.match(urlReg);
|
let domain = (weburl + "").match(urlReg);
|
||||||
return ((domain != null && domain.length > 0) ? domain[2] : "");
|
return ((domain != null && domain.length > 0) ? domain[2] : "");
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,11 @@
|
|||||||
"name": "HitoseaTask",
|
"name": "HitoseaTask",
|
||||||
"id": "com.hitosea.task",
|
"id": "com.hitosea.task",
|
||||||
"url": "https://t.hitosea.com/"
|
"url": "https://t.hitosea.com/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Public DooTask",
|
||||||
|
"id": "com.dootask.public",
|
||||||
|
"url": "https://public/"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -125,9 +125,9 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
chackReleases() {
|
chackReleases() {
|
||||||
let hostName = window.location.hostname;
|
let hostName = $A.getDomain(window.systemInfo.apiUrl);
|
||||||
if (hostName == '127.0.0.1') {
|
if (hostName == "" || hostName == '127.0.0.1') {
|
||||||
hostName = "www.dootask.com"
|
hostName = "public"
|
||||||
}
|
}
|
||||||
if (this.$Electron) {
|
if (this.$Electron) {
|
||||||
// 客户端(更新)
|
// 客户端(更新)
|
||||||
@ -147,7 +147,7 @@ export default {
|
|||||||
if (!this.repoData) {
|
if (!this.repoData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let currentVersion = window.systemInformation.version;
|
let currentVersion = window.systemInfo.version;
|
||||||
let latestVersion = $A.leftDelete(this.releases.tag_name.toLowerCase(), "v")
|
let latestVersion = $A.leftDelete(this.releases.tag_name.toLowerCase(), "v")
|
||||||
if (this.compareVersion(latestVersion, currentVersion) === 1) {
|
if (this.compareVersion(latestVersion, currentVersion) === 1) {
|
||||||
// 有新版本
|
// 有新版本
|
||||||
|
16
resources/assets/js/functions/common.js
vendored
16
resources/assets/js/functions/common.js
vendored
@ -2,6 +2,7 @@
|
|||||||
* 基础函数
|
* 基础函数
|
||||||
*/
|
*/
|
||||||
(function (window, $, undefined) {
|
(function (window, $, undefined) {
|
||||||
|
window.systemInfo = window.systemInfo || {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
@ -794,7 +795,7 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (this.rightExists(url, '.js')) {
|
if (this.rightExists(url, '.js')) {
|
||||||
script.src = url + "?hash=" + window.systemInformation.version;
|
script.src = url + "?hash=" + window.systemInfo.version;
|
||||||
} else {
|
} else {
|
||||||
script.src = url;
|
script.src = url;
|
||||||
}
|
}
|
||||||
@ -850,7 +851,7 @@
|
|||||||
}
|
}
|
||||||
script.rel = 'stylesheet';
|
script.rel = 'stylesheet';
|
||||||
if (this.rightExists(url, '.css')) {
|
if (this.rightExists(url, '.css')) {
|
||||||
script.href = url + "?hash=" + window.systemInformation.version;
|
script.href = url + "?hash=" + window.systemInfo.version;
|
||||||
} else {
|
} else {
|
||||||
script.href = url;
|
script.href = url;
|
||||||
}
|
}
|
||||||
@ -928,6 +929,17 @@
|
|||||||
return {'<': '<', '>': '>', '&': '&', '"': '"'}[c];
|
return {'<': '<', '>': '>', '&': '&', '"': '"'}[c];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 正则提取域名
|
||||||
|
* @param weburl
|
||||||
|
* @returns {string|string}
|
||||||
|
*/
|
||||||
|
getDomain(weburl) {
|
||||||
|
let urlReg = /http(s)?:\/\/([^\/]+)/i;
|
||||||
|
let domain = (weburl + "").match(urlReg);
|
||||||
|
return ((domain != null && domain.length > 0) ? domain[2] : "");
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
10
resources/assets/js/functions/web.js
vendored
10
resources/assets/js/functions/web.js
vendored
@ -22,8 +22,8 @@
|
|||||||
str.substring(0, 1) === "/") {
|
str.substring(0, 1) === "/") {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
if (window.systemInformation && typeof window.systemInformation.apiUrl === "string") {
|
if (typeof window.systemInfo.apiUrl === "string") {
|
||||||
str = window.systemInformation.apiUrl + str;
|
str = window.systemInfo.apiUrl + str;
|
||||||
} else {
|
} else {
|
||||||
str = window.location.origin + "/api/" + str;
|
str = window.location.origin + "/api/" + str;
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务器地址
|
* 服务地址
|
||||||
* @param str
|
* @param str
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
@ -46,8 +46,8 @@
|
|||||||
str.substring(0, 1) === "/") {
|
str.substring(0, 1) === "/") {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
if (window.systemInformation && typeof window.systemInformation.origin === "string") {
|
if (typeof window.systemInfo.origin === "string") {
|
||||||
str = window.systemInformation.origin + str;
|
str = window.systemInfo.origin + str;
|
||||||
} else {
|
} else {
|
||||||
str = window.location.origin + "/" + str;
|
str = window.location.origin + "/" + str;
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
<div class="login-body">
|
<div class="login-body">
|
||||||
<div class="login-logo"></div>
|
<div class="login-logo"></div>
|
||||||
<div class="login-box">
|
<div class="login-box">
|
||||||
<div class="login-title">Welcome Dootask</div>
|
<div class="login-title">Welcome {{welcomeTitle}}</div>
|
||||||
|
|
||||||
<div v-if="loginType=='reg'" class="login-subtitle">{{$L('输入您的信息以创建帐户。')}}</div>
|
<div v-if="loginType=='reg'" class="login-subtitle">{{$L('输入您的信息以创建帐户。')}}</div>
|
||||||
<div v-else class="login-subtitle">{{$L('输入您的凭证以访问您的帐户。')}}</div>
|
<div v-else class="login-subtitle">{{$L('输入您的凭证以访问您的帐户。')}}</div>
|
||||||
|
|
||||||
<div class="login-input">
|
<div class="login-input">
|
||||||
<Input v-if="$Electron && cacheServerUrl" :value="cacheServerUrl" prefix="ios-globe-outline" size="large" readonly clearable @on-clear="onServerUrlClear"/>
|
<Input v-if="$Electron && cacheServerUrl" :value="cacheServerUrl" prefix="ios-globe-outline" size="large" readonly clearable @on-clear="clearServerUrl"/>
|
||||||
|
|
||||||
<Input v-model="email" prefix="ios-mail-outline" :placeholder="$L('输入您的电子邮件')" size="large" @on-enter="onLogin" @on-blur="onBlur" />
|
<Input v-model="email" prefix="ios-mail-outline" :placeholder="$L('输入您的电子邮件')" size="large" @on-enter="onLogin" @on-blur="onBlur" />
|
||||||
<Input v-model="password" prefix="ios-lock-outline" :placeholder="$L('输入您的密码')" type="password" size="large" @on-enter="onLogin" />
|
<Input v-model="password" prefix="ios-lock-outline" :placeholder="$L('输入您的密码')" type="password" size="large" @on-enter="onLogin" />
|
||||||
@ -43,7 +43,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="$Electron" class="login-right-bottom">
|
<div v-if="$Electron" class="login-right-bottom">
|
||||||
<Button icon="ios-globe-outline" type="primary" @click="onServerUrlInput">{{$L('自定义服务器')}}</Button>
|
<Button icon="ios-globe-outline" type="primary" @click="inputServerUrl">{{$L('自定义服务器')}}</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -56,6 +56,8 @@ export default {
|
|||||||
return {
|
return {
|
||||||
loadIng: 0,
|
loadIng: 0,
|
||||||
|
|
||||||
|
welcomeTitle: window.systemInfo.title || "Dootask",
|
||||||
|
|
||||||
codeNeed: false,
|
codeNeed: false,
|
||||||
codeUrl: $A.apiUrl('users/login/codeimg'),
|
codeUrl: $A.apiUrl('users/login/codeimg'),
|
||||||
|
|
||||||
@ -75,8 +77,10 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
this.getDemoAccount();
|
this.getDemoAccount();
|
||||||
//
|
//
|
||||||
if (!this.$Electron && this.cacheServerUrl) {
|
if (this.$Electron) {
|
||||||
this.onServerUrlClear();
|
this.chackServerUrl();
|
||||||
|
} else {
|
||||||
|
this.clearServerUrl();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
deactivated() {
|
deactivated() {
|
||||||
@ -109,6 +113,9 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getDemoAccount() {
|
getDemoAccount() {
|
||||||
|
if (this.isNotServer()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.$store.dispatch("call", {
|
this.$store.dispatch("call", {
|
||||||
url: 'system/demo',
|
url: 'system/demo',
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
@ -140,7 +147,7 @@ export default {
|
|||||||
this.codeUrl = $A.apiUrl('users/login/codeimg?_=' + Math.random())
|
this.codeUrl = $A.apiUrl('users/login/codeimg?_=' + Math.random())
|
||||||
},
|
},
|
||||||
|
|
||||||
onServerUrlInput() {
|
inputServerUrl() {
|
||||||
$A.modalInput({
|
$A.modalInput({
|
||||||
title: "自定义服务器",
|
title: "自定义服务器",
|
||||||
value: this.cacheServerUrl,
|
value: this.cacheServerUrl,
|
||||||
@ -156,23 +163,44 @@ export default {
|
|||||||
this.$store.dispatch("call", {
|
this.$store.dispatch("call", {
|
||||||
url: value + 'system/setting',
|
url: value + 'system/setting',
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
$A.setStorage("cacheServerUrl", value)
|
this.setServerUrl(value)
|
||||||
window.location.reload();
|
|
||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
$A.modalError(msg || "服务器地址无效", 301);
|
$A.modalError(msg || "服务器地址无效", 301);
|
||||||
cb()
|
cb()
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$A.setStorage("cacheServerUrl", "")
|
this.clearServerUrl();
|
||||||
window.location.reload();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onServerUrlClear() {
|
chackServerUrl() {
|
||||||
$A.setStorage("cacheServerUrl", "")
|
return new Promise((resolve, reject) => {
|
||||||
window.location.reload();
|
if (this.isNotServer()) {
|
||||||
|
$A.messageWarning("请设置服务器")
|
||||||
|
this.inputServerUrl()
|
||||||
|
reject()
|
||||||
|
} else {
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
setServerUrl(value) {
|
||||||
|
if (value != this.cacheServerUrl) {
|
||||||
|
$A.setStorage("cacheServerUrl", value)
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
clearServerUrl() {
|
||||||
|
this.setServerUrl("")
|
||||||
|
},
|
||||||
|
|
||||||
|
isNotServer() {
|
||||||
|
let apiHome = $A.getDomain(window.systemInfo.apiUrl)
|
||||||
|
return apiHome == "" || apiHome == "public"
|
||||||
},
|
},
|
||||||
|
|
||||||
onBlur() {
|
onBlur() {
|
||||||
@ -197,44 +225,46 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onLogin() {
|
onLogin() {
|
||||||
if (!this.email) {
|
this.chackServerUrl().then(() => {
|
||||||
return;
|
if (!this.email) {
|
||||||
}
|
|
||||||
if (!this.password) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (this.loginType == 'reg') {
|
|
||||||
if (this.password != this.password2) {
|
|
||||||
$A.noticeError("确认密码输入不一致");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
if (!this.password) {
|
||||||
this.loadIng++;
|
return;
|
||||||
this.$store.dispatch("call", {
|
|
||||||
url: 'users/login',
|
|
||||||
data: {
|
|
||||||
type: this.loginType,
|
|
||||||
email: this.email,
|
|
||||||
password: this.password,
|
|
||||||
code: this.code,
|
|
||||||
invite: this.invite,
|
|
||||||
},
|
|
||||||
}).then(({data}) => {
|
|
||||||
this.loadIng--;
|
|
||||||
$A.setStorage("cacheLoginEmail", this.email)
|
|
||||||
this.$store.dispatch("handleClearCache", data).then(() => {
|
|
||||||
this.goNext1();
|
|
||||||
}).catch(() => {
|
|
||||||
this.goNext1();
|
|
||||||
});
|
|
||||||
}).catch(({data, msg}) => {
|
|
||||||
this.loadIng--;
|
|
||||||
$A.noticeError(msg);
|
|
||||||
if (data.code === 'need') {
|
|
||||||
this.reCode();
|
|
||||||
this.codeNeed = true;
|
|
||||||
}
|
}
|
||||||
});
|
if (this.loginType == 'reg') {
|
||||||
|
if (this.password != this.password2) {
|
||||||
|
$A.noticeError("确认密码输入不一致");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.loadIng++;
|
||||||
|
this.$store.dispatch("call", {
|
||||||
|
url: 'users/login',
|
||||||
|
data: {
|
||||||
|
type: this.loginType,
|
||||||
|
email: this.email,
|
||||||
|
password: this.password,
|
||||||
|
code: this.code,
|
||||||
|
invite: this.invite,
|
||||||
|
},
|
||||||
|
}).then(({data}) => {
|
||||||
|
this.loadIng--;
|
||||||
|
$A.setStorage("cacheLoginEmail", this.email)
|
||||||
|
this.$store.dispatch("handleClearCache", data).then(() => {
|
||||||
|
this.goNext1();
|
||||||
|
}).catch(() => {
|
||||||
|
this.goNext1();
|
||||||
|
});
|
||||||
|
}).catch(({data, msg}) => {
|
||||||
|
this.loadIng--;
|
||||||
|
$A.noticeError(msg);
|
||||||
|
if (data.code === 'need') {
|
||||||
|
this.reCode();
|
||||||
|
this.codeNeed = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
goNext1() {
|
goNext1() {
|
||||||
|
4
resources/assets/js/store/state.js
vendored
4
resources/assets/js/store/state.js
vendored
@ -26,8 +26,8 @@ state.cacheProjectParameter = $A.getStorageArray("cacheProjectParameter");
|
|||||||
|
|
||||||
// ServerUrl
|
// ServerUrl
|
||||||
state.cacheServerUrl = $A.getStorageString("cacheServerUrl")
|
state.cacheServerUrl = $A.getStorageString("cacheServerUrl")
|
||||||
if (state.cacheServerUrl && window.systemInformation) {
|
if (state.cacheServerUrl) {
|
||||||
window.systemInformation.apiUrl = state.cacheServerUrl;
|
window.systemInfo.apiUrl = state.cacheServerUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ajax
|
// Ajax
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<script src="{{ asset_main('js/scroll-into-view.min.js') }}"></script>
|
<script src="{{ asset_main('js/scroll-into-view.min.js') }}"></script>
|
||||||
<script>
|
<script>
|
||||||
window.csrfToken = { csrfToken : "{{ csrf_token() }}" };
|
window.csrfToken = { csrfToken : "{{ csrf_token() }}" };
|
||||||
window.systemInformation = { version : "{{ $version }}", origin: window.location.origin + "/", apiUrl: null };
|
window.systemInfo = { title: "{{config('app.name', 'WebPage')}}", version : "{{ $version }}", origin: window.location.origin + "/", apiUrl: null };
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user